From 709768214ca4f1c5e344975be1ce1d377d3432d6 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Wed, 10 Apr 2024 03:26:08 +0200 Subject: [PATCH] postmarketos-initramfs: check if UDC is configured before clearing (MR 5000) This fixes the annoying "sh: write error" and "Couldn't write to clear UDC" messages that happen on every single boot. Signed-off-by: Caleb Connolly --- main/postmarketos-initramfs/init_functions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/postmarketos-initramfs/init_functions.sh b/main/postmarketos-initramfs/init_functions.sh index 5cf2b16bf..69a84ee79 100644 --- a/main/postmarketos-initramfs/init_functions.sh +++ b/main/postmarketos-initramfs/init_functions.sh @@ -626,7 +626,9 @@ setup_usb_configfs_udc() { fi # Remove any existing UDC to avoid "write error: Resource busy" when setting UDC again - echo "" > /config/usb_gadget/g1/UDC || echo " Couldn't write to clear UDC" + if [ "$(wc -w <$CONFIGFS/g1/UDC)" -gt 0 ]; then + echo "" > /config/usb_gadget/g1/UDC || echo " Couldn't write to clear UDC" + fi # Link the gadget instance to an USB Device Controller. This activates the gadget. # See also: https://gitlab.com/postmarketOS/pmbootstrap/issues/338 echo "$_udc_dev" > /config/usb_gadget/g1/UDC || echo " Couldn't write new UDC"