USB Device Mode does not work on Qt device creation image

In my project, I want to use a toradex imx6DL with iris carrier as a device (gadget). In general, I want to use the OTG port on Iris carrier (x12) to work as a device side so that I can connect it to a host and be recognized as a serial port (e.g. ttyACM0). I read the instruction http://developer.toradex.com/knowledge-base/usb-device-mode-(linux) and started with a Toradex image. It works perfectly out of box. I got a ttyACM0 on my host PC and a ttyGS0 on the board, and serial communication also works.

Then I tried to do the same with Boot2qt (Qt device creation) image (5.8) and found it doesn’t work. I found that usb_f_acm and u_serial modules are not loaded. I loaded them manually and followed the instruction to add gadget g1. It works fine until the last step echo ci_hdrc.1 > UDC. It shows -sh: echo: write error: Device or resource busy. I tried to find what goes wrong on the Internet and suspect that it is because boot2qt uses this QTG port for adb debugging. I can see usb_f_fs and g_ffs modules are loaded, but I cannot unload them by using rmmod.

Is this the reason of device or resource busy? How can I re-configure it to work just like in the Toradex image? Any help would be appreciated!

Hi

We are not really familiar with Qt for Device Creation.

Do you see an USB device originating from your Colibri iMX6 on your PC, e.g. what is the difference of lsusb before and after connecting the USBC port to the PC?

What kernel modules are loaded?

Do you have a directory /sys/kernel/config/usb_gadget/ and what is its content?
If yes you could try to disable the current usb_gadget device by doing a

echo "" > <directory_of_old_config>/UDC

Max

Hi Max,

Thanks for the help. I can see the USB device on my host pc. It shows:

Bus 003 Device 017: ID 18d1:0105 Google Inc.

I think it has been recognized as a g_ffs FunctionFS gadget. I think this is because boot2qt is running adb on it and use it for debugging. lsmod shows:

Module         Size       Used by
g_ffs          2500     1
usb_f_fs       16388    3 g_ffs
libcomposite   28301    2 g_ffs,usb_f_fs
configfs       20633    3 libcomposite,usb_f_fs
galcore        207902   2

The /sys/kernel/config/usb_gadget/ directory is empty and there is no g1 configuration in it. I can make a g1 or g2 configuration but in the last step echo ci_hdrc.1 > UDC. It shows -sh: echo: write error: Device or resource busy.

Since there is no g1, I don’t know where did the FunctionFS come from. If I can figure out how to disable it and release ci_hdrc.1, then probably I can make my own configuration. But I’m not familiar with the linux system and I don’t know how can I do that.

Hi

Do the following commands shed some light on the issue?

mount | grep configfs
find /etc/ -name “schema
find / -name UDC
grep gadget-import /etc -R

Max

Hi, I finally got some help from Qt company, and find out that our suspicion is correct. Indeed adbd is the cause of the issue. Solution is simple, change the /etc/default/adbd file and modify the USE_ETHERNET=no line to USE_ETHERNET=yes, in this way, adbd will use ethernet instead of the USB port.

Thanks a lot for the help!