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

stdout device issue

Altera_Forum
Honored Contributor II
1,626 Views

Hi, 

 

I've scoured the forums but have not found a thread which solved a similar problem I'm having (although threads discussing similar symptoms exist). I sincerely hope someone can point me in the right direction here. The basic problem I'm dealing with is (detail to follow): 

 

*I cannot write to any UART in my system with printf() or alt_printf() unless I have the following set: 

1) use small C library 

2) use reduced device drivers 

 

When both options are set, I can transmit characters successfully via any UART set as stdout. When only 2) is set, the uart does not work at all and when only 1) is set and a printf() executes, not all characters are displayed while some are swopped and some are repeated. 

 

Some background: I am in the verification stage of a custom board with a EP3C25 device. Currently I'm running a basic SOPC builder system (nios II cpu, jtag uart, standart uart, sram controller, pio) and I'm using the Hello World example app to test. I've verified that stdout, stdin and stderr are set in the bsp settings and in all cases the application and bsp build without errors or warnings. 

 

In the case where nothing is printed on stdout, I know the code runs as my LEDs keep toggling and I've run a debugger on the code -though I couldn't make out much of the internals of the printf() routine while debugging. 

 

Other code I'd like to use does not compile when the options listed above are set, so I'd like to sort this issue out, any hints? 

 

Regards, 

DB
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
646 Views

I forgot to mention, I'm using 9.1sp1 web edition.

0 Kudos
Altera_Forum
Honored Contributor II
646 Views

small C library not support printf () 

 

u can use only putc and getc - only character mode..
0 Kudos
Altera_Forum
Honored Contributor II
646 Views

 

--- Quote Start ---  

small C library not support printf () 

--- Quote End ---  

The small C library does support printf. It just does not support floating point formatting and buffered I/O. 

 

If enabling reduced device drivers helps, I would guess the problem may have something to do with interrupts as the UART driver will use polling instead of interrupts when this option is used.
0 Kudos
Altera_Forum
Honored Contributor II
646 Views

Ok, just to clarify: 

Are you unable to use either the JTAG UART or the standard UART?  

 

I've got a custom board I'm "bringing up" too and so far the JTAG UART is working fine for me without the small C library or the reduced device drivers. I have not gotten around to trying to route data out my "real UART" yet but will soon hopefully. 

David
0 Kudos
Altera_Forum
Honored Contributor II
646 Views

Thanks for the input, all. 

 

Neither JTAG nor standart UART worked, unless I enabled reduced device drivers and small C library, i.e. polling. This was with the NIOS /e core. 

 

I have since switched to the /f core, which solved the problem. One day when I have time (or when it comes back to bite) I might hunt down the issue, but for now I'll live with the core change. 

 

This may be a separate issue altogether, but I also experienced strange behaviour when passing character pointers between my own functions with the /e core. This might have had something to do with incorrect variable alignment in memory. Nevertheless this was also fixed with the /f core.  

 

-DB
0 Kudos
Altera_Forum
Honored Contributor II
646 Views

Interesting. When I get around to testing my UART I will see if I can duplicate your issue. 

 

David
0 Kudos
Reply