raspberrypi / usbboot

Raspberry Pi USB booting code, moved from tools repository
Apache License 2.0
912 stars 229 forks source link

Reboot via signal from computer (UX Quality Of Life) #241

Open mofosyne opened 4 days ago

mofosyne commented 4 days ago

Is your feature request related to a problem? Please describe. Problem is after flashing, I have to manually reboot. This is fine, but hoping to automate this.

Describe the solution you'd like Would be nice to be able to auto trigger a reboot (And also if possible optionally disable eMMC boot on reboot)

Perhaps you could either expose a serial interface or maybe a HID device or perhaps upon detection of a special file read, to which you can request a reboot.

Describe alternatives you've considered Manually rebooting by hand. Works but is annoying.

Additional context Currently autodetecting the CM4 via an approach like below, so a bash friendly (and as driverless approach) would be appreciated.

# Locate RPI CM4 Via USB
DEVICE=$(lsscsi -N | grep "RPi-MSD-" | awk '{print $NF}')
if [ -z "$DEVICE" ]; then
    # Not yet booted
    rpiboot
    sleep 3s
    DEVICE=$(lsscsi -N | grep "RPi-MSD-" | awk '{print $NF}')
    if [ -z "$DEVICE" ]; then
        echo "Raspberry Pi storage device not found."
        exit 1
    fi
fi

# Making sure to unmount all partition (FYI: '?' is a glob pattern so that `sdX?*` matches /dev/sdX1 /dev/sdX2, etc...)
sudo umount $DEVICE?* || /bin/true
timg236 commented 4 days ago

The EEPROM flashing stage as a recovery_reboot option so you can automate the process of flashing the EEPROM default to EMMC then rebooting.

The mass-storage-gadget64 provides a UART console on the GPIO pins and a USB serial gadget so you could trigger a reboot after the flashing has completed e.g. use 'rpi-imager --cli' to flash then send 'sudo reboot' to the USB gadget serial after 'rpi-imager' has flashed / verified the imager.

The other option which is the future UX for provisioning is the Raspberry Pi secure-boot provisioner which is an open source fully automated provisioning system. It uses fastboot from a Linux initramfs so it's very easy to custom this to do arbitrary customizations. rpiboot is just the USB firmware loader in this context.

See: https://github.com/raspberrypi/rpi-sb-provisioner