This page looks best with JavaScript enabled

RaspberryPi UART Terminal

 ·  🎃 kr0m

RaspberryPi has pins on the top side of the board, some serve as interfaces for communication via I2C, SPI, others as clock signal, others as PWM, others as general-purpose I/O pins and finally the ones we are going to focus on in this manual, the UART pins.

The idea is to configure the bootloader to show us the kernel boot through this serial port and as soon as the Linux OS boots, it offers us a TTY terminal, so we can see the RaspberryPi boot messages without having to change the HDMI cable of our monitor.

This can be especially useful when we are testing compiled kernels and trying out new features.

To do this on a current computer, we will have to buy a serial to USB adapter since most current computers no longer come with a serial port by default. I opted for this one .


The first thing will be to compile our kernel with support for the adapter:

Device Drivers ---> USB support ---> USB Serial Converter support
[*] USB Generic Serial Driver
[*] USB FTDI Single Port Serial Driver

When we connect the adapter, we can see something like this in the kernel output messages (dmesg):

Product: FT232R USB UART
Manufacturer: FTDI
FTDI USB Serial Device converter detected
Detected FT232RL
FTDI USB Serial Device converter now attached to ttyUSB0

Okay, the part on our PC is already finished, now we continue with the configuration of the RaspberryPi. The first thing will be to compile the kernel with support for the UART port:

Device Drivers ---> Character devices ---> Serial drivers
[*] ARM AMBA PL011 serial port support
[*] Support for console on AMBA serial port

Once the kernel is booted, we can see that there is a new device:

ls -la /dev/ttyAMA0

crw------- 1 root tty 204, 64 abr 24 19:28 /dev/ttyAMA0

This is the device we will use to communicate with our RaspberryPi.

We configure the RaspberryPi bootloader to display the boot through the tty port and not through the graphical output:

vi /boot/cmdline.txt

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline rootwait

Now we configure Raspbian to boot a login console on that port:

vi /etc/inittab

T0:23:respawn:/sbin/agetty -L ttyAMA0 115200 vt100

We connect the cables as follows:

* Gris: GND
* Azul: TX(FTDI) RX(Rasp)
* Morado: RX(FTDI) TX(Rasp)

Now we install screen to be able to connect and connect through the FTDI port:

emerge -av app-misc/screen
screen /dev/ttyUSB0 115200

The result will be a login tty, if we restart we can see the boot from this port:

This is Calculon.unknown_domain (Linux armv6l 3.10.25-kr0m-nomodules+) 20:41:42  
  
Calculon login:

Well, that’s all. I hope you have learned something by reading this article and that you have enjoyed it as much as I have writing it ;)

If you liked the article, you can treat me to a RedBull here