Bug 11766 - Console (getty) issues with systemd
Summary: Console (getty) issues with systemd
Status: RESOLVED NEEDINFO
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2019.02.1
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: Carlos Santos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-09 13:01 UTC by IsakT
Modified: 2019-12-10 21:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Comparison between console-getty.service contents between 2018.11 and 2019.02.1 (2.83 KB, text/plain)
2019-04-09 13:01 UTC, IsakT
Details
getty options changed from -L to -h (fixed) (2.83 KB, text/plain)
2019-05-02 14:32 UTC, khozaei
Details

Note You need to log in before you can comment on or make changes to this bug.
Description IsakT 2019-04-09 13:01:26 UTC
Created attachment 7976 [details]
Comparison between console-getty.service contents between 2018.11 and 2019.02.1

When using an image built with Buildroot for the Raspberry Pi 3 (64 bit) using systemd as init system, the serial console reached through 3 of the GPIO pins reports various errors and is generally unstable (misses characters sporadically). One common error I get printed is: "Inappropriate ioctl for device" from Getty.

This is on version 2019.02.1. The same config works fine with Buildroot 2018.11.

The error/issues goes away if I replace the contents in the file /etc/systemd/system/getty.target.wants/console-getty.service with the content in the same file from the image built with version 2018.11.

I can attach one file only, so the file contains the contents both from version 2018.11 (working) and 2019.02.1 (not working).
Comment 1 khozaei 2019-05-02 14:32:46 UTC
Created attachment 7986 [details]
getty options changed from -L to -h (fixed)

I found the solution finally.

I added `--flow-control` option to agetty in `serial-getty@.service` and this option fixed my problem.

> **-h, --flow-control** 

> Enable hardware (RTS/CTS) flow control. It is left up to the
> application to disable software (XON/XOFF) flow protocol where
> appropriate.
Comment 2 Carlos Santos 2019-07-20 18:05:58 UTC
Hello,

The change you proposed does not seem to be required for other boards beyond
Raspberry Pi 3. The best solution may be adding a post-buid script to patch
serial-getty@.service. There is already a board/raspberrypi/post-build.sh.

Would you mind submitting a patch?
Comment 3 Peter Seiderer 2019-07-21 19:16:39 UTC
Enabling hardware flow control for a 3-wire serial line (without
the extra wires for the hardware flow control) seems strange, and I believe is not the solution...

diff -u ~/Downloads/console-getty.service_comparison.txt ~/Downloads/console-getty.fixed.txt 
--- /home/seiderer/Downloads/console-getty.service_comparison.txt	2019-04-09 19:02:33.570689557 +0200
+++ /home/seiderer/Downloads/console-getty.fixed.txt	2019-07-21 21:03:18.299974466 +0200
@@ -32,7 +32,7 @@
     # The '-o' option value tells agetty to replace 'login' arguments with an
     # option to preserve environment (-p), followed by '--' for safety, and then
     # the entered username.
-    ExecStart=-/sbin/getty -L %I 115200 vt100
+    ExecStart=-/sbin/getty -h %I 115200 vt100
     Type=idle
     Restart=always
     UtmpIdentifier=%I

You seem to have fixed the already working file (marked by you with 'console-getty.service from Buildroot 2018.11 (Working):' and not the one marked by your with 'console-getty.service from Buildroot 2019.02.1 (Not working):'.

The real diff between the two versions is:

-    ExecStart=-/sbin/getty -L %I 115200 vt100
+    ExecStart=-/sbin/getty -L console 115200 vt100

Can you check which console/%I the working version is using on a running system?
Comment 4 Peter Seiderer 2019-07-21 21:03:29 UTC
Tested with buildroot master and raspberrypi3_64_defconfig with the following changes:

- change to glibc
- channge to init systemd

No login on HDMI, double Buildroot login on serial.

After changing cmdline.txt from:

    root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200

to (as described in [1]):

    root=/dev/mmcblk0p2 rootwait console=ttyAMA0,115200 console=tty1

everything worked fine...

Login from serial, getty for HDMI console runs:

    /sbin/agetty -o -p -- \u --noclear --keep-baud console 115200,38

Login from HMDI conole, getty for serial runs:

    /sbin/agetty -o -p -- \u --keep-baud 115200,38400,9600 ttyS0 vt220

Mind to share your config/defconfig file?

[1] https://patchwork.ozlabs.org/patch/668134
Comment 5 Carlos Santos 2019-09-29 15:50:24 UTC
Closing, since the reporter did not send the config file requested by Peter
Seiderer in comment #4. Fee free to reopen, if you still believe that this
bug is valid.
Comment 6 Simon 2019-12-10 20:02:51 UTC
I've ran into this issue as well when updating from 2018.11 to 2019.02.

The problem is that systemd automatically picks up the kernel's console=<console> parameter and creates a serial-console@<console>.service which collides with the one generated by buildroot.
The solution is to not create a service file for the serial console when using systemd.

See https://github.com/simonvanderveldt/norns-image/pull/40 for more info.
Comment 7 Carlos Santos 2019-12-10 21:39:24 UTC
(In reply to Simon from comment #6)

This bug was open aiming a problem with the Raspberry Pi 3 board. Please don't
reopen old bugs just because they are similar to your current problem.

If you are using systemd just don't select BR2_TARGET_GENERIC_GETTY and no
serial-console@<console>.service will be created.