To enable the Nios II processor to load software from EPCS / EPCQ after power cycle or reset in the Quartus II software version 13.1 and later follow the steps below:
1. Add the following 2 lines in your <project>.qsf file.
a. set_global_assignment -name STRATIXV_CONFIGURATION_SCHEME "ACTIVE SERIAL X1"
b. set_global_assignment -name ENABLE_INIT_DONE_OUTPUT ON
2. Delete the db, incremental_db and qsys generated folders in your project directory.
3. Make sure the Nios IIs Reset Vector is pointing at EPCS/EPCQ Controller.
4. Make sure the Nios IIs Exception Vector is pointing at onchip_memory or some other memory devices.
5. Generate in Qsys.
6. Compile in Quartus II.
7. Note: If the design is not targeting EPCQ device, skip this step
Generate the .jic file with Convert Programming File tool.
a. Select .jic file for Programming file type.
b. Select the correct EPCQ device for Configuration device.
c. Make sure Active Serial is selected for Configuring device mode.
d. Click on Flash Loader, then click on Add Device to select the device youre using then clicks Ok.
e. Click on SOF Data, and then click on Add File to select the .sof file generated by Quartus II compilation.
f. Click on the .sof file you have just added, click on Properties and enable the Compression from there.
g. Click on Generate to generate the .jic file.
h. Program the EPCQ with the .jic file generated with Quartus Programmer and power-cycle the board.
8. Generate the .flash files for the .sof and .elf files with:
a. sof2flash --input=hw.sof --output=hw.flash --XX verbose
Note: Replace XX with EPCS for EPCS device and replace XX with EPCQ for EPCQ device
b. elf2flash --input=sw.elf --output=sw.flash --epcs --after=hw.flash verbose
9. Use nios2-configure-sof or Quartus Programmer to configure the FPGA with the .sof file then program the EPCQ device with the Nios II Flash Programmer as follow:
a. nios2-flash-programmer --epcs --base=<base address of EPCQ device> hw.flash
Note: The EPCQ need to be programmed with the .flash file even if it had been programmed with Quartus Programmer earlier in .jic format
b. nios2-flash-programmer --epcs --base=<base address of EPCQ device> sw.flash