Home‎ > ‎Sergey's Blog‎ > ‎

Intel Galileo - Configuring the Serial Port in Linux

posted Jan 23, 2014, 3:46 PM by Sergey Kiselev   [ updated Jan 23, 2014, 3:47 PM ]

Introduction

Intel Galileo board features three serial ports:
  1. /dev/ttyGS0: This is the port provided by client USB connector. It is normally used by Arduino IDE to upload sketches to the Galileo.
  2. /dev/ttyS1: This is the serial port that is connected to the 3.5 mm connector, and it is normally used for the Linux console.
  3. /dev/ttyS0: Galileo can be configured to connect this serial port to Arduino pins 0 and 1. In this post I am going to talk about configuring this port.

Note: I will use UART (Universal Asynchronous Receiver/Transmitter) as a name for for the hardware inside the Quark SoC that provides serial port functionality.

GPIO Configuration

There are several GPIOs that control multiplexing of pins 0, 1, and enable a level shifter that need to be set in order to enable serial port on Arduino pins 0 and 1:
  • gpio4: This GPIO controls level shifter for UART signals and some other signals connected to Quark SoC, such as SPI and fast I/O. Writing '1' to this GPIO enables level shifter.
  • gpio40: This GPIO controls multiplexer for pin 0. Writing '0' to this GPIO connects pin 0 to UART's RxD (receive data) signal.
  • gpio41: This GPIO controls multiplexer for pin 1. Writing '0' to this GPIO connects pin 1 to UART's TxD (transmit data) signal.
The the following commands can be used to set these GPIOs so that pins 0, and 1 are connected to UART:
root@clanton:~# echo -n "4" > /sys/class/gpio/export
root@clanton:~# echo -n "40" > /sys/class/gpio/export
root@clanton:~# echo -n "41" > /sys/class/gpio/export
root@clanton:~# echo -n "out" > /sys/class/gpio/gpio4/direction
root@clanton:~# echo -n "out" > /sys/class/gpio/gpio40/direction
root@clanton:~# echo -n "out" > /sys/class/gpio/gpio41/direction
root@clanton:~# echo -n "strong" > /sys/class/gpio/gpio40/drive
root@clanton:~# echo -n "strong" > /sys/class/gpio/gpio41/drive
root@clanton:~# echo -n "1" > /sys/class/gpio/gpio4/value
root@clanton:~# echo -n "0" > /sys/class/gpio/gpio40/value
root@clanton:~# echo -n "0" > /sys/class/gpio/gpio41/value
The following commands will unexport GPIOs from sysfs (this is optional):
root@clanton:~# echo -n "4" > /sys/class/gpio/unexport
root@clanton:~# echo -n "40" > /sys/class/gpio/unexport
root@clanton:~# echo -n "41" > /sys/class/gpio/unexport

Software

Once serial port is configured it can be accessed using /dev/ttyS0 device just as any other serial port. One possible use is to run getty on it for an additional serial console. This can be done by adding the following string to /etc/inittab:
S0:2345:respawn:/sbin/getty 115200 ttyS0

And then reloading init configuration using:

root@clanton:~# kill -1 1

RS-232 Level Shifter Hardware

Galileo uses a logic-level signals (either 5V or 3.3V level). For connecting Galileo to another device with an RS-232 serial port, signals need to be converted to RS-232 levels. There are several shields and converters available that implement this functionality, for example this RS232 shield sold by SparkFun. Alternatively it is possible to build a level shifter using ICs like MAX232 (Maxim Integrated, Texas Instruments), MAX3232 (Maxim Integrated, Texas Instruments), or similar. Or use a serial to USB converter such as FTDI DB9-USB-D5-M module.


Comments