UART in olinuxino

Started by anra, September 28, 2013, 05:12:17 PM

Previous topic - Next topic

anra

 has anyone been succesful with a usart communication and A13-wifi-olinuxino?
Using the official debian image, how to start using a serial communication? what are the steps?
Is the uext ready to be used?
I am thinking to check a serial communication connecting the 152 pin to the 153 processor pin (uart1tx et uart1rx). Then to send:
echo "hell0" > /dev/ttySx
and then
cat /dev/ttySx

But what is x for the uext? is ttyS0? uart1 is in ttyS0?

Note:
A) using dmesg | grep tty

I get ..... console=ttyS0, 115200 root=/dev/mmcblkop2.... but I don't know what does it mean?

B) using ls /dev/

I get ..... ttyS0, ttyS1, ttyS2, ttyS3.....

thanks for your answers

granite_crusher

hi anra,

I was succesful :)
I guess you are using kernel 3.4 or 3.0 (I do not track official images any more, as compiling custom kernel and custom debian gives more under control). I am not very familiar with uSart but I used uart1 and uart3 even. (there is uart0 but it's pins is conflicting with SD card)

I will explain what did you dmesged:

console=ttyS0,115200 it shows that ttyS0 is for sending dmesg in first uart(lowest number)

ttyS0 ttyS1 ttyS2 ttyS3 is statical defined serial ports which on this board can be used just 3 first in case you don't use SD card. You define uart (and pins (for example uart1 can be on uext or on gpio-2) in fex). ttyS* is assigned from lowest number to lowest uarts

example:
if you defined in fex 3uarts: uart0, uart1 and uart3 (there is no uart2 in A13) then you will get uart0 -> ttyS0; uart1-> ttyS1; uart3 -> ttyS2;

you could write more what you want to do, I could try to give more specific answer.

granite

anra

Hi, thanks
I don't understand all you have said. I have a fex file in my usd card:script_gpio_lcd_800x480 and inside I have found:

[uart_para]
uart_debug_port = 1
uart_debug_tx = port:PG03<4><1><default><default>
uart_debug_rx = port:PG04<4><1><default><default>

[uart_para0]
uart_used = 0
uart_port = 0
uart_type = 2
uart_tx = port:PB19<2><1><default><default>
uart_rx = port:PB20<2><1><default><default>

[uart_para1]
uart_used = 1
uart_port = 1
uart_type = 2
uart_tx = port:PG03<4><1><default><default>
uart_rx = port:PG04<4><1><default><default>


So I think you said I have to configure the uart1 (in the uext ) or a uart3 (I dont see where is on the board) but how (the uext pins are 152 y 151)?
I understand that the uart0 is used. But I don't see how is configurated in the fex?

anra

I have found this link: https://www.olimex.com/forum/index.php?topic=742.msg5755#msg5755
mike1968 has been sucessful using uart1 in uext...

He has done:

Enable /dev/tty[1-6] and disable /dev/ttyS0 in /etc/inittab
Code: [Select]
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

#T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux

I don't understand why it worked? I will try...

granite_crusher

anra,

according to your fex you have one uart enabled: uart1 and it is assigned to ttyS0:

it depends what do you want to do:
if you want to communicate with pc throught uart (log in your a13-olinuxino) then your machine is already setted up for that. Notice that

[uart_para]
uart_debug_port = 1
uart_debug_tx = port:PG03<4><1><default><default>
uart_debug_rx = port:PG04<4><1><default><default>

is for debugging (or communicating with u-boot from pc)

uart0 is disabled because of this:
[uart_para0]
uart_used = 0

If you want to communicate with some device (for example GPS) you have to be sure that no bootargs as "console=ttyS0,115200" exists, and comment that line as mike shows.
that comment frees ttyS0 from being command promt. (not comment out that line would be same as you get to login prompt, but instead of your login and password you would overflow console with as example GPS NMEA messages)

port:PG03<4><1><default><default>

PG03 is real name for A13 pin while 152 and 153 is olimex numbering - you should check schematics for these numbers, but as I remember uart1 is set in uext pins as default.

there is instruction in forum how to set up uart3, it gives advantage that you can have debug environment and use uart devices, and it do not conflict. Otherwise using just one uart you will have to choose between debuging environment or device. this runs into trouble of booting with uart device plugged in.

granite

anra

#5
Hi granite, thanks
I am not interested in debugging.
So the only think I have to do is to comment the line?
#T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux

but have I to uncomment the lines?

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

My uart device would be plugged on booting. You said there are some problems if only I use one uart. But those problems are permanent? My uart device is no sending messages to olinuxino like a GPS...
Maybe I would need to configure a uart3. Any link you know explaining it? I have put "uart3" in the search section and no answers...

granite_crusher

by comenting
#T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux

you are disabling just tty on serial
means no more logging in throught uart1/ttyS0;
however it do not puts off debugging.
Quote from: anra on September 29, 2013, 01:37:11 PM
but have I to uncomment the lines?
but I guess you don't know what is tty.... these you shouldn't comment.
(did you know what you can switch to 6 tty's with alt+ctrl+F*(F1 to F6 for different ttys) and switch back to X with ctrl+F7 (default on most debian distros, but as I can remeber it is different on olinuxino image))

You still will need to get rid of
these:

[uart_para]
uart_debug_port = 1
uart_debug_tx = port:PG03<4><1><default><default>
uart_debug_rx = port:PG04<4><1><default><default>

in fex

and check environment in u-boot(actually you should do that first!!! before above, You will have to connect by uart to pc and interupt boot) to get rid of any default console=ttyS0,115200 in bootargs, or you have to recompile u-boot without that thing,

else your uart device will get weird messages from u-boot, and kernel dmesg....

so probably easier way is to set up uart3 (if you do not want to play with compiling u-boot or you are unable to connect with pc through uart.)

https://www.olimex.com/forum/index.php?topic=1030.msg6385#msg6385

just be warned: you will be unable to use spi1, and one of uart3 lines is connected to green led, so it will be on and flashing when communication going (maybe it's even cooler :) )

anra

thanks granite
After comenting #T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux, my uart communication using uext is working...
I have used:

echo "hello" > /dev/ttyS0 and
cat /dev/ttyS0

If someone is doing the same than me, I advice to use this command before: stty -F /dev/ttyS0 -echo -onlcr. Using -echo: prevents an infinite loop of "hello",  and -onlcr prevents the serial device from converting LF to CRLF on output
I will try also uart3...