News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

How to flash Nios code to NVM? Sof2flash tool fails in Quartus 18.1

Started by Alexander K., December 27, 2019, 10:48:48 PM

Previous topic - Next topic

Alexander K.

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.

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>





CliftonWarner12

Quote from: Alexander K. on December 27, 2019, 10:48:48 PM
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.
It sounds like you are trying to flash an ELF file generated by the Nios gcc to the EPC flash, but are encountering issues when using Nios Programmer. You mentioned that you have successfully flashed a SOF file to the EPC flash by creating a JIC file, which is great.

One potential solution for flashing the ELF file to the EPC flash could be to use the "Convert Programming Files" tool in Quartus to convert the ELF file to a HEX file. You can then add the HEX file to your JIC file using the Quartus "Convert Programming Files" tool.

When adding the HEX file, make sure to specify the correct starting address for the file. This address should match the starting address of the code in your Nios application. If the address is incorrect, the Nios application may not start.

Alternatively, you can try using a different flash programming tool to flash the ELF file to the EPC flash. There are many third-party flash programming tools available that may work with your Cyclone 10 device. You can also try contacting Intel/Altera support for assistance with this issue.

Thomas D

Hi CliftonWarner12,
Quote from: CliftonWarner12 on April 13, 2023, 04:37:48 AM
One potential solution for flashing the ELF file to the EPC flash could be to use the "Convert Programming Files" tool in Quartus to convert the ELF file to a HEX file.
I did not find a way to convert the ELF file to a HEX file in the "Convert Programming Files" tool you mentioned. Are you sure that this is possible? If yes, how?

br
Thomas

Thomas D


rewvas

QuoteSo 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.


It sounds like you're trying to flash both the SOF file (for the FPGA configuration) and the ELF file (for the Nios II processor application) into EPC flash but encountering issues with the Nios Programmer due to a bug in the sof2flash utility since Quartus version 17.1.

You are correct that you need to convert the ELF file to a HEX file for inclusion in the "Convert Programming Files" tool. You can use the elf2hex tool that comes with Nios II to generate a HEX file from the ELF file. The command looks like this:

elf2hex --input=application.elf --output=application.hex --base=0x800000 --end=0x810000
Make sure the base address matches where your Nios II processor expects the application to be loaded in memory. You can find this address in the Nios II BSP settings (in the linker script or memory map).