Forum Discussion

naand's avatar
naand
Icon for New Contributor rankNew Contributor
1 year ago

NIOS II - FW doesn't work with compiler optimization turned on

Dear support team,
I have a problem with the behavior of the firmware if the project is built in release mode with optimization enabled.
The problem occurs during the write-to-flash routine. I use Generic Serial Flash Interface Intel® FPGA IP and was inspired by the intel_generic_serial_flash_interface_top example to create the code to write a block of data to the Flash. In the example, the memcpy function transfers data into the Flash. I don't know if the critical point of the function is the memcpy, but if optimization is turned on, the firmware seems to perform no write operation to the Flash: the function returns no errors, so it makes me believe that everything was executed correctly, but after a check, there wasn't the expected data in memory. While with the same code built with optimization turned off, the firmware works properly.
The flash_write_function, which generates the problem, is attached.
My questions are:
  1. Why this behavior?
  2. Is it possible to use memcpy as a write function on Flash?
  3. Is it possible to turn off optimization for a block of code?
I'm using:
  • Quartus Prima Version 20.1.1
  • Nios II/f processor
  • Eclipse IDE (version: Mars.2 Release (4.5.2) - build id: 20160218-0600)
  • Toolchain used:

The NIOS data cache is disabled, whereas the instruction cache is enabled (see below). I use only the IORD and IOWR functions to perform registers and peripherals accesses.

Here are the Nios II Application Properties:
Thanks,

Best regards.

naand

15 Replies