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++
12599 Discussions

"Hello World!" keeps looping. Anyone know why?

Altera_Forum
Honored Contributor II
1,122 Views

Hi, 

 

I have a system created in Qsys with a Nios , on-chip RAM, DDR3 controller, JTAG UART etc. 

 

I have specified the Reset vector and exception vector memory for the NIOS to be in the on-chip RAM only.  

 

The DDR3 controller Avalon mm base address is 0x0000_0000 and the end address is 0x3FFF_FFF, and I want to only use this memory for data so I would expect to be able to use it all. 

 

The strange this is , when I run my program below which tries to write and read to the DDR3 RAM, "Hello World!" just keeps printing out on the terminal forever and the program doesn't do anything else. If however, I change the ddr_base address in the code to 0xFFF, it runs fine. So what is being used in in the DDR3 memory from 0x0 ? Why should this happen if my code (.text etc) is being loaded only into the on-chip RAM. I appreciate if anyone knows the reason as to why or point out where i'm going wrong? Thanks 

 

# include <stdio.h> int main() { printf("Hello World!\n"); long* ddr_base = 0x0; int i; for (i = 0; i <50; i++) { *ddr_base++ = i; } ddr_base = 0x0; // pointing back to base of DDR3 for (i = 0; i <50; i++) { printf("word %u = %lu\n", i, *ddr_base); ddr_base++; } printf("done\n"); return 0; }
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
404 Views

mulligan22, 

you might want to include your system.h library ( in your main) which shows the proper addresses to your system. Make sure that your indeed writing to the correct address. The code to me looks like it shouldn't loop over..  

 

-Trukng
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

mulligan22, 

you might want to include your system.h library ( in your main) which shows the proper addresses to your system. Make sure that your indeed writing to the correct address. The code to me looks like it shouldn't loop over..  

 

-Trukng 

--- Quote End ---  

 

 

 

Yes normally I would include the system.h , but in this case I am just creating a pointer and pointing it directly to the memory address 0x0 which is the base address of the DDR3 specified in Qsys. "Hello World!" just keeps looping forever on the terminal and doesn't go any further in the program.. strange. If like I said, change the ddr_base to 0xFFF and start writing from there , the program works ok. It seems from 0x0 to 0xFFF in DDR3 is being used for something, but why would it cause this looping? 

 

Could it be that part of my program is being loaded to the DDR3 aswell as the on-chip RAM? I wouldn't expect this tho. The on-chip RAM is only where I want the program stored and it is at base address 0x4000_0000. The Nios only has the instruction master connected to the on-chip RAM. Any ideas?
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Mulligan22, 

I think to start troubleshooting, you might want to remove the DDR3 and make sure nios is working properly. I usually would check the reset vector and the memory vector and make sure they are indeed pointing to the on chip memory. I usually have the data master and instruction master connected to the on chip memory that i want the nios to use. If nios starts properly and you dont see the looping, you can rule out that its a nios problem. After that you can add the DDR3 ip core and see if you get the same issue. Ive seen something similar before with this but i dont recall the solution, i think their was a setting in the BSP editor that wasnt pointing to the correct memory. Let me know how that goes. 

 

-Trukng
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Hi, I seems that the system is keep resetting by it self, can you remove most of the other component and make this simple as possible first, so to ensure the nios is running smoothly.

0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Agree... looks like auto reset here!

0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

Agree... looks like auto reset here! 

--- Quote End ---  

 

 

Hi, 

 

I am facing the same issue.. Can you please let me know what did you do to solve this problem??
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

I don't know if this could be the reason, but if your code seems like the above, I would expect an infinite loop somewhere ( e.g "while(1)" ) within the main() function.

0 Kudos
Reply