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++
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.
12408 Discussions

Simultaneous open of two UART on a single NIOS II

Honored Contributor II



I searched before post but I didn't find anything so I hope nobody asked this before. 


I try to use several (three on my final application) UART on the same NIOS and connected each others (uart0 <=> uart1). I want to send a character with uart0 to uart1. 

To do this, I want to use open, read, and write function in non blocking mode (reduced_device_driver option disable). 

But when I try to open the second uart, i have an error (errno 24 => EMFILE /* Too many open files */). 

I tried to disable uart1 when I send the character with uart0 and enable it after and it's working but for my application it's not really applicable... 

SO my question is: 

Is it possible to open more than one uart device at the same time? 


Thank you in advance! :)
0 Kudos
1 Reply
Honored Contributor II

Go into the BSP editor, and under the "Advanced" section, increase the value of hal.max_file_descriptors. 


Also, it is not strictly necessary to use reduced drivers if you just want non-blocking access. If you're using the full HAL layer, you can also use fcntl() to set O_NONBLOCK on the device. (This does not appear to work on the standard streams - stdin, stdout, stderr - but it should work on a device you have opened with open().) Keep in mind that this will make the device non-blocking for both reads and writes; i.e. check the return value of write() -- don't just assume the character was sent.