Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Bare Metal HPS UART Rx

Altera_Forum
Honored Contributor II
1,059 Views

Hi, 

I've read through the posts in this section and I can't find something that addresses this apparently simple issue. If this has already been discussed elsewhere I apologize for my poor search skills. I am running a bare metal application run off an SD card on the CycloneV SoCKit board. I am using a Qsys built system with many custom video modules and filters. The FPGA portion works correctly, there is communication to the hardware modules though the MM interfaces and the debug messages sent through the UART show fine in a terminal. However, I am unable to receive anything sent from the PC to the board through the UART.  

 

I would expect a character to be read at the very least if the port is polled continuously, but no data ever arrives on the UART. Is a driver required for the correct use of getc()? Here is a simple test showing the problem: 

 

# include <fcntl.h># include <stdio.h># include <string.h># include <inttypes.h> int main(void) { // Vars int length = 0; char c; int length; char packet_in_b64; // Welcome printf("== SOC Kit UART Test === \r\n"); // This shows correctly on the terminal // Loop while(1){ c = getchar(); if( c != 255 ){ packet_in_b64 = c; printf( "char: %2x, length:%d r\n", c, length ); // Never shown } } }  

 

The possibilities I have thought about are: 

  • Damaged FTDI module. Seems unlikely since board->PC communication works 

  • Missing driver? I would have thought that even without an interrupt handler, or advanced register configurations, the default settings would allow getchar to receive data. 

  • The value that is always received is eof (http://www.cplusplus.com/eof). Which indicates a failure of some sort. 

 

 

If someone has experienced a similar problem I would appreciate any comments/suggestions on the matter.  

Thanks, 

Alfredo
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
176 Views

 

--- Quote Start ---  

 

 

  • Missing driver? I would have thought that even without an interrupt handler, or advanced register configurations, the default settings would allow getchar to receive data. 

 

 

--- Quote End ---  

 

Hi, I got this to work correctly, though not with without the drivers. In case this helps someone else, it seems that the default stdin does not work out of the box with default settings. In my case, including "alt_16550_uart.h" from the altera embedded ip libraries and using the alt_16550_init and alt_16550_ read and write functions works correctly.
Reply