From 29fb570ae5b08113ca51c4beb39f9241f0841c9c Mon Sep 17 00:00:00 2001 From: Joseph Timothy Foley Date: Thu, 2 Jul 2026 10:05:09 +0000 Subject: [PATCH] Adding module detect functionality --- Scripts/gadget.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Scripts/gadget.sh b/Scripts/gadget.sh index 148f635..0918cba 100755 --- a/Scripts/gadget.sh +++ b/Scripts/gadget.sh @@ -2,6 +2,17 @@ # Adapted from # "Using OTG mode on Raspberry Pi SBCs" # https://pip-assets.raspberrypi.com/categories/685-app-notes-guides-whitepapers/documents/RP-009276-WP/Using-OTG-mode-on-Raspberry-Pi-SBCs + +# Is the dwc2 overlay installed? Nothing will work if it isn't. +LOGGER="systemd-cat -t gadget.sh" +if lsmod | grep -q "dwc2"; then + $LOGGER -p info "DWC2 module loaded, setting up OTG gadget serial and ethernet" +else + $LOGGER -p warning "DWC2 module missing. Aborting OTG setup" + exit 1 +fi + + sudo modprobe libcomposite cd /sys/kernel/config/usb_gadget # Create our new gadget @@ -50,4 +61,4 @@ ln -s functions/ecm.usb0 configs/c.1/ ## USB Device Controller update UDC=`ls /sys/class/udc` -echo $UDC > UDC \ No newline at end of file +echo $UDC > UDC