4

Using 2020-12-02-raspios-buster-armhf-lite I have attached a USB to serial cable and enabled logins with

sudo systemctl enable serial-getty@ttyUSB0.service
sudo systemctl start serial-getty@ttyUSB0.service

This works fine. I can attach the serial cable to a PC and login. However if I disconnect the USB cable from the Raspberry Pi then reconnect it, I can no logger get a login prompt. Or if I boot the Pi without the USB cable attached I can't get a login prompt after plugging it in. It seems the USB cable has to be attached at boot time. Is there anyway to "hot plug" the USB cable and get a login prompt?

My goal is to have a totally headless Pi (with no networking) where if I need to login I can attach a USB to serial cable and get a login prompt.

1
  • If you do not enable them and connect to the serial port and ground do you not end up on the console? You may need to confirm console using the serial port and nothing else can use it in raspi-config
    – user115418
    Jan 3 at 4:29
4

After a lot of Googling I have come up with the following solution. Instead of the above, create these 2 files:

/etc/udev/rules.d/90-usb-serial-login.rules

ACTION=="add", SUBSYSTEM=="tty", ENV{ID_BUS}=="usb", TAG+="systemd", ENV{SYSTEMD_WANTS}="usb-serial-login.service"

/etc/systemd/system/usb-serial-login.service

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl start serial-getty@ttyUSB0

This seems to give a login prompt no matter when the USB cable is attached.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.