How to enable serial console on Android

To bring up an embedded system with JTAG and other flash programmer, one of the first things worth doing is to enable a serial port on the platform and let the embedded Linux kernel use it as the console. In this way, one can somehow view the kernel boot-up process before the display, network interfaces, USB ports are brought up before more conventional interfaces can be used (like LCD, keypad, telnet, adb, etc.)

Put in a simple way, the following things need to be done. Since many Android devices run on Qualcomm MSM chipsets, I will just use MSM as an example. The basic idea is that the Linux kernel already supports the MSM platform under the ARM architecture category; however, a few things still need to be done to get the kernel console driver to work.

Step 1: Setup the platform. This procedure depends on the hardware. The idea is to configure the a UART interface of the platform to connect to a serial port (e.g., RS232 DE9), and connect it to a PC's serial port (e.g., COM1).

Step 2: Configure the Linux kernel to enable the serial port driver.
Enable CONFIG_SERIAL_MSM and CONFIG_SERIAL_MSM_CONSOLE.

Step 3: Specify the serial tty device as the console
Add the following kernel command line (in the boot configuration file): "console=ttyMSM2,115200n8". The character device selected is ttyMSM2 or ttyMSM1 on some devices. They correspond to different UART interfaces on the MSM chipset. The value 115200 is the baudrate of the serial port. It uses 8 bits data, no flow control. One can set up the terminal on the PC accordingly.

After these modifications, recompile and flash the kernel, you will probably see Kernel "printk" messages on the serial port on the PC. One can then run "getty" on the tty device for serial logging in from the PC.

References

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License