Chromium OS [serial] Console Debugging HOWTO

Introduction

The kernel team has been working to remove cruft from the Chromium OS kernel configs. Since there are no Chromebooks with a serial port, serial port drivers were removed from the stock configuration, which is a minor inconvenience for those who still do a lot of debugging using the serial port.

A quick howto was e-mailed some time ago here for using mini-PCIe serial cards, but the information is somewhat limited in scope and is worth correcting and modernizing. There are several ways to accomplish what is described here, please feel free to chip in.

This HOWTO assumes you have built a bootable Chromium OS image and are not afraid to edit some config files. We'll assume the target platform is 32-bit "x86-generic".

Enable Kernel Serial Drivers

Use the pcserial USE flag when building your kernel:

chromium-os$ USE=pcserial cros_workon_make --board="${BOARD}" chromeos-kernel

For Exynos-based systems, add the samsung_serial USE flag:

chromium-os$ USE=samsung_serial cros_workon_make --board="${BOARD}" chromeos-kernel

Enable Console Logging

By default, the kernel command line is set up to enable no consoles and thus log no output. This leads to a cleaner/speedier boot, but is not helpful when you need to see failure messages. Thus you'll need change some kernel command-line parameters to get meaningful output.

When you create the image with build_image, simply use the --enable_serial flag to select the console for logging output. The value it takes is exactly the same as what the kernel expects for console= (see the next section for more details).

$ ./build_image --enable_serial ttyS0

The console= option

The console= option is described in detail in kernel-parameters.txt in the Linux kernel source tree.

Platform Specific Settings

X86

On most x86 platforms, ttyS0 will refer to the southbridge's UART accessed via ports specified in Super IO configuration space. However, for add-in PCIe cards you may need to specify a MMIO address to access the UART. For example, "console=uart8250,mmio,0x50401000,115200n8".

See Appendix A below for more details.

ARM Exynos

You probably want to use ttySAC3 for your console.

Enabling Serial Console Login

See the Controlling Enabled Consoles document for all the details.

Build Chromium OS image using your custom kernel config

Set the pcserial USE flag when calling build_packages:

USE=pcserial ./build_packages

Appendix

A: How to find alternate IO and MMIO addresses for your UART

If you already have UART support but simply do not know what options to pass to the kernel, you may examine a few sources to figure it out.

Method 1: Look at /proc/iomem
localhost ~ # cat /proc/iomem | grep serial
    50401000-50401007 : serial

note: for two port pci-serial cards you will see two entries like this:
    e0801000-e0801008 : serial
    e0801200-e0801207 : serial
and the each range will correspond to the two different serial ports

Method 2: Look at PCI device config
localhost chronos # lspci | grep -i serial
02:00.0 Serial controller: NetMos Technology PCIe 9901 Multi-I/O Controller

localhost chronos # lspci -v -s 02:00.0
02:00.0 Serial controller: NetMos Technology PCIe 9901 Multi-I/O Controller (prog-if 02 [16550])
        Subsystem: Device a000:1000
        Flags: bus master, fast devsel, latency 0, IRQ 16
        I/O ports at 2000 [size=8]
        Memory at c0401000 (32-bit, non-prefetchable) [size=4K]
        Memory at c0400000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: [80] Power Management version 3
        Capabilities: [88] MSI: Enable- Count=1/32 Maskable- 64bit+
        Capabilities: [c0] Express Legacy Endpoint, MSI 00
        Kernel driver in use: serial

Method 3: Look at dmesg for lines such as this:
[    0.676698] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.678173] serial 0000:04:00.3: PCI INT D -> GSI 18 (level, low) -> IRQ 18
[    0.678716] 1 ports detected on Oxford PCI Express device
[    0.678910] ttyS0: detected caps 00000700 should be 00000100
[    0.679365] 0000:04:00.3: ttyS0 at MMIO 0x50401000 (irq = 18) is a 16C950/954
[    0.679899] console [ttyS0] enabled, bootconsole disabled
Comments