This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3354: USB gadget not recognized by Host

Part Number: AM3354
Other Parts Discussed in Thread: TPS65218

After resolving this issue, I was able to load g_ether / g_mass_storage, but now my host computer isn't recognizing the SBC as a gadget device.

I'm watching dmesg on the host computer, and don't see any information when I plug in / unplug the SBC.

Here's what I'm running on the SBC:

dd bs=1M count=64 if=/dev/zero of=/backing_file
modprobe g_mass_storage file=/backing_file

And here's the output from dmesg:
~# dmesg | tail
[  921.136718] LUN: file: /backing_file
[  921.136732] Number of LUNs=1
[  921.136761] g_mass_storage gadget: adding config #1 'Linux File-Backed Storage'/bf1510d4
[  921.137186] g_mass_storage gadget: adding 'Mass Storage Function'/de5dad80 to config 'Linux File-Backed Storage'/bf1510d4
[  921.140897] g_mass_storage gadget: I/O thread pid: 1322
[  921.140964] g_mass_storage gadget: cfg 1/bf1510d4 speeds: high full
[  921.140978] g_mass_storage gadget:   interface 0 = Mass Storage Function/de5dad80
[  921.141013] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[  921.141029] g_mass_storage gadget: userspace failed to provide iSerialNumber
[  921.141039] g_mass_storage gadget: g_mass_storage ready

Running /proc/interrupts doesn't show any interrupts for musb-hdrc.0 / musb-hdrc.1, which I would think there would be if the physical connection is being made:

# cat /proc/interrupts
           CPU0       
 16:      61879      INTC  68 Level     gp_timer
 18:          0      INTC   3 Level     arm-pmu
 20:       1561      INTC  12 Level     49000000.edma_ccint
 22:         23      INTC  14 Level     49000000.edma_ccerrint
 26:          0      INTC  96 Level     44e07000.gpio
 27:          0      INTC  98 Level     4804c000.gpio
 28:          0      INTC  32 Level     481ac000.gpio
 29:          0      INTC  62 Level     481ae000.gpio
 30:       3212      INTC  72 Level     OMAP UART0
 31:       4250      INTC  73 Level     OMAP UART1
 35:          3      INTC  71 Level     4802a000.i2c
 36:          4      INTC  30 Level     4819c000.i2c
 37:         13      INTC  64 Level     mmc0
 38:       5371      INTC  28 Level     mmc1
 39:      55156      INTC  29 Level     mmc2
 47:          0      INTC  75 Level     rtc0
 48:          0      INTC  76 Level     rtc0
 49:      64578      INTC  36 Level     tilcdc
 52:          0      INTC  80 Level     48038000.mcasp_tx
 53:          0      INTC  81 Level     48038000.mcasp_rx
 54:          0      INTC 111 Level     48310000.rng
 55:          1      INTC  37 Level     SGX ISR
 57:          1      INTC  18 Level     musb-hdrc.0
 58:          1      INTC  19 Level     musb-hdrc.1
 60:          0  44e07000.gpio   6 Edge      48060000.mmc cd
 61:          0      INTC   7 Level     tps65218
Err:          0


I ran the script from this topic, here is the output:
Linux dorado 4.14.40-ti-jumpnow #1 PREEMPT Wed Jul 31 23:53:48 UTC 2019 armv7l armv7l armv7l GNU/Linux
USB is initialized
usb@47401000: host, okay
usb@47401800: otg, okay

Gadget Kernel Config: g_ether is enabled
Gadget Kernel Config: g_mass_storage is enabled
Gadget Kernel Config: g_serial is enabled
gadget driver loaded: (none)

The list of USB gadget drivers installed:
/lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/:
function/
legacy/
libcomposite.ko
udc/

/lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/function:
u_ether.ko
u_serial.ko
usb_f_acm.ko
usb_f_ecm.ko
usb_f_ecm_subset.ko
usb_f_eem.ko
usb_f_fs.ko
usb_f_hid.ko
usb_f_mass_storage.ko
usb_f_ncm.ko
usb_f_obex.ko
usb_f_rndis.ko
usb_f_serial.ko
usb_f_uvc.ko

/lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/legacy:
g_acm_ms.ko
g_cdc.ko
g_ether.ko
g_ffs.ko
g_hid.ko
g_mass_storage.ko
g_multi.ko
g_serial.ko
gadgetfs.ko

/lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/udc:
bdc/
dummy_hcd.ko
fotg210-udc.ko
fusb300_udc.ko
gr_udc.ko
m66592-udc.ko
mv_u3d_core.ko
mv_udc.ko
net2272.ko
pxa27x_udc.ko
r8a66597-udc.ko
snps_udc_core.ko
snps_udc_plat.ko
udc-xilinx.ko

/lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/udc/bdc:
bdc.ko


  • Hi,

    Robert Curtin said:
    I ran the script from this topic, here is the output:
    Linux dorado 4.14.40-ti-jumpnow #1 PREEMPT Wed Jul 31 23:53:48 UTC 2019 armv7l armv7l armv7l GNU/Linux
    USB is initialized
    usb@47401000: host, okay
    usb@47401800: otg, okay

    Gadget Kernel Config: g_ether is enabled
    Gadget Kernel Config: g_mass_storage is enabled
    Gadget Kernel Config: g_serial is enabled
    gadget driver loaded: (none)

    The log above shows MUSB1 is configured as otg/dual-role mode but no gadget driver loaded to it.

    Did you run this script before or after 'modprobe g_mass_storage' command?

  • Good catch, I copied the script incorrectly and it garbled the line that read the uevent information. Here's the correct output, which shows that g_mass_storage is loaded:

    # cat /sys/class/udc/musb-hdrc.1/uevent uevent
    DRIVER=g_mass_storage
    USB_UDC_NAME=musb-hdrc
    USB_UDC_DRIVER=g_mass_storage

    chkusb.sh Version 0.2.4
    Linux dorado 4.14.40-ti-jumpnow #1 PREEMPT Wed Jul 31 23:53:48 UTC 2019 armv7l armv7l armv7l GNU/Linux
    USB is initialized
    usb_test.sh: line 258: warning: command substitution: ignored null byte in input
    usb_test.sh: line 259: warning: command substitution: ignored null byte in input
    usb@47401000: host, okay
    usb_test.sh: line 258: warning: command substitution: ignored null byte in input
    usb_test.sh: line 259: warning: command substitution: ignored null byte in input
    usb@47401800: otg, okay

    Gadget Kernel Config: g_ether is enabled
    Gadget Kernel Config: g_mass_storage is enabled
    Gadget Kernel Config: g_serial is enabled
    gadget driver loaded: DRIVER=g_mass_storage

    The list of USB gadget drivers installed:
    /lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/:
    function/
    legacy/
    libcomposite.ko
    udc/

    /lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/function:
    u_ether.ko
    u_serial.ko
    usb_f_acm.ko
    usb_f_ecm.ko
    usb_f_ecm_subset.ko
    usb_f_eem.ko
    usb_f_fs.ko
    usb_f_hid.ko
    usb_f_mass_storage.ko
    usb_f_ncm.ko
    usb_f_obex.ko
    usb_f_rndis.ko
    usb_f_serial.ko
    usb_f_uvc.ko

    /lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/legacy:
    g_acm_ms.ko
    g_cdc.ko
    g_ether.ko
    g_ffs.ko
    g_hid.ko
    g_mass_storage.ko
    g_multi.ko
    g_serial.ko
    gadgetfs.ko

    /lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/udc:
    bdc/
    dummy_hcd.ko
    fotg210-udc.ko
    fusb300_udc.ko
    gr_udc.ko
    m66592-udc.ko
    mv_u3d_core.ko
    mv_udc.ko
    net2272.ko
    pxa27x_udc.ko
    r8a66597-udc.ko
    snps_udc_core.ko
    snps_udc_plat.ko
    udc-xilinx.ko

    /lib/modules/4.14.40-ti-jumpnow/kernel/drivers/usb/gadget/udc/bdc:
    bdc.ko

  • The log looks good now. Thanks.

    After loaded g_mass_storage gadget driver, and connected musb1 port to the USB host, please run the following command to get some musb register dump:

    # grep -i 'power\|devctl' /sys/kernel/debug/musb-hdrc.1/regdump

  • Here's the output. It doesn't change when I plug / unplug the USB host.

    # grep -i 'power\|devctl' /sys/kernel/debug/musb-hdrc.1/regdump
    Power       : e0
    DevCtl      : 19


  • Thanks for the register dump. It shows MUSB1 is in host mode. It is caused by grounded USB1_ID pin.

    If you only need MUSB1 to work in device mode on your  board, you can set usb1 dr_mode ='peripheral' in dts, which would ignore the USB1_ID pin status and put MUSB1 to device mode.

    But if you you need MUSB1 to work in dual role mode, you have to check your board design and usb connection to find out what causes USB1_ID pin grounded.

  • Setting dr_mode to 'peripheral' worked. Thankfully, having it be OTG is a nice-to-have, so that works for me!

    Thanks for your help!

  • Hi,

    I am glad the issue is solved. Thanks for the update.