How to program EPCS flash making NiosII boot from EPCS device correctly
1. Build NiosII system in Qsys and point reset vector to EPCS controller. Set EPCS controller base address to 0x0 is better.
2. Create NiosII software project based on the system building in Qsys. In BSP editor, point all code running in Ram.
3. You can use “NiosII flash programmer” that integrated in NiosII EDS to program EPCS flash. Open file-> new, then select “sopcinfo” file for flash information.
First add “sof” file, then add “elf” file, like below:
You can press start now, tool will program flash automatically.
If you need generate programming file used in QuartusII programmer, please follow below steps to do it.
1. Convert “elf” file to “hex” file for flash programming. Please open NiosII command shell, and enter into your working directory that “elf” file located. Type below two commands to generate “hex” file.
elf2flash --input=yourfilename.elf --output= yourfilename.flash --epcs –verbose
nios2-elf-objcopy -I srec -O ihex yourfilename.flash yourfilename.hex –v
2. Now open “Convert Programming File” from QuartusII “file” menu, then setup as below figure. Please note you must select “relative addressing” option when adding “hex” file.
3. Open “programmer”, add “jic” file that generated in last step, then program flash.
4. Re-power up your board, you will find NiosII running automatically.