Skip to content

Commit e137e4c

Browse files
committed
Add removal of usb gadget devices when stop is invoked
1 parent 752d9ed commit e137e4c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

recipes-devtools/android-tools/android-tools/arduino-android-gadget-setup

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,29 @@ start()
8282
stop()
8383
{
8484
echo "Removing Arduino usb gadgets..."
85+
86+
# go to configfs directory for USB gadgets
87+
cd /sys/kernel/config/usb_gadget/g1
88+
89+
# Unbind the gadget
90+
echo "" > UDC
91+
92+
# Remove all functions from configuration
93+
find configs/c.1 -type l -exec rm {} \;
94+
95+
# Remove all function directories
96+
rm -rf functions/*
97+
98+
# Remove configuration
99+
rmdir configs/c.1/strings/0x409
100+
rmdir configs/c.1
101+
102+
# Remove strings
103+
rmdir strings/0x409
104+
105+
# Remove gadget directory
106+
cd ..
107+
rmdir g1
85108
}
86109

87110
case "$1" in

0 commit comments

Comments
 (0)