Rodeklu
Posts: 2
Joined: Sun Nov 22, 2015 2:39 pm

Add serial terminal in Jessie (systemd) after boot

Tue Nov 24, 2015 8:54 am

Hi,

I want to start a serial terminal session after boot.
I get the "Uncompressing Linux... done, booting the kernel." message from the bootloader so the connection is OK.
In raspi-config I disabled the serial option.
On the console (tty1) I see that there is no getty started for ttyAMA0.
The documentation (http://0pointer.de/blog/projects/serial-console.html) gives:
systemctl start serial-getty@ttyS2.service
I changed it to:
sudo systemctl start serial-getty@ttyAMA0.service
I checked with:
sudo systemctl status serial-getty@ttyAMA0.service
serial-getty@ttyAMA0.service - Serial Getty on ttyAMA0
Loaded: loaded (/lib/systemd/system/serial-getty@.service; disabled)
Active: active (running) since Tue 2015-11-24 09:17:29 CET; 9s ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 616 (agetty)
CGroup: /system.slice/system-serial\x2dgetty.slice/serial-getty@ttyAMA0.service
└─616 /sbin/agetty --keep-baud 115200 ttyAMA0 vt102

Nov 24 09:17:29 radio_keuken systemd[1]: Started Serial Getty on ttyAMA0.

Running ps a gives:
ps a
PID TTY STAT TIME COMMAND
522 tty1 Ss 0:00 /bin/login -f
546 tty1 S+ 0:01 -bash
575 pts/0 Ss 0:01 -bash
616 ? Ss+ 0:00 /sbin/agetty --keep-baud 115200 ttyAMA0 vt102
644 pts/0 R+ 0:00 ps a

I'm using the console for the boot messages. (PID 522 and 546)
I'm also using a SSH session to copy and paste the results in this post. (PID 575 and 644)
There is no prompt at the serial terminal and a question mark in the TTY column of the process.
What's wrong?

If I enabled the serial option in raspi-config the serial terminal is working.

Update 1:
If a run a minicom session:
minicom -b 115200 -o -D /dev/ttyAMA0
Stop the session with ctrl-A q (without reset)
Now I start the service and I get the prompt in my serial terminal.
Question still is what's wrong?

Update 2:
I changed the ExecStart to:
ExecStart=-/sbin/agetty -8 -a pi 115200 %I $TERM
Now it's working in both the boot and manual start of the service.
Still no idea what's wrong but now I've got a workaround.

Update 3:
I copied the /lib/systemd/system/serial-getty@.service file to /etc/systemd/system/serial-autologin@.service
Made the changes to ExecStart in that file.
Created this link in /etc/systemd/system/getty.target.wants:
serial-getty@ttyAMA0.service -> /etc/systemd/system/serial-autologin@.service
Now the serial terminal is started at boot.

Regards,

Rob.

Return to “Beginners”