Forum Discussion
Altera_Forum
Honored Contributor
14 years agoelf2hex
It shouldnt be hard...
I have my project compiled in the SBT. I just need to convert the .elf file to hex I tried using the script below it gives me a hex file but with no information (all zeros). I am running the script below in the command shell. Am I doing anything wrong? Is there any other way to get a hex file out of SBT? elf2hex --input=project.elf --base=0x0 --end=4193404 --width=64 Thanks3 Replies
- Altera_Forum
Honored Contributor
Hi,
For me this works: elf2flash --base=0x0 --reset=0x00000000 --end=0x10000000 --input full_mv6.elf --output full_mv6.flash Try to look at it maybe it can help. BR, - Altera_Forum
Honored Contributor
elf2hex requires begin and end addresses of memory device. Let's say You've added 32bit wide on-chip memory, which begins at 0x01000000 and ends at 0x01001000 (SOPC/QSYS shows those addresses), so You generate a hex file like this:
I usually use much higher end address size, since --no-zero-fill removes all unnecessary zeroes from the file. For example for hex file for SDRAM, I use this script:elf2hex --input=project.elf --output=project.hex --no-zero-fill --base=0x01000000 --end=0x01001000
Width of 8bits is required because of SPI bootloader binary transfers. I copy the binary data from flash to SDRAM using my own bootloader. The end address is made as high, as possible, since I don't care what binary size it will be.elf2hex --input=project.elf --width=8 --no-zero-fill --output=project.hex --base=0x00800000 --end=0x008EFFFF - Altera_Forum
Honored Contributor
Check the addresses of the loadable elf segments with 'objdump -p foo.elf' possibly the address range you requested doesn't contain any data!.
I use 'objcopy -o binary -j section_name foo.elf' to extract the binary data from a nios elf image (then convert it to a ppc elf .o file).