Forum Discussion
NIOS II - FW doesn't work with compiler optimization turned on
- Why this behavior?
- Is it possible to use memcpy as a write function on Flash?
- Is it possible to turn off optimization for a block of code?
- 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.
Best regards.
naand
15 Replies
- wwanalim_intel
Contributor
Hi,
We are glad that pragma is working.
Currently, this is the only optimization bug we are aware of. In the meantime, can we know what flash are you using? (the function will change based on flash vendor)
It seems using volatile not helping in here maybe the function is too small not because variable is optimized. Can you try this ?
By the way, can you share your pragma example? We are interested to understand how it is used.
Thank you.
- naand
New Contributor
Hi,
I'm using the Micron Flash MT25QL256ABA8E12-1SIT.
I tried the solution proposed in the StackOverflow link: the __attribute__ ((noinline)) works, so this is another solution.
My problem is only with the optimization of the flash_read_flag_status_register function, so this is my example of the #pragma directive:
#pragma GCC push_options
#pragma GCC optimize("O0")alt_u32 flash_read_flag_status_register(T_flash_state *st){IOWR(st->csr_base, FLASH_CSR_FL_CMD_SET, 0x00001870);IOWR(st->csr_base, FLASH_CSR_FL_CMD_CTRL, 0x1);return IORD(st->csr_base, FLASH_CSR_FL_CMD_RD0);}#pragma GCC pop_optionsMy code works even with the highest level of GCC optimization (-O3) if I use the #pragma solution.
Thanks.
Best Regards,
naand
- wwanalim_intel
Contributor
Hi,
We are glad to hear that both #pragma and __attribute__ ((noinline)) works for your issue.
As for now problem had been solved, we will continue to transition this thread to community support.
Thank you for the example given, will be helpful for others in future.
I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.