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

stdin, stdout, stderr

Altera_Forum
Honored Contributor II
1,189 Views

I can see that I have UART drivers installed, and I'm sure the C library is there also. I don't really know that things like printf are going to be directed to my UARTs, but it's a worry. They have to be used to communicate with hardware subsystems, not a human user. Is there a control for this in nios2configtool? Or is there some runtime method for controlling this?

0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
443 Views

Under eCos HAL -> Nios2 architecture you can set diagnostic console device and debug device. I believe that the diag device is set to jtag_uart default and the debug is set to uart. Just remove the uart from the debug device and you will not get any messages out on the uart. Printf uses jtag_uart so that you can use nios2-terminal or run the program from Nios IDE and see your printf messages there. This is a pretty nice to have in case of debugging and interacting with your system.  

 

If you call your uart uart in SOPC, you can access it with this:  

 

//Make a handle and a couple of variables 

cyg_io_handle_t uart; 

int uartlen; 

unsigned char uartbuf[100]; 

 

 

//Look up the handle, if your uart is called uart, you'll find it on /dev/uart. If it's called uart1 you'll find it on /dev/uart1 

cyg_io_lookup("/dev/uart", &uart); 

 

 

//And then you can read from it: 

uartlen = 80; 

cyg_io_read(uart, (void*)&uartbuf[0], &uartlen); 

 

//And write to it: 

cyg_io_write(uart, (void*)&uartbuf[0], &uartlen); 

 

Look here:http://ecos.sourceware.org/docs-latest/ref...o-user-api.html (http://ecos.sourceware.org/docs-latest/ref/io-user-api.html) for more information. 

 

Ole
0 Kudos
Reply