Guides
Guides copied to clipboard
Intentional delay
Hi, thanks for the guide, it's very helpful.
I've been using the mass-storage-gadget guide and found that the script in section 5.3.4 would not work every time.
ls: write error: Device or resource busy
I added an intentional delay before the last line and it seems to work reliably now.
#!/bin/bash
# /sbin/modprobe g_mass_storage file=/dev/mmcblk0p3
modprobe libcomposite
mkdir -p /sys/kernel/config/usb_gadget/mygadget
cd /sys/kernel/config/usb_gadget/mygadget
echo 0x1d6b > idVendor
echo 0x0104 > idProduct
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB
mkdir -p strings/0x409
echo "1234567890" > strings/0x409/serialnumber
echo "me" > strings/0x409/manufacturer
echo "My USB Device" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: Mass Storage" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
mkdir -p functions/mass_storage.usb0
echo 0 > functions/mass_storage.usb0/lun.0/cdrom
echo 0 > functions/mass_storage.usb0/lun.0/ro
echo /dev/mmcblk0p3 > functions/mass_storage.usb0/lun.0/file
ln -s functions/mass_storage.usb0 configs/c.1/
sleep 1 # required to make the following line work
ls /sys/class/udc > UDC
Hope this helps somebody.
Maybe a sync is an alternative for the sleep?