Using a serial console for u-boot and Linux kernel debugging

Note that using a serial console for u-boot and Linux kernel debugging is applicable to just about any SBC, and is the only method really available without using expensive hardware to debug the u-boot bootloader.

Basically if you need to know what's happening during the SBC boot-up, or if your SBC is not displaying the kernel messages on a video screen for whatever reason, you need a serial console. What follows are generic instructions on how to setup and use a serial console on any SBC.

Hardware required

The only piece of hardware required is an inexpensive PL2303 USB-to-serial converter cable. These are available from a number of sellers for as little as $1.20 a piece, so a suggestion is to buy two or three, as the extra ones may come in handy later.

usbserialcable1.jpg

Note the wires are color coded, usually:

  • Black: GND
  • White: RX
  • Green: TX
  • Red: +5V@ Max. 500mA (WARNING: DO NOT CONNECT THE RED WIRE)

Connecting

Only the GND, RX and TX wires should be connected. DO NOT CONNECT THE +5V (RED WIRE).

Find the UART header on your SBC. Connect the GND wire first, then connect the RX on the cable to the TX on the SBC, and the TX on the cable to the RX on the SBC. Voilà!

Connect the USB end of the cable to any USB port on your workstation/laptop/PC.

Using the serial console

You'll need a console program that connects to the serial interface. For example, if you are using Linux on your workstation/laptop/PC, the simplest program to use is GNU screen.

# sudo screen /dev/ttyUSB0 115200

If you are using screen and want to dump the entire scrollback buffer to a file (for example, if you have rebooted your SBC and captured the u-boot and Linux kernel messages during boot), check here.

Examples of u-boot and Linux kernel boot messages

Following the instructions above, I connected an Amlogic S905 Android TV Box running Armbian Linux to my Thinkpad T420 laptop, and dumped the u-boot and Linux kernel messages during boot-up.

  1. This file is a dump of all the u-boot and Linux kernel messages from power-on to a Linux prompt.
  2. In this file I pressed the space bar after power-on to get to the interactive u-boot mode and typed a few commands.

References

  • 5 Linux / Unix Commands For Connecting To The Serial Console.
  • Developer Olin has written a complete documentation for running Ubuntu 14.04 headless arm64 Linux on the K1Plus box, you can download and read the Pdf file complete with pictures from here.
  • A technical description of UART / serial connections from the Android Developer's website can be found here.
  • Adafruit has a very detailed lesson on how to use a serial console cable to connect to a headless Raspberry Pi, but the instructions can be applied to basically any SBC with few changes.