Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20638 Discussions

How to convert NIOS2 SW file to HEX

Altera_Forum
Honored Contributor II
3,090 Views

I need to program a CFI Flash (NOT EPCS) device that is attached to my Cyclone2 with both the HW and SW images. It appears one method that fits my needs is to follow appnote an478 and create a flash POF from the hw image SOF and sw image ELF. Then use the default config to load a PFL design in the FPGA to allow me to write to the CFI Flash over the JTAG interface. 

 

I think my problem is that I am assuming the SW image needs to be loaded into the "Convert Programming File" tool to create the POF (combines HW and SW image) but should be added as HEX data. I'm having trouble trying to convert my ELF file to HEX while being able to append the bootloader to the image (sw needs bootloader to transfer instructions from CFI Flash to external sdram). 

 

elf2hex does not allow the use of bootloader or offset address 

 

i've tried elf2flash, which does let me attach the bootloader, but then when I try the following command I get an error: 

 

nios2-elf-objcopy --input-target srec --output-target ihex sw.flash sw.hex 

 

error ":Interleave must be positive" 

0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
1,724 Views

Can you compile your bootloader into the regular project, thereby making one .elf that has everything in it? Maybe you could create two .elf's instead.  

Either way, once you have the .elf use it to do the conversion... 

nios2-elf-objcopy -O ihex file.elf output_file.hex
0 Kudos
Altera_Forum
Honored Contributor II
1,724 Views

Hi, 

 

I will be extremely interested by the end of this thread... 

Because I need to do the same thing and I don't know how to do this... 

 

Please, someone could help ? Thks in advance. 

 

See u.
0 Kudos
Altera_Forum
Honored Contributor II
1,724 Views

 

--- Quote Start ---  

 

i've tried elf2flash, which does let me attach the bootloader, but then when I try the following command I get an error: 

 

nios2-elf-objcopy --input-target srec --output-target ihex sw.flash sw.hex 

 

error ":Interleave must be positive" 

 

--- Quote End ---  

 

 

You've put the options here with two dashes before, but I bet you've only got one on your command line. That is, your command has the option -input-target rather than the option --input-target, so the nios2-elf-objcopy command thinks it's the interleave option. There's the same error in the official Altera knowledge base article. 

 

Mark.
0 Kudos
Altera_Forum
Honored Contributor II
1,724 Views

Thank you for the answer Mark!

0 Kudos
Reply