Author Topic: How to flash Nios code to NVM? Sof2flash tool fails in Quartus 18.1  (Read 3165 times)

Alexander K.

  • Active Member
  • *
  • Posts: 2
So far I've managed to flash sof files to EPC flash by creating the jic file.
But now I also want the elf file (generated by Nios gcc) also to be flashed into EPC flash.
Using Nios Programmer failes due to bug in sof2flash since 17.1 (related to cyclone 10)
There must be also other way:
I assume I've to add the hex file (converted from elf) to the "Convert Programming Files" tool.
Unfortunately the address where this hex file is placed seems to be wrong. The Nios application is not starting.
I'm basically using the provided Quartus design but added small Nios application.

Starting and debugging Nios application directly via Jtag works, so application itself is correct.

Alexander K.

  • Active Member
  • *
  • Posts: 2
Re: How to flash Nios code to NVM? Sof2flash tool fails in Quartus 18.1
« Reply #1 on: December 28, 2019, 11:35:50 AM »
So now it works finally.
From Nios Project Context menu select Make Targets... -> Build... (Shift+F9)
Select target mem_init_generate
This will create a hex file called "epcq_controller.hex" in "min_init" folder with small boot loader and your nios app included
Open "Convert Programming File" tool.
If this hex file is not already there, add by click on "Add Hex Data".
Leave "Big Endian" and "Absolute Address".
Select recently generated "epcq_controller.hex".
Click generate, open generated jic file using programmer.

or open following XML cof file with the conversion tool and replace with your files:

<?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
<cof>
   <eprom_name>EPCQ16A</eprom_name>
   <flash_loader_device>10CL025Y</flash_loader_device>
   <output_filename>output_files/test_board.jic</output_filename>
   <n_pages>1</n_pages>
   <width>1</width>
   <mode>7</mode>
   <hex_block>
      <hex_filename>C:/Users/Alex/test_board/quartus/software/modulator2/mem_init/epcq_controller.hex</hex_filename>
      <hex_addressing>absolute</hex_addressing>
      <hex_little_endian>0</hex_little_endian>
   </hex_block>
   <sof_data>
      <start_address>00000000</start_address>
      <user_name>Page_0</user_name>
      <page_flags>1</page_flags>
      <bit0>
         <sof_filename>output_files/test_board.sof</sof_filename>
      </bit0>
   </sof_data>
   <version>10</version>
   <create_cvp_file>0</create_cvp_file>
   <create_hps_iocsr>0</create_hps_iocsr>
   <auto_create_rpd>0</auto_create_rpd>
   <rpd_little_endian>1</rpd_little_endian>
   <options>
      <map_file>1</map_file>
   </options>
   <advanced_options>
      <ignore_epcs_id_check>2</ignore_epcs_id_check>
      <ignore_condone_check>2</ignore_condone_check>
      <plc_adjustment>0</plc_adjustment>
      <post_chain_bitstream_pad_bytes>-1</post_chain_bitstream_pad_bytes>
      <post_device_bitstream_pad_bytes>-1</post_device_bitstream_pad_bytes>
      <bitslice_pre_padding>1</bitslice_pre_padding>
   </advanced_options>
</cof>