summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Richard2025-06-26 09:26:00 +0000
committerChuanhong Guo2025-07-04 01:50:24 +0000
commitc5c894f7ff9731cb0c24f566f41cdb2fce9aed68 (patch)
treec08f1daec92cac76a0b716199d4ec3b019063293
parente2cdcf8e4614176d3ff05db0c292440e844d5cb2 (diff)
downloadopenwrt-c5c894f7ff9731cb0c24f566f41cdb2fce9aed68.tar.gz
usbgadget: add OS descriptors support
Add OS descriptors support. Configuring OS descriptors allows Microsoft Windows to bind the right drivers without any additional configuration. Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Link: https://github.com/openwrt/openwrt/pull/19237 Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
-rw-r--r--package/utils/usbgadget/files/usbgadget.init9
1 files changed, 9 insertions, 0 deletions
diff --git a/package/utils/usbgadget/files/usbgadget.init b/package/utils/usbgadget/files/usbgadget.init
index f2e105caae..384ab548b6 100644
--- a/package/utils/usbgadget/files/usbgadget.init
+++ b/package/utils/usbgadget/files/usbgadget.init
@@ -35,6 +35,9 @@ setup_gadget() {
local strings_path="${gadget_path}/strings/0x409"
mkdir "$strings_path"
apply_configs "$strings_path" "$cfg"
+
+ local os_desc_path="${gadget_path}/os_desc"
+ apply_configs "$os_desc_path" "$cfg"
}
setup_configuration() {
@@ -54,6 +57,8 @@ setup_configuration() {
local strings_path="${cfg_path}/strings/0x409"
mkdir "$strings_path"
apply_configs "$strings_path" "$cfg"
+
+ ln -s "$cfg_path" "${GADGET_FS}/${GADGET_PREFIX}${gadget}/os_desc"
}
setup_function() {
@@ -78,6 +83,9 @@ setup_function() {
apply_configs "$fun_path" "$cfg"
+ local os_desc_path="$(find ${fun_path}/os_desc/* -type d)"
+ apply_configs "$os_desc_path" "$cfg"
+
ln -s "$fun_path" "$cfg_path"
}
@@ -134,6 +142,7 @@ stop() {
for gadget_path in ${GADGET_FS}/${GADGET_PREFIX}* ; do
[ -d "$gadget_path" ] || continue
echo "" > ${gadget_path}/UDC
+ find ${gadget_path}/os_desc -maxdepth 1 -type l -exec rm '{}' ';'
find ${gadget_path}/configs -maxdepth 2 -type l -exec rm '{}' ';'
rmdir ${gadget_path}/configs/*/strings/*
rmdir ${gadget_path}/configs/*