USB Device Not Detected

I followed this article to create a USB gadget serial driver as a kernel module, which was loaded automatically at kernel boot-up without any issues.

root@colibri-imx6:~# lsmod
Module                  Size  Used by
usb_f_acm               4121  2
u_serial                8399  1 usb_f_acm
pn5xx_i2c               7933  0
libcomposite           35314  10 usb_f_acm
configfs               20093  3 usb_f_acm,libcomposite

When plugging an external USB device, most of the time the device was detected. A serial device “/dev/ttyACM0” and a disk drive “/dev/sda” were emulated successfully. Below is the kernel log when plugging the device:

root@colibri-imx6:~# [  826.873761] usb 1-1.2: new full-speed USB device number 3 using ci_hdrc
[  832.017113] usb-storage 1-1.2:1.2: USB Mass Storage device detected
[  832.042683] scsi host0: usb-storage 1-1.2:1.2
[  832.048983] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[  832.055692] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[  832.076936] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[  832.083609] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[  832.140086] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device
[  832.146449] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[  832.153118] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[  832.164670] usbcore: registered new interface driver cdc_acm
[  832.170362] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[  832.179498] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[  832.186206] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[  833.045102] scsi 0:0:0:0: Direct-Access     WHIS     Mass Storage          PQ: 0 ANSI: 4
[  833.061851] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[  833.068615] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[  833.076887] sd 0:0:0:0: [sda] 896 512-byte logical blocks: (459 kB/448 KiB)
[  833.094726] sd 0:0:0:0: [sda] Write Protect is off
[  833.105422] sd 0:0:0:0: [sda] No Caching mode page found
[  833.110792] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  833.145500]  sda:
[  833.152711] sd 0:0:0:0: [sda] Attached SCSI removable disk

However, some times the device was not detected successfully. No serial device or disk drive was emulated. This problem happens randomly. Below is the kernel log.

root@colibri-imx6:/etc/udev# [25324.735199] usb 1-1.1: new full-speed USB device number 33 using ci_hdrc
[25325.152880] usb 1-1.1: unable to read config index 0 descriptor/start: -32
[25325.159871] usb 1-1.1: chopping to 0 config(s)
[25325.167237] usb 1-1.1: string descriptor 0 read error: -32
[25325.177271] usb 1-1.1: no configuration chosen from 0 choices
[25325.183517] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[25325.190228] imx-sgtl5000 sound: snd_soc_register_card failed (-517)

I tried googling the error messages of the log and could not find anything useful. Can anybody interpret the error messages for me? How do I fix or mitigate this problem?
Thank you.
William

Could you try to reproduce the same with the Toradex Easy Installer which does support USB mass storage gadget out-of-the-box?

I did see this problem happened with Toradex Easy Installer. Below is the log:

 / # [ 2980.746223] usb 1-1.3: unable to read config index 0 descriptor/start: -32
    [ 2980.753204] usb 1-1.3: chopping to 0 config(s)
    [ 2980.759209] usb 1-1.3: string descriptor 0 read error: -32

And this happens all the time or just intermittent?

Have you tried connecting it to another USB port, another PC, through a USB hub vs. no hub?

It happens intermittent. It happens most likely when unplugging then re-plugging the USB cable with the USB device on.
I was using Colibri Eval board which has a USB hub for the tests shown above.
I just tried a custom board without a USB hub and this problem did not happen. I also tried to have a off-the-shelf external USB hub connected between the USB port on the custom board and the USB device. The problem did not happen either. It seems to me that the USB hub chip (USB2514B/M2) on Colibri Eval board is causing the problem. Any thought of how the chip firmware is updated?

It happens intermittent. It happens most likely when unplugging then re-plugging the USB cable with the USB device on.

What is your device? If it is on, this means its external powered and not by USB. Is you device USB compliant?

I was using Colibri Eval board which has a USB hub for the tests shown above.

Which version of Eval Board are you using exactly?

I just tried a custom board without a USB hub and this problem did not happen.

So, is this solution OK for you?

I also tried to have a off-the-shelf external USB hub connected between the USB port on the custom board and the USB device. The problem did not happen either.

What happen, if you connect this off the shelf hub between the USB Hub on board and your device. Is the issue still present?

It seems to me that the USB hub chip (USB2514B/M2) on Colibri Eval board is causing the problem. Any thought of how the chip firmware is updated?

I am not sure that the hub is really the problem. The hub does not need any firmware. There is the the possibility to solder EEPROM on the carrier baord, if a customer wants to have special settings for the USB device (enumeration, power, …).

Could you share the dmesg log in working and not working state?

First, thank you very much for taking your time to help me with this issue,

What is your device? If it is on, this means its external powered and not by USB. Is you device USB compliant?

It’s self powered device with STM32 microcontroller. It has a USB type-C port to communicate with Linux host using a USB type-A to type-C converter cable. The driver for windows is provided by manufacturer :
https://www.st.com/en/development-tools/stsw-stm32102.html
It does not seem to have Linux driver.
I don’t know how to tell if it is USB compliant.

Which version of Eval Board are you using exactly?
Col Evaluation V3.2A
So, is this solution OK for you?
No, we need 3 USB host ports. A hub is a must-have.
What happen, if you connect this off the shelf hub between the USB Hub on board and your device. Is the issue still present?
Below is kernel log after an external hub is plugged then the device is plugged into that hub.
I could not post the log in a proper format. So I just posted it in the comment section below this.
It seems that same issue happened ,but device enumeration was still successful. This phenomenon has been consistent with this setup.

Could you share the dmesg log in working and not working state?
See the attached text files.

Our latest finding is that all device enumeration failures happened when the cable was plugged into the device on type-C (device) side of the cable (host end was kept plugged). No issues so far when the cable was plugged into host on type-A (host) side (device end was kept plugged).
link text

root@colibri-imx6:~# [  175.531316] usb 1-1.1: new full-speed USB device number 8 using ci_hdrc
                        [  175.904151] usb 1-1.1: unable to read config index 0 descriptor/start: -32
                        [  175.911057] usb 1-1.1: chopping to 0 config(s)
                        [  175.918257] usb 1-1.1: string descriptor 0 read error: -32
                        [  175.928226] usb 1-1.1: no configuration chosen from 0 choices
                        [  234.978251] usb 1-1.1: USB disconnect, device number 8
                        [  450.249417] usb 1-1.1: new high-speed USB device number 9 using ci_hdrc
                        [  450.385929] hub 1-1.1:1.0: USB hub found
                        [  450.395742] hub 1-1.1:1.0: 4 ports detected
                        
                        root@colibri-imx6:~# [  480.490772] usb 1-1.1.1: new full-speed USB device number 10 using ci_hdrc
                        [  481.007061] usb 1-1.1.1: unable to read config index 0 descriptor/start: -71
                        [  481.014214] usb 1-1.1.1: can't read configurations, error -71
                        [  481.310802] usb 1-1.1.1: new full-speed USB device number 12 using ci_hdrc
                        [  486.430426] cdc_acm 1-1.1.1:1.0: ttyACM0: USB ACM device
                        [  486.445146] usb-storage 1-1.1.1:1.2: USB Mass Storage device detected
                        [  486.451947] scsi host4: usb-storage 1-1.1.1:1.2
                        [  487.452436] scsi 4:0:0:0: Direct-Access     WHIS     Mass Storage          PQ: 0 ANSI: 4
                        [  487.468685] sd 4:0:0:0: [sda] 896 512-byte logical blocks: (459 kB/448 KiB)
                        [  487.484683] sd 4:0:0:0: [sda] Write Protect is off
                        [  487.497705] sd 4:0:0:0: [sda] No Caching mode page found
                        [  487.503121] sd 4:0:0:0: [sda] Assuming drive cache: write through
                        [  487.538457]  sda:
                        [  487.545918] sd 4:0:0:0: [sda] Attached SCSI removable disk
                        [  487.753175] FAT-fs (sda): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Hi Dominik,
The device’s firmware just got updated by the developer. Not sure if it is related to the issue you mensioned. Now it’s being detected consistently without any issue.
Thank you, Toradex, for helping me with this issue.
Since it’s not related to any product or service provided by Toradex, Let me know I should delete this thread in the forum.

hi @wjzhang

Perfect that it works. Thanks for the feedback. You can leave the question as it is.

On you stm32 based device do you have controllable pull-up on one of the USB data lines? Double check if pull-up is activated after stm32 is done initialising usb peripheral. I’ve seen exactly those type of errors in a situation when pull-up was enabled when stm32 was not fully ready for usb control transfers.