05-04-2009 03:25 AM
Hi, in my Microblaze system I have an SRAM and a FLASH. I copy my code (the *.elf) with XMD to the SRAM then I start a small code in BRAM which copies the SRAM content word by word to FLASH. When booting the system the FLASH content is copied to SRAM and the system starts from the SRAM start address. (This was put up before there was the flashprogrammer tool in XPS). Now I want my system to be updated via UART but none of the above mentioned files do the trick. The only thing that worked so far was doing something similar like above : copy the *.elf to SRAM then copy with a small BRAM program to an MMC card. Then I extract the copied portion with a HEX editor and save it to a file. If I upload this one via UART to FLASH it works. The *.bin (which looks similar) doesn't. What can I do to generate a file that works ? (for a little more comfort :-) )
05-04-2009 10:32 AM
Since the file isn't being handled by an ELF loader, the binary file must first be flattened so that all instructions and data appear at the correct addresses. Additionally, all ELF header info (program/section headers, magic numbers, etc.) have to be removed as well. I would recommend using mb-objcopy to produce a binary file, and then use xxd to translate this binary file into a C header file.
Say you have a MicroBlaze ELF called executable.elf:
> mb-objcopy -I elf32-microblaze -O binary executable.elf temp.bin
> xxd -i -c 4 temp.bin exec.c
This produces a flattened C file that preserves memory layout while also removing all ELF header info (if header info is loaded into memory it would corrupt the executable). You can then link against this C file, and write the contents over UART, etc.
Also, you can compare the contents of the C file to the disassembled version of your executable by:
> mb-objdump -D executable.elf > disasm.txt
The instructions/data found in this file should correspond to those found in the array declared in the C file.
05-05-2009 04:00 AM
I boot from a similar method. Store the firmware update on SD card, at the user request copy the firmware to FLASH and then boot from FLASH to DDR using the standard methods.
I create a simple script to do the job:
powerpc-eabi-objcopy -O binary -j .vectors -j .text -j .init -j .fini -j .rodata -j .rodata1 -j .fw_version -j .sdata2 -j .sbss2 -j .data -j .got -j .got1 -j .got2 -j .ctors -j .dtors -j .eh_frame -j .jcr -j .gcc_except_table -j .sdata -j .sbss c:/lockie/lts2_disp1_001/release/lts2_disp1_001.elf c:/lockie/lts2_disp1_001/release/lts2_disp1_001_release.bin
powerpc-eabi-objcopy -O srec -j .vectors -j .text -j .init -j .fini -j .rodata -j .rodata1 -j .fw_version -j .sdata2 -j .sbss2 -j .data -j .got -j .got1 -j .got2 -j .ctors -j .dtors -j .eh_frame -j .jcr -j .gcc_except_table -j .sdata -j .sbss c:/lockie/lts2_disp1_001/release/lts2_disp1_001.elf c:/lockie/lts2_disp1_001/release/lts2_disp1_001_release.srec
powerpc-eabi-objdump -I .sbss2 c:/lockie/lts2_disp1_001/release/lts2_disp1_001.elf -x > c:/lockie/lts2_disp1_001/release/lts2_disp1_001_release_objdump.txt
The resulting .bin file can be byte-for-byte copied onto flash starting from address 0.
Hope this helps.
05-06-2009 12:20 AM
thank you for your answer, unfortunately the xxd command is "unknown" when I try to use it in the command shell. what could I have done wrong, or could be needed ?
05-06-2009 12:37 AM
thank you for your answer, I used the first part to create the .bin file (only changed to "mb-objcopy") and I think it works ! Only... if you don't mind could you explain a little what you do there and why, I'm afraid I'm not the command-line specialist... ;-) But I also understand if you say RTFM :-) .
btw: unrelated : r u from Scotland ?
05-06-2009 04:58 PM
SET CHERE_INVOKING=1 %XILINX_EDK%\bin\nt\xbash.exe -c "c:/lockie/xxxx/disp1_gen_bin_release.sh"
Run the batch file as part of your post build flow in XPS (project properties -> build tab).
This way every time you build your project, it will auto-build your .bin file..
I spent a long time with the FAE trying to work this out. There is no FM to R :)..
From Australia ;)