MXC serial port timeout

05.02.2013 14:01

Playing with my Debian-running Kindle over the serial console (because I don't have networking running natively yet under Debian) exposed one interesting feature. The serial port would stop responding if it was left idle (no traffic in or out) for a few tens of seconds. By accident I found out that sliding the power button restores it back to normal operation, however the reason for this was a mystery until I looked into the Linux kernel source.

Kindle uses a NXP MX35-series CPU. The serial port /dev/ttymxc0 is provided by the mxc_uart driver, which is compiled into the kernel image shipped by Amazon. Inspecting the source (drivers/serial/mxc_uart.c in the Linux kernel tree) shows that the driver implements a power-saving feature that powers down the peripheral and disables its clock if there is no activity for 30 seconds.

This clock gating feature is enabled by default, but luckily you can disable it through the sysfs on a per-UART basis. I now have the following line in the /etc/rc.local file and the serial console remains available even if left idle for a while:

echo 0 > /sys/devices/platform/mxcintuart.0/uart_clk_state
Posted by Tomaž | Categories: Code


You can also create file /mnt/us/DO_NOT_KILL_UART which will prevent serial port power off (take a look into /etc/init.d/power)

Since I am using a stock Debian install that does not include Amazon's "/etc/init.d/power" from the original Kindle OS, the "DO_NOT_KILL_UART" trick won't work in my case.

Posted by Tomaž

Add a new comment

(No HTML tags allowed. Separate paragraphs with a blank line.)