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

RS232 with uCLinux

Altera_Forum
Honored Contributor II
1,141 Views

Hi, 

 

I am trying to set up communication between a PC and a DE2-70 board running uCLinux via the serial port. When booting uCLinux it detects the UART component alright. I naively assumed that it would just work, i.e. that if I have Linux running on both machines, I can use the open(), read() and write() system calls in order to communicate. 

 

After that didn't work I checked that the baud rate, parity and stop bits were correctly configured but still no luck. Any ideas what the problem could be? 

 

I have the sneaking suspicion it may have something to do with the UART driver included in uCLinux - is it perhaps not meant for this type of communication? Is it out of date? 

 

It would be very helpful if someone could let me know if they got this thing to work - even if you don't know what the problem is, it'll help me narrow down the list of possible issues... 

 

Thanks in advance, 

 

Johannes Lehmann
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
404 Views

For me the FiFoed UART and the Altera UART Driver (NoMMU-version) seems to work fine.  

 

What do you mean by " this type of communication" ? Async communication is widely used. Maybe you first start a command shell on the UART to try it using a serial terminal. 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

By "this type of communication" I simply meant that support for the standard Linux system calls was implemented in the driver with the natural semantics. 

 

By start a command shell you mean connect to the Nios via serial rather than JTAG UART? 

 

Thanks for the help!
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Perhaps a better description of my question / misunderstanding is: 

 

Am I right in thinking that if within uCLinux run "cat /dev/urandom /dev/ttyS0", I should - given I have the correct baud rate etc. is set on the host (equal to what I set in SOPC builder) - receive a stream of random data?
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

By "this type of communication" I simply meant that support for the standard Linux system calls was implemented in the driver with the natural semantics. 

--- Quote End ---  

O have no idea what you mean by this. Embedded Linux _is_ standard Linux, as long you use features that are not configured to be missing to save resources. 

 

--- Quote Start ---  

By start a command shell you mean connect to the Nios via serial rather than JTAG UART? 

--- Quote End ---  

or additional to same by means of initab or by starting it from the shell. 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

Am I right in thinking that if within uCLinux run "cat /dev/urandom /dev/ttyS0", I should - given I have the correct baud rate etc. is set on the host (equal to what I set in SOPC builder) - receive a stream of random data? 

--- Quote End ---  

 

Yep. (if urandom is not configured not to be provided) 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

O have no idea what you mean by this. Embedded Linux _is_ standard Linux, as long you use features that are not configured to be missing to save resources. 

or additional to same by means of initab or by starting it from the shell. 

--- Quote End ---  

 

 

Sorry to have been so unclear about this... What I meant was: In order for uCLinux to even detect the serial controller, I need to enable Altera UART in the menuconfig. From that I concluded that the driver was written specifically for the UART component available in the SOPC builder (due to the name "Altera"). That made it seem like it was written by the embedded linux community specifically for the Nios 2. 

 

Since the "cat /dev/urandom /dev/ttyS0" command didn't make any data come out on the other side and since I know that the cat program uses the read() and write() system calls, I guessed that the issue may be due to the driver not having been written to support these system calls or some other setup work being necessary. Alternatively the driver could have simply been out of date.  

 

So seeing that no data arrives at the PC and assuming that cat works and the receiving end works, there seems to be some problem regarding the way in which the RS232 controller is set up. 

 

Furthermore assuming that the SOPC component works and that I wired everything up correctly (and assigned pins correctly) this only leaves (as far as I can think of) the possibility that the driver in uCLinux doesn't do what I think it does. Of course I may be wrong there and I am currently in the process of checking all my assumptions :p.
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

What I meant was: In order for uCLinux to even detect the serial controller, I need to enable Altera UART in the menuconfig. From that I concluded that the driver was written specifically for the UART component available in the SOPC builder (due to the name "Altera"). That made it seem like it was written by the embedded linux community specifically for the Nios 2. 

--- Quote End ---  

Correct. 

 

--- Quote Start ---  

Since the "cat /dev/urandom /dev/ttyS0" command didn't make any data come out on the other side and since I know that the cat program uses the read() and write() system calls, I guessed that the issue may be due to the driver not having been written to support these system calls or some other setup work being necessary. Alternatively the driver could have simply been out of date.  

--- Quote End ---  

If the UART is not working, I suppose an error message should come with "open" and be displayed by "cp" on the error channel (the terminal) 

 

--- Quote Start ---  

So seeing that no data arrives at the PC and assuming that cat works and the receiving end works, there seems to be some problem regarding the way in which the RS232 controller is set up. 

--- Quote End ---  

AFAIK, the default setup of the driver when initiated is 19200,8,1, no parity. But maybe I'm wrong. 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

 

--- Quote Start ---  

AFAIK, the default setup of the driver when initiated is 19200,8,1, no parity. But maybe I'm wrong. 

--- Quote End ---  

 

The default baudrate can be set in the Linux kernel menuconfig. 

 

There is no error when opening the UART - or for that matter when writing to it or reading from it. From what I can tell though nothing ever comes out of the RS-232 port. I mean even if I did get the baudrate and parity wrong, one would still expect *something* to come out, right? 

 

By now I checked that I have the correct pin assignments many times... 

 

Does anyone know whether the RS-232 port is wired as DTE (Data Terminal Equipment) or DCE (Data Circuit-terminating Equipment)?
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

AFAIK, with ioctl you can control if hardware handshake is used. Maybe you need to create a small C program to do open(), ioctl() an write() on TTYS0 to test this.  

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Hi, 

 

I am trying to set up communication between a PC and an X10 for smart home controller using DE2 board running uCLinux via the serial port. I am looking when booting uCLinux it detects the UART component alright and if I have Linux running on my laptop and the host computer, I can use the open(), read() and write() system calls in order to communicate, which will allow me to communicagte b/w Altera NiosII and X10 device. 

 

I checked that the baud rate as 4800bps, I am not able to create the right C-code so far to run the communication b/w the Laptop frist with the board through RS232 (UART) and then with the X10 device. Any ideas what the the right c code could be? 

 

It would be very helpful if someone could let me know if you have a tested code used beforer. Even if you don't know what the code is, it'll help me narrow down any suggestions from your side... 

 

Thanks in advance, 

 

Nidal...
0 Kudos
Reply