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

printf Problem with custom Board and NIOS II

Altera_Forum
Honored Contributor II
2,571 Views

Hello has anybody the same problem or an solution? 

 

I'm using a custom board with an stratix device and a NIOS II/f Debug Level 2. 

The NIOS II itself has a lot of user-defined interfaces, internal memory (ram and rom), dma and so on. 

 

The problem I have is, that when I download a program with an printf-Statement, that the NIOS II seams to hang up in a sub-routine at the printf-Statement. When I download a program which only switches on and off some leds it works. 

 

stdout, stdin, stderr are configured to a seperate uart (uart1) (a jtag_uart is not included in the design). 

 

Has anybody noticed the same problem or knows an solution? 

 

Chris
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
1,044 Views

hmmmmm that should have worked. 

 

The fact that it compiled means you have the right includes for your code, so I guess it's worth checking out how much memory resources you have in case you have some memory collision. 

 

I would also try adding a Jtag uart and re-directing to it if you have the ability to do so to determine if the problem is in the code or the uart itself. With the current uart implemented do you see any data at all coming back? 

 

Sorry that I can't be of more help (been using the jtag uart for NIOS II this whole time). 

 

Good-luck
0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

If you're using Hyperterminal ... ugghh! ;-) Try: 

 

File->properties, Settings tab, ASCII setup button: 

check "Append line feeds to incoming line ends" box. 

 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

Whooops! Sorry, please disregard my last ... I put it on 

the wrong thread ... too much sugar or something 8-/ 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

Hello, 

 

adding a JTAG_UART didn't solve the problem. There are also no memory conflicts in the design. 

It is also enough memory available (2 MRAM Blocks for system memory). 

 

So I try to find the failure with an simulation. 

 

Any other Ideas? 

 

MfG 

Chris
0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

Have you adjusted any of the compiler settings in the IDE? (like small C library, optimization strength, etc....) 

 

Another quick test is to open the hardware reference design in the hardware tutorial section and bring the hello world program into the software compile and just take a look at the various settings to see if there are any noticeable difference between your design and the ref. design. 

 

I'm sure you wouldn't have done this but are you making sure that you're printf statements use terminated strings ("Hello World" or if you prepared the string character-wise that you have the \n character at the end (that's what tells printf to stop outputing characters)). 

 

Another question is when the algorithm freezes, do you see anything get communicated across via serial (jtag or RS232)? 

 

And lastly could you describe you're memory structure further (ie, onboard, offboard, ram, rom, flash, etc..... and portions reside in each)
0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

Maybe I experienced the same problem. I found out that my generated linker description file (generated.x - folder "debug/system_description" in the syslib project) was wrong (some bug?). The .exception section pointed to system_memory_s2 and therefore overlapped some code section. Whenever an interrupt occurs (printf) the processor hangs up. 

 

.exceptions : 

. = ALIGN(0x20); 

*(.irq) 

KEEP (*(.exceptions)); 

} > system_memory_s1 <<<<<<<<< was wrong 

 

Hope that you can solve your problem in the same way. 

 

ps: keep in mind that generated.x will be automatically overwritten on syslib rebuilds.
0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

Thanks for the info. If have a hunch that there is a memory collision that&#39;s going to be one of the places I check now.

0 Kudos
Altera_Forum
Honored Contributor II
1,044 Views

Hello, 

 

I&#39;ve solved my problem. 

 

There are two things which happend at the same time. 

 

The first thing is, that the SOPC-Builder writes wrong settings for the NIOS II IDE into the ptf-File. So the software is generated into wrong address spaces. 

 

The second thing is, that the NIOS II IDE didn&#39;t recognize changes of the ptf-File. So I had to delete the syslib-Library and then I had to generate a new one. (rebuild didn&#39;t recognize the changes). 

 

Thanks for helping to solve the problem. 

Chris
0 Kudos
Reply