Enable UART on Cubieboard with Lubuntu

I wanted to connect my cubieboard with lubuntu to my arduino via serial communication. For that I had to enable a UART and connect pins to my arduino (only RX/TX is needed). I have arduino mini 3.3V on which I have attached some sensors (outside temperature).
By this command you can check if the port is enabled:

stty -F /dev/ttyS0 -a

In fresh installation of lubuntu the ttyS0 is configured and used by kernel and ttyS1 is not enabled. You will get this message for ttyS1:

stty: /dev/ttyS1: Input/output error

I followed the how-to by cubieboard.

sudo mount /dev/nanda /mnt
cd /mnt
sudo bin2fex script.bin script.fex
sudo vi script.fex

I changed only 1 uart – I selected the one that is using only 2 pins uart_para4:

[uart_para4]
uart_used = 1
uart_port = 4
uart_type = 2
uart_tx = port:PG10<4><1><default><default>
uart_rx = port:PG11<4><1><default><default>

I use mc for as easy text editor

save and convert fex file back to bin file:

sudo fex2bin script.fex script.bin

restart to have new UART visible in lubuntu:

sudo reboot

You can find the pin definition on cubie site.

For my case I have configured in script.fex file port PG10 as tx and PG11 as rx which are pins 17 and 18 on the connector on USB side.

17 PG10 (CSI1-D6/UART4-TX) 18 PG11 (CSI1-D7/UART4-RX)

 

I have attached cables (I have 2.54mm ones, but they somehow fit). I used 3.3V from the front side of cubieboard but I could used also PIN 44 next to SATA port.

Pin 17/18 for RX/TX and PIN19 for GND

Arduino mini pro 3.3V

The device number of ttySx depends on how many uarts you have opened. In my case I have opened uart0 and uart4, so the uart4 is mapped to the device ttyS1.

To test my changes I used utility called “cu” that I have installed and started on ttyS1 with 9600 baud rate.

 

sudo apt-get install cu
cu -s 9600 -l /dev/ttyS1

Arduino was programmed to send me outside temperature (in C) and humidity so I started to receive data.

Now I will setup a crontab and a web server to have history of temperature available on the internet. I will do another post, because it took me a while to create such graph on my web page hosted on Cubieboard2 with Apache.

Outside temperature for last 4 days using Google charts API


Related Posts

Cubieboard and 2.00mm vs 2.54mm pins

Cubieboard has thickness 2.00mm 2×20-pin-header that is not so suitable for home hobbiest. Arduino and other small boards uses 2.54mm pin (0.100inch) To connect it I have bought 2.00mm to 2.54mm 40pcs Wire Cable 2P[…]

Continue reading ...

Cubieboard2 – Lubundu – Extending NAND from 2GB to 4GB

When I install new Lubuntu NAND image to my new Cubieboard2 I had only 2GB of space out of 4GB available. I followed this forum to expand the filesystem to 4GB. sudo nand-part In my[…]

Continue reading ...

Lubuntu ssh: Read from socket failed – solved

SSH to my fresh lubuntu on cubieboard2 was not working. I tried it also from the lubuntu itself with the error: $ ssh localhostRead from socket failed: Connection reset by peer I went through many[…]

Continue reading ...