Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

NIOS II gen 2 not starting when code compiled with O0 optimization

Altera_Forum
Honored Contributor II
1,331 Views

Hi, 

 

My code simply does not run if in the BSP settings I leave the default O0 compiler optimization. With O1 and Os it works I have tried. 

 

The code starts like this: 

 

*leds = 0xFF; printf("\n hello world1"); fp = fopen("/dev/uart", "rb+"); printf("\n after fopen"); fprintf(fp, "hello world2"); printf("\n after fprintf"); 

 

When I debug the the debug view in eclipse shows that the program is running immediately i.e. it is not waiting at the first line of the code as usual. This also is resolved by using O1 or Os optimization. 

 

What is wrong?!? 

 

I use Quartus Prime lite 15.1. 

 

Mitko
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
318 Views

Have you checked whether your memory is sufficient for your code? Can you try to increase your onchip-memory? I assume you are running from onchip-memory.

0 Kudos
Altera_Forum
Honored Contributor II
318 Views

Yes there is more than enough memory. I resolved this by starting a new project from scratch and copy-pasting the vhdl and the c code. 

 

It is a configuration problem that messes up the project either when you copy it from somewhere (because of absolute paths) or when you upgrade the project from a previous version of Quartus. I am not sure which one - i don't plan to spend more time analyzing this. 

 

What I can confirm is: 

1. Problem dissapears when: starting a new project from scratch - new Quartus project, rebuilding the system in qsys, new project in SBT. VHDL code was copy pasted and so were the c code files. 

2. Problem dissapears even if I use the nios system as it was in the project that had the problem (hence the problem is not in Qsys system) 

3. Problem remains if I recreate the SBT from scratch in the Quartus project with the problem. (of course copy the c-code files) 

 

I really don't like this kind of behaviour of the software - unfortunately altera is not the only having such problems, in fact I would expect any complicated toolchain to have this kind of issues.
0 Kudos
Reply