Tagged with raspbian

Serial Port Sees Kernel Sequence But No Login Prompt In Raspbian

I just finished fighting a battle debugging the serial console on the raspberry pi. I was able to see the kernel boot sequence, so I was confident there were no pin-out issues, but following the kernel sequence I wasn’t being presented with a login prompt:

TLDR;

If you have this problem, first check that the following line is present and uncommented in your /etc/inittab file:

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

If you’ve installed upstart on your Raspberry Pi, you must add the following file to /etc/init

/etc/init/ttyAMA0.conf

# ttyAMA0 - getty
#
# This service maintains a getty on ttyAMA0 from the point the system is
# started until it is shut down again.
 
start on runlevel [23] and not-container
 
stop on runlevel [!23]
 
respawn
exec /sbin/getty -L ttyAMA0 115200 vt100

THE DETAILS

I have a project that’s going to require me to configure the wifi on a Raspberry Pi in place. This made me nervous, as the only interface I would have available into the device was through WiFi, so a mistake in configuration would effectively brick the device.

Looking for a safer solution I stumbled upon the Adafruit USB to TTL cable. This cable allows you to access the serial terminal available through the pins on the Raspberry Pi header directly from the USB port of a computer without the need of other serial to usb converters. This is due to the embedded PL2303 chip in the cable that performs the conversion.

After following the instructions in this guide on Adafruit’s site, I was able to see the linux kernel boot sequence in a terminal on my mac:

...
[    9.614251] usbcore: registered new interface driver snd-usb-audio
[    9.716471] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5390, rev 0502 detected
[   10.572707] FAT-fs (mmcblk0p5): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[   11.397452] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 5370 detected
[   11.567387] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[   11.903032] usbcore: registered new interface driver rt2800usb
[   12.114566] init: failsafe main process (292) killed by TERM signal
[   13.929262] ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'
[   13.986951] ieee80211 phy0: rt2x00lib_request_firmware: Info - Firmware detected - version: 0.29
[   14.741621] init: udev-fallback-graphics main process (414) terminated with status 1

Unfortunately, after this I was supposed to see a login prompt, and no amount of waiting was seeing one appear. I logged into the Raspberry Pi, and did a quick ‘ps aux | grep getty’ to look for the getty process that is supposed to create the console on the serial port. The default getty processes were present, but I should have seen a process using the device ttyAMA0, and it wasn’t present:

pi@raspberrypi ~ $ ps aux | grep getty
root       664  0.0  0.1   3744   804 tty4     Ss+  02:03   0:00 /sbin/getty -8 38400 tty4
root       666  0.0  0.1   3744   804 tty5     Ss+  02:03   0:00 /sbin/getty -8 38400 tty5
root       671  0.0  0.1   3744   804 tty2     Ss+  02:03   0:00 /sbin/getty -8 38400 tty2
root       672  0.0  0.1   3744   804 tty3     Ss+  02:03   0:00 /sbin/getty -8 38400 tty3
root       674  0.0  0.1   3744   804 tty6     Ss+  02:03   0:00 /sbin/getty -8 38400 tty6
root       980  0.0  0.1   3744   804 tty1     Ss+  02:03   0:00 /sbin/getty -8 38400 tty1
pi        1912  0.0  0.1   3520   796 pts/0    S+   02:21   0:00 grep --color=auto getty

I started doing some digging, and all the relevant threads I could find kept on telling you to ensure that the relevant line used to launch getty on the serial port was uncommented like this:

/etc/inittab

# /sbin/getty invocations for the runlevels.
...
 
#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

No matter how many times I checked, that last line was uncommented in my file, but my login prompt continued to fail to appear.

After lots of beating my head against the wall, I finally realized that earlier in setting up the environment I had installed Upstart on my installation of Raspbian. Upstart replaces the inittab script, and instead uses .conf files located at /etc/init. Looking at the .conf files, there was no file to start the getty process I needed for the serial port.

I added the following to /etc/init/ttyAMA0.conf:

# ttyAMA0 - getty
#
# This service maintains a getty on ttyAMA0 from the point the system is
# started until it is shut down again.
 
start on runlevel [23] and not-container
 
stop on runlevel [!23]
 
respawn
exec /sbin/getty -L ttyAMA0 115200 vt100

With this new .conf file in place I rebooted my pi, and a login prompt like the following:

...
[   13.771014] ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'
[   13.844754] ieee80211 phy0: rt2x00lib_request_firmware: Info - Firmware detected - version: 0.29
[   14.282944] init: udev-fallback-graphics main process (405) terminated with status 1
��
Debian GNU/Linux 7 raspberrypi ttyAMA0
 
raspberrypi login:

Finally my serial login was working!

Tagged , , , , , , , , ,