Merge pull request #2860 from citral23/usb-gadget

usbgadget: reorder the write to gadget/UDC to avoid a condition where…
This commit is contained in:
fewtarius 2024-02-08 10:07:15 -05:00 committed by GitHub
commit f4741244e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,6 +46,7 @@ usb_start() {
echo $VENDOR > gadget/strings/0x409/manufacturer
echo $MACHINE > gadget/strings/0x409/product
if [ "${USB_MODE}" = mtp ] ; then
echo 0x1d6b > gadget/idVendor
echo 0x0100 > gadget/idProduct
@ -55,19 +56,20 @@ usb_start() {
mount mtp -t functionfs /dev/ffs-umtp
/usr/sbin/umtprd &
sleep 1
echo "${UDC_NAME}" > gadget/UDC
elif [ "${USB_MODE}" = cdc ] ; then
echo cdc > gadget/configs/c.1/strings/0x409/configuration
echo 0x1d6b > gadget/idVendor
echo 0x104 > gadget/idProduct
ln -s gadget/functions/ecm.usb0 gadget/configs/c.1
echo "${UDC_NAME}" > gadget/UDC
ifconfig usb0 $IP up
/usr/sbin/udhcpd -S /storage/.cache/usbgadget/udhcpd.conf
else
exit 0
fi
echo "${UDC_NAME}" > /sys/kernel/config/usb_gadget/gadget/UDC
echo "USB_MODE=$(cat gadget/configs/c.1/strings/0x409/configuration)" > /storage/.cache/usbgadget/usbgadget.conf
}