New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gadget serial (ttyGS0) hangs when no host is present; prevents reboot & shutdown #1929
Comments
I would like to confirm the behavior on my raspberry pi zero W. Disabling the g_serial module seems to solve the shutdown/reboot hang. Have you managed to figure out a workaround, or how to do a clean shutdown once you've started up with g_serial enabled? |
Plugging in a host is the only workaround I know. You can do so while the reboot is happening and it will finish as usual. |
I cannot replicate this issue with the latest kernel, and Busybox getty. With
in /etc/inittab I can happily connect to my ZeroW through wifi and reboot, although there may still be an issue with Raspbian version of getty. Using the "-w" option for getty should stop it writing to ttyGS0 before a host connects, so there should be no reason for it to hang. |
Raspbian Jessie doesn't have an inittab. The step to enable the getty was
I copied /lib/sytemd/system/getty@.service to gadget-getty@.service and modified it to make it
which is definitively less zombie-like than before. I can't test plugging in a host and actually attempting to use it at the moment, however. |
@nsayer Hi, would it be possible to share your service file? I'm also encountering this issue and any changes always geive me the same results. It leaves an agetty process in some weird state : The service is impossible to stop and the system is unable to poweroff :( Connecting to a computer doesn't solve the issue either even when booting while it is plugged into a computer. |
Here's what I came up with, but I'm not 100% sure it's best-of-breed. :)
|
@nsayer : Thank you! It didn't help though I already tested it like this. I actually realized that systemd was stuck trying to clear the TTY, so it never even got around to starting agetty. The only way to unstuck the process was to set the TTY directives to no :
You can quickly override the existing service file like this :
This can also be done manually by creating an
This looks like a bug in systemd to be honest. I can connect using the serial connection from my computer now :D |
Closing this issue as questions answered/issue resolved. Please reopen if you feel more Raspian kernel work needs to be done. |
just to known, |
This issue still seems to exist as of 2019-09-16 in Raspbian 10. The changes suggested by @popsUlfr appear to fix the issue easily. Why not incorporate these changes into Raspbian so this functionality works out-of-the-box? |
@XECDesign Any thoughts? |
Are there any downsides or potential issues? |
If you run the following code on a Raspberry Zero with the latest Raspbian rebooting will hang. Reboot and shutdown are no longer possible without hanging after running the following script: if grep -q 'Zero' /proc/device-tree/model; then
echo '>>> Configuring Serial Login for Raspberry Zero'
echo ' dtoverlay=dwc2' >> /boot/config.txt
echo ' modules-load=dwc2,g_serial' >> /boot/cmdline.txt
echo 'g_serial' >> /etc/modules
systemctl enable getty@ttyGS0.service
else
echo 'This is not a Raspberry Zero, skip this step.'
fi Please fix this issue. I came up with the following workaround from @popsUlfr: # enable serial login on Raspberry Pi zero
if grep -q 'Zero' /proc/device-tree/model; then
echo '>>> Configuring Serial Login for Raspberry Zero'
echo ' dtoverlay=dwc2' >> /boot/config.txt
echo ' modules-load=dwc2,g_serial' >> /boot/cmdline.txt
echo 'g_serial' >> /etc/modules
# fix /raspberrypi/linux/issues/1929
mkdir -p /etc/systemd/system/getty@ttyGS0.service.d
bash -c 'echo -e "[Service]\nTTYReset=no\nTTYVHangup=no\nTTYVTDisallocate=no" > /etc/systemd/system/getty@ttyGS0.service.d/override.conf'
systemctl enable getty@ttyGS0.service
else
echo 'This is not a Raspberry Zero, skip this step.'
fi |
I can reproduce this |
A less invasive way to test is:
|
All that is required to make it reboot is changing |
@XECDesign I can't see any reason why we'd want Is this a systemd default setting? Can we patch this file, or add a local override? |
TTYVTDisallocate comes from systemd, but the problem is that the getty@.service unit is meant for virtual consoles. For serial consoles the serial-getty@service should be used. See also the comment in the unit file https://github.com/systemd/systemd/blob/master/units/getty%40.service.m4#L31-L34
|
Thank you very much for clarifying! |
Just wanted to thank you for this. I spent literally months searching for why my Rpis were not rebooting correctly, and some random serendipity walked me to your bug one night, and I fixed this nagging blocking issue for my next firmware update. |
+1 Saved me hours! Use serial-getty@.service not getty@.service
|
If you configure a Pi Zero or Zero W with the gadget serial configuration (dtoverlay dwc2, modules dwc2 and g_serial) and provision a getty on ttyGS0, the pi won't be able to be rebooted or shut down cleanly.
If you attach a host, this doesn't happen.
This is probably because the getty's attempt to open ttyGS0 hangs until a host shows up, and the process becomes unkillable.
The text was updated successfully, but these errors were encountered: