From 5583d2f8d7922fae0105203b049542b6b27f8cff Mon Sep 17 00:00:00 2001 From: "Joseph T. Foley" Date: Sun, 28 Jun 2026 23:15:48 +0000 Subject: [PATCH] unix line endings needed --- Scripts/gadget.sh | 96 ++++++++++++++--------------- Scripts/serial-ether-gadget.service | 12 ++-- 2 files changed, 54 insertions(+), 54 deletions(-) mode change 100644 => 100755 Scripts/gadget.sh diff --git a/Scripts/gadget.sh b/Scripts/gadget.sh old mode 100644 new mode 100755 index 4b2cc36..ab978eb --- a/Scripts/gadget.sh +++ b/Scripts/gadget.sh @@ -1,48 +1,48 @@ -# 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 -sudo modprobe libcomposite -cd /sys/kernel/config/usb_gadget -# Create our new gadget -sudo mkdir MyGadget -cd MyGadget -# Add some boilerplate data that the gadget needs -echo 0x1d6b > idVendor # Linux Foundation’s USB VID. Replace with your own VID if required -echo 0x0104 > idProduct # Multifunction Composite Gadget -echo 0x0100 > bcdDevice # v1.0.0 -echo 0x0200 > bcdUSB # USB2 -mkdir strings/0x409 # 0x409 = English -# Insert your own manufacturer and gadget name here -echo "RaspberryPi" > strings/0x409/manufacturer -echo "MyPiGadget" > strings/0x409/product -# Make the serial number the same as the Raspberry Pi serial number; you can use whatever is required here -SERIAL=`cat /proc/cpuinfo | awk '/Serial/ {print $3}' ` -echo $SERIAL > strings/0x409/serialnumber -# Create a configuration area and populate -mkdir configs/c.1 -echo 120 > configs/c.1/MaxPower -mkdir configs/c.1/strings/0x409 -echo "Config 1" > configs/c.1/strings/0x409/configuration - -# Create our specific gadget type -## Mass storage device -### Remember to create the storage block device first -## cd /root -### Example: Make a 256 MB file to act as "USB stick" -## sudo dd if=/dev/zero of=drive.bin bs=1M count=256 -### Create a VFAT file system on the backing store -## sudo mkfs.vfat drive.bin -## -# mkdir functions/mass_storage.usb0 -## Set up our backing store -# echo "/home/pi/drive.bin" > functions/mass_storage.usb0/lun.0/file -## Link our function to our configuration -#ln -s functions/mass_storage.0 configs/c.1/ - -## Serial (CDC ACM) -mkdir functions/acm.usb0 -ln -s functions/acm.usb0 configs/c.1/ - -## Ethernet (RNDIS and ECM) -mkdir functions/ecm.usb0 -ln -s functions/ecm.usb0 configs/c.1/ +# 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 +sudo modprobe libcomposite +cd /sys/kernel/config/usb_gadget +# Create our new gadget +sudo mkdir MyGadget +cd MyGadget +# Add some boilerplate data that the gadget needs +echo 0x1d6b > idVendor # Linux Foundation’s USB VID. Replace with your own VID if required +echo 0x0104 > idProduct # Multifunction Composite Gadget +echo 0x0100 > bcdDevice # v1.0.0 +echo 0x0200 > bcdUSB # USB2 +mkdir strings/0x409 # 0x409 = English +# Insert your own manufacturer and gadget name here +echo "RaspberryPi" > strings/0x409/manufacturer +echo "MyPiGadget" > strings/0x409/product +# Make the serial number the same as the Raspberry Pi serial number; you can use whatever is required here +SERIAL=`cat /proc/cpuinfo | awk '/Serial/ {print $3}' ` +echo $SERIAL > strings/0x409/serialnumber +# Create a configuration area and populate +mkdir configs/c.1 +echo 120 > configs/c.1/MaxPower +mkdir configs/c.1/strings/0x409 +echo "Config 1" > configs/c.1/strings/0x409/configuration + +# Create our specific gadget type +## Mass storage device +### Remember to create the storage block device first +## cd /root +### Example: Make a 256 MB file to act as "USB stick" +## sudo dd if=/dev/zero of=drive.bin bs=1M count=256 +### Create a VFAT file system on the backing store +## sudo mkfs.vfat drive.bin +## +# mkdir functions/mass_storage.usb0 +## Set up our backing store +# echo "/home/pi/drive.bin" > functions/mass_storage.usb0/lun.0/file +## Link our function to our configuration +#ln -s functions/mass_storage.0 configs/c.1/ + +## Serial (CDC ACM) +mkdir functions/acm.usb0 +ln -s functions/acm.usb0 configs/c.1/ + +## Ethernet (RNDIS and ECM) +mkdir functions/ecm.usb0 +ln -s functions/ecm.usb0 configs/c.1/ diff --git a/Scripts/serial-ether-gadget.service b/Scripts/serial-ether-gadget.service index fedb487..bc1765c 100644 --- a/Scripts/serial-ether-gadget.service +++ b/Scripts/serial-ether-gadget.service @@ -1,7 +1,7 @@ -[Unit] -Description=Serial and Ethernet over OTG USB -After=systemd-user-sessions.service -[Service] -ExecStart=/root/rover-pi/Scripts/gadget.sh -[Install] +[Unit] +Description=Serial and Ethernet over OTG USB +After=systemd-user-sessions.service +[Service] +ExecStart=/root/rover-pi/Scripts/gadget.sh +[Install] WantedBy=multi-user.targe \ No newline at end of file