Skip to contentSkip to conversation

meta-oe: libusbgx: Configure the Devices Used

PATCH In review Maxim Sloyko 2 participants 3 messages Aug 6, 2021 – Aug 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 meta-oe: libusbgx: Configure the Devices Used

Add ability to configure the UDC used for specific schema. The feature is backwards compatible, so existing users don't need to change anything.

If one wants to specify which UDC is used for specific schema, for example, eth0, they can add this variable to the configuration file:

UDC_FOR_SCHEMA_eth0=f8000000.udc

If the device file exists in /sys/class/udc when the gadget is started, it will be used for this schema.

If this configuration is not present, first available device is picked.

---
 meta-oe/recipes-support/libusbgx/libusbgx/gadget-start | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 meta-oe/recipes-support/libusbgx/libusbgx/gadget-start
meta-oe/recipes-support/libusbgx/libusbgx/gadget-start +6 -1
old mode 100644
new mode 100755
index 1a106b785..9e22671a9
@@ -7,5 +7,10 @@ for i in $IMPORT_SCHEMAS; do
 done
 
 for i in $ENABLED_SCHEMAS; do
-    ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
+    configured_udc=$(eval 'echo ${UDC_FOR_SCHEMA_'"$i"'}')
+    if [ -n "${configured_udc}" ] && [ -e "/sys/class/udc/${configured_udc}" ]; then
+        echo ${configured_udc} > /sys/kernel/config/usb_gadget/"$i"/UDC
+    else
+        ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
+    fi
 done
Signature · 1 line
2.32.0.605.g8dce9f2422-goog
#1 lore raw
Quoted 9 lines · Maxim Sloyko via lists.openembedded.org

Add ability to configure the UDC used for specific schema. The feature is backwards compatible, so existing users don't need to change anything.

If one wants to specify which UDC is used for specific schema, for example, eth0, they can add this variable to the configuration file:

Quoted 7 lines

UDC_FOR_SCHEMA_eth0=f8000000.udc

If the device file exists in /sys/class/udc when the gadget is started, it will be used for this schema.

If this configuration is not present, first available device is picked.

Thanks for your contribution Maxim, it looks fine, although I had to edit the commit subject line to remove meta-oe from it commit msg guidelines are here for OE
https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

Quoted 30 lines
---
 meta-oe/recipes-support/libusbgx/libusbgx/gadget-start | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 meta-oe/recipes-support/libusbgx/libusbgx/gadget-start
meta-oe/recipes-support/libusbgx/libusbgx/gadget-start +6 -2
old mode 100644
new mode 100755
index 1a106b785..9e22671a9
@@ -7,5 +7,10 @@ for i in $IMPORT_SCHEMAS; do
 done
 
 for i in $ENABLED_SCHEMAS; do
-    ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
+    configured_udc=$(eval 'echo ${UDC_FOR_SCHEMA_'"$i"'}')
+    if [ -n "${configured_udc}" ] && [ -e "/sys/class/udc/${configured_udc}" ]; then
+        echo ${configured_udc} > /sys/kernel/config/usb_gadget/"$i"/UDC
+    else
+        ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
+    fi
 done
--

2.32.0.605.g8dce9f2422-goog

#2 lore raw
Quoted 17 lines · Khem Raj
Quoted 14 lines · Maxim Sloyko via lists.openembedded.org

Add ability to configure the UDC used for specific schema. The feature is backwards compatible, so existing users don't need to change anything.

If one wants to specify which UDC is used for specific schema, for example, eth0, they can add this variable to the configuration file:

UDC_FOR_SCHEMA_eth0=f8000000.udc

If the device file exists in /sys/class/udc when the gadget is started, it will be used for this schema.

Quoted 7 lines
Quoted 2 lines

If this configuration is not present, first available device is picked.

Thanks for your contribution Maxim, it looks fine, although I had to edit the commit subject line to remove meta-oe from it commit msg guidelines are here for OE
https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

Noted, thank you.

Quoted 32 lines
Quoted 32 lines
---
 meta-oe/recipes-support/libusbgx/libusbgx/gadget-start | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 meta-oe/recipes-support/libusbgx/libusbgx/gadget-start
meta-oe/recipes-support/libusbgx/libusbgx/gadget-start +6 -2
old mode 100644
new mode 100755
index 1a106b785..9e22671a9
@@ -7,5 +7,10 @@ for i in $IMPORT_SCHEMAS; do
 done
 
 for i in $ENABLED_SCHEMAS; do
-    ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
+    configured_udc=$(eval 'echo ${UDC_FOR_SCHEMA_'"$i"'}')
+    if [ -n "${configured_udc}" ] && [ -e "/sys/class/udc/${configured_udc}" ]; then
+        echo ${configured_udc} > /sys/kernel/config/usb_gadget/"$i"/UDC
+    else
+        ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
+    fi
 done
--

2.32.0.605.g8dce9f2422-goog

Signature · 1 line
-MS