Once upon a time, I had this code working, so I know the code is good.As I have been made the honorary NIOS II guru at work, I have been tasked with learning all I can so I can teach my boss. I had some code that I managed to make work in both Modelsim and on hardware. It can R/W to mem and light up some LEDs...simple. I decided to add a flash chip so that I can play around with having an FPGA image and software programmed into the chip. After abject failure (every method I've tried to get the flash to program the chip properly and run the software crashed and burned...another issue for another thread) I decided to go back to the previous design. I removed the generic tristate controller and bridge from Qsys, rebuilt the system, changed the C code back to the previous address mapping, rebuilt the code, regenerated the BSP, regenerated the .hex files (a whole other issue), recompiled the project in Quartus, and programmed the .sof file into the FPGA. Now all of my LEDs just stay lit, and nothing happens. Simulating things in modelsim show me that the processor just never does anything useful. It just seems to go through the reset vector, to do some things that look like stack or heap initialization, and then do some other things that look like housekeeping. Then it repeats that process endlessly. It never seems to find my code, and I just don't understand why. Using the debugger doesn't seem to have any value, because it never gets to my code, so it never seems to find my breakpoints. Just arbitrarily pausing the debugger at any point shows that the processor is at 0x0000000 (which happens to be where my reset vector is, but I've moved the reset vector by changing the offset of the instruction memory and the debugger still stops at 0x000000, so I know its not stopping at the reset vector). It just doesn't seem to be doing anything. The system right now is a NIOS II/e (not having the cache makes it easier to follow instructions in modelsim), 3 on-chip memories (1 instruction, 1 data, 1 r/w test mem) and a pio for the LEDs. That's it. Any suggestions? This NIOS stuff is making me feel like I live on this forum. Thanks in advance for any help!!!! O! And for the record I'm doing this with a Cyclone III starter board. I have all of the pins connected according to the datasheet and all of the unused pins are set to inputs tristated.
If all this started happening after switching to Qsys make sure that you are not using old stale SOPC Buider files. So if the old SOPC Builder system .qip file is still in your Quartus II project files list remove it and add the new one for your Qsys system. If you are still pointing at an old .sopcinfo file make sure you use the new one in your BSP.
Since the code was the same I assumed that the problem was in the BSP. After hours of playing around with the BSP settings I discovered that the problem was the "enable_c_plus_plus" option. If I disable this option the code runs as it should. This option seems to be enabled by default as well.Any thoughts as to why this causes problems? I never would have thought to start looking here.
I just created a BSP in 11.0 and C++ was disabled. I don't think I have ever created a BSP with C++ enabled so I'm not sure what could have happened (haven't used C++ in a long time). I suspect having C++ enabled cause something to go wrong with the initialization, I would look through the Nios II errata to see if there are any C++ bugs reported there.
Nothing in the errata sheet. I think your right about the initialization error. Based on the simulation in modelsim, it looks like the NIOS is constantly trying to initialize itself, failing, and starting over. Maybe it has something to do with the libraries being included? I don't know. At least its working.