AnsweredAssumed Answered

USB device - custom board

Question asked by havran on Jul 31, 2018
Latest reply on Aug 13, 2018 by havran

Hello,

 

we have custom board with SC589 chip. We have got  most of the peripherals working, except the USBs. There are two USBs: device and host. I am testing the device right now (there is problem with second - host - connector on our board at the moment) following the Linux Add-in user guide (creating g_mass_storage gadget), but with no luck (well, it worked only once - my laptop registered device in /dev after connecting USB - but I am not able to reproduce since then). Here is what I do on our device after boot:

# cat /sys/devices/platform/scb/310c2000.usb/musb-hdrc.1.auto/mode
b_idle
# dd if=/dev/zero of=fsg.block bs=1M count=16
16+0 records in
16+0 records out
# modprobe g_mass_storage file=/fsg.block stall=0
Number of LUNs=8
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
Number of LUNs=1
LUN: file: /fsg.block
Number of LUNs=1
g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
g_mass_storage gadget: userspace failed to provide iSerialNumber
g_mass_storage gadget: g_mass_storage ready
# cat /sys/devices/platform/scb/310c2000.usb/musb-hdrc.1.auto/mode
b_idle

The problem is that (until today, see below) my laptop never (well, it did, but only once) registered my device. When I connect device with my laptop, nothing happens - no change in "lsusb", no log in "dmesg" (on both sides). One time happend that laptop registered this USB (as I wrote above) and created device in /dev. But only once, which is strange.

 

The other problem occurred today. Once I probe gadget driver (output same as above) and connect device with my laptop, I got following messages on device side:

musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage setup
musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage setup
musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage setup
musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage in/status
musb_g_ep0_irq 804: SETUP packet len 4 != 8 ?
musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage in/status
musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage in/status
musb_g_ep0_irq 804: SETUP packet len 0 != 8 ?
musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage in/status
# cat /sys/devices/platform/scb/310c2000.usb/musb-hdrc.1.auto/mode
b_peripheral

 

At the same time, the host (laptop) shows something like this:

[ 8341.546917] usb 3-2: new full-speed USB device number 34 using xhci_hcd
[ 8341.670366] usb 3-2: device descriptor read/64, error -71
[ 8341.900327] usb 3-2: device descriptor read/64, error -71
[ 8342.130223] usb 3-2: new full-speed USB device number 35 using xhci_hcd
[ 8342.253602] usb 3-2: device descriptor read/64, error -71
[ 8342.483552] usb 3-2: device descriptor read/64, error -71
[ 8342.590228] usb usb3-port2: attempt power cycle
[ 8343.233575] usb 3-2: new full-speed USB device number 36 using xhci_hcd
[ 8343.233736] usb 3-2: Device not responding to setup address.
[ 8343.440385] usb 3-2: Device not responding to setup address.
[ 8343.646977] usb 3-2: device not accepting address 36, error -71
[ 8343.770289] usb 3-2: new full-speed USB device number 37 using xhci_hcd
[ 8343.770447] usb 3-2: Device not responding to setup address.
[ 8343.977148] usb 3-2: Device not responding to setup address.
[ 8344.183627] usb 3-2: device not accepting address 37, error -71
[ 8344.183733] usb usb3-port2: unable to enumerate USB device

I tried to connect it into my Raspberry, but raspberry did not detect it at all. I tested USB flash drivers on both Raspberry and my Laptop and it worked, so I guess it is not problem on the host side.

 

I am really running out of ideas. After several days of debugging it worked only once, and since today I see these ep0stage messages. Since I am testing device USB only at the moment, here is our dts config related to used USB (I deleted the host USB from dts for testing purposes):

<--snip-->

                usb0_phy: usb-phy@310c2390 {
                        compatible = "usb-nop-xceiv";
                        reg = <0x310c2390 0x10>;
                        reg-names = "phy";
                };

 

                usb0: usb@310c2000 {
                        compatible = "ADI,musb";
                        reg = <0x310c2000 0x390>;
                        reg-names = "mc";
                        interrupts = <0 134 0>,
                                                 <0 135 0>;
                        interrupt-names = "mc", "dma";
                        spu_securep_id = <154>;

 

                        mode = <2>;
                        mentor,multipoint = <1>;
                        mentor,num-eps = <16>;
                        mentor,ram-bits = <12>;
                        mentor,dma-channels = <8>;
                        memtor,dyn-fifo = <0>;
                        mentor,power = <500>;
                        phys = <&usb0_phy>;
                };

<--snip-->

 

We are using Linux version ADI-1.1.0, but I applied patch from [1]

# uname -a
Linux buildroot 4.0.0-ADI-1.1.0 #7 Mon Jul 30 21:32:50 CEST 2018 armv7l GNU/Linux
# lsusb
Bus 001 Device 001: ID 1d6b:0002

Do you have any ideas what is wrong or any tips for further debugging? I will be very grateful for any response.

 

Thank you very much!

 

[1] https://ez.analog.com/docs/DOC-17249-fix-usb-hotplug-issue-on-linux-for-sc5xx-for-linux-110

Outcomes