Hi, I’m the Toradex AI Assistant.
I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.
Hello! Thank you for your detailed description. Let’s address your questions and get USB device mode working on Torizon 7.x.x.
1. Permission Issue with echo
and sudo
This is a common shell issue: sudo
only elevates echo
, not the redirection (>
). The file write is still done as the regular user. To resolve, use sudo
with sh -c
like this:
sudo sh -c 'echo 0x1b67 > idVendor'
Apply this pattern for all echo commands writing to files under /sys
.
You can also run a root shell with sudo -i
or, in your script/service, ensure the whole process runs as root.
More details:
USB Device Mode (Linux) | Toradex Developer Center
2. USB Host Power Regulator and Device Functionality
Disabling the host VBUS regulator (®_usb_host_vbus
) should not affect USB device mode; host and device use separate controllers. This device tree change only disables power switching for host mode, so it does not interfere with gadget/device operation.
3. Device Tree Branch
For Torizon OS 7.1.0, make sure you use the device tree based on branch toradex_6.6-2.2.x-imx
for i.MX6. See more:
Add Device Tree Branch to Release Matrix
4. Gadget Not Starting
If the gadget is configured but not starting, ensure:
-
ConfigFS is mounted at
/sys/kernel/config
-
All necessary function drivers (e.g.,
usb_f_mass_storage
,usb_f_ecm
, etc.) are loaded -
udc is properly set: after creating and configuring, make sure you assign the UDC:
sudo sh -c 'echo <udc_name> > UDC'
where
<udc_name>
is typically found by listing/sys/class/udc/
(e.g.,ci_hdrc.0
). -
Check for kernel logs (
dmesg
) for USB or gadget-related issues.
5. General Setup Steps
Here is a simplified sequence, run as root or with each command wrapped in sudo sh -c
:
mount -t configfs none /sys/kernel/config
cd /sys/kernel/config/usb_gadget/
mkdir -p g2
cd g2
echo 0x1b67 > idVendor
echo 0x4000 > idProduct
mkdir -p strings/0x409
echo "1234567890" > strings/0x409/serialnumber
echo "Toradex" > strings/0x409/manufacturer
echo "USB Gadget" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
mkdir -p functions/ecm.usb0
ln -s functions/ecm.usb0 configs/c.1/
ls /sys/class/udc # outputs something like 'ci_hdrc.0'
echo ci_hdrc.0 > UDC
See USB Device Mode (Linux) for more examples and explanation.
If after these steps the device is still not enumerating, let me know the dmesg
output after configuring the gadget, and the result of lsusb
on the host.
Best regards, Toradex AI Assistant.