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.

Linux/AM3358: USB force to Host/Device mode

Part Number: AM3358
Other Parts Discussed in Thread: TX12

Tool/software: Linux

Hi,

i want to use the usb host controller on the am3358 in host and gadget mode. A external trigger triggers the "transformation".

The device only have a usb a female connector, so i have to override the id pin to get in gaged mode. For Tests i use the beagle bone black (a femal connecto)

I changed the usb port in the device tree to

dr_mode = "otg";

The system boots, dmesg | grep usb shows :


root@beaglebone:~# dmesg |grep usb                                                                                                                                                
[    1.532469] usbcore: registered new interface driver usbfs
[    1.532549] usbcore: registered new interface driver hub
[    1.532674] usbcore: registered new device driver usb
[    2.182201] usbcore: registered new interface driver usb-storage
[    2.184238] 47401300.usb-phy supply vcc not found, using dummy regulator
[    2.186947] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[    2.186969] musb-hdrc: MHDRC RTL version 2.0
[    2.186978] musb-hdrc: setup fifo_mode 4
[    2.186997] musb-hdrc: 28/31 max ep, 16384/16384 memory
[    2.187159] musb-hdrc musb-hdrc.0.auto: MUSB HDRC host driver
[    2.187202] musb-hdrc musb-hdrc.0.auto: new USB bus registered, assigned bus number 1
[    2.187508] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.187523] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.187533] usb usb1: Product: MUSB HDRC host driver
[    2.187542] usb usb1: Manufacturer: Linux 4.4.91-ti-r133 musb-hcd
[    2.187551] usb usb1: SerialNumber: musb-hdrc.0.auto
[    2.190863] 47401b00.usb-phy supply vcc not found, using dummy regulator
[    2.193353] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[    2.193373] musb-hdrc: MHDRC RTL version 2.0
[    2.193382] musb-hdrc: setup fifo_mode 4
[    2.193398] musb-hdrc: 28/31 max ep, 16384/16384 memory
[    2.193572] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    2.193607] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 2
[    2.193876] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[    2.193891] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.193901] usb usb2: Product: MUSB HDRC host driver
[    2.193911] usb usb2: Manufacturer: Linux 4.4.91-ti-r133 musb-hcd
[    2.193920] usb usb2: SerialNumber: musb-hdrc.1.auto
[    2.283548] usbcore: registered new interface driver usbhid
[    2.283560] usbhid: USB HID core driver


lsusb -v


Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0002 2.0 root hub
  bcdDevice            4.04
  iManufacturer           3 Linux 4.4.91-ti-r133 musb-hcd
  iProduct                2 MUSB HDRC host driver
  iSerial                 1 musb-hdrc.1.auto
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
Hub Descriptor:
  bLength               9
  bDescriptorType      41
  nNbrPorts             1
  wHubCharacteristic 0x0011
    Per-port power switching
    No overcurrent protection
    TT think time 8 FS bits
  bPwrOn2PwrGood        5 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x02
  PortPwrCtrlMask    0xff
 Hub Port Status:
   Port 1: 0000.0100 power
Device Status:     0x0001
  Self Powered


I want to start in host mode and load a driver for a wifi module.But the usb power meter shows there is no power on the usb port.

What is the common way to enable power on the usb port in host mode ?

a possible solution form booting my side:

load the usb core driver in host mode ?

enable the power USB1_DRVVBUS (Signal in bbb schematic) powers the usb port with 5 volts

load the driver for the wifi stick

host to gadget:

unload wifi driver

disable power USB1_DRVVBUS

unload the host driver ?

load the rndis driver (bind to usb1 port)

gadget to host

vice versa

Is there a common solution the manage this problem ?

  • Stefan,

    You have two issues here.

    1. the usb port doesn't have vbus power after kernel booted.

    2. how to switch between host and gadget mode.

    Let's solve the first issue first.

    For a otg port (dr_mode = "otg") to work, you have to load a gadget driver, it makes sense for the gadget mode, but it is also required for the port to work in host mode.

    Now you changed the second port to "otg" mode, I don't know how you set dr_mode for the first USB port (the micro-AB port), but you can check the folder "/sys/class/udc/".

    If there is only one folder "musb-hdrc.0.auto", it is for the second port, you only need to load one USB gadget driver.

    But if there are two folders "musb-hdrc.0.auto" and "musb-hdrc.1.auto", which means both usb ports are in "otg" mode, you have to load two different gadget drivers for the second usb port to work in "otg" mode properly, or disable the first USB port if you don't use it at all.

  • Hi Bin,

    i have only one file in/sys/class/udc/ the "musb-hdrc.0.auto" I load the usb rinds driver via modprobe. The moduls loads correctly but, lsmod shows that the rinds module is not used by anyone. I tried to bind the driver to the 1-1:1.0 but I got the error no such device.

    But nothing works and power on the usb device. Can I reload the usb core diver for the usb controller ?

    Thanks
    Stefan
  • Stefan Blattmann said:
    i have only one file in/sys/class/udc/ the "musb-hdrc.0.auto"

    Please run the following two commands to get the dr_mode for both usb controllers.

    # cat /proc/device-tree/ocp/usb\@47400000/usb\@47401000/dr_mode
    # cat /proc/device-tree/ocp/usb\@47400000/usb\@47401800/dr_mode

    Stefan Blattmann said:
    I load the usb rinds driver via modprobe.

    Please show the exact command you used.

    Stefan Blattmann said:
    lsmod shows that the rinds module is not used by anyone

    Please show the exact log too. I have to see the exact log to tell what is going on.

    Stefan Blattmann said:
    I tried to bind the driver to the 1-1:1.0 but I got the error no such device.

    Don't bind it. The usb gadget driver is for udc, not for any usb host bus, such as 1-1:1.0...

    Stefan Blattmann said:
    But nothing works and power on the usb device. Can I reload the usb core diver for the usb controller ?

    Please show me the exact commands and logs. It suppose to work if everything step is done correctly.

  • Please also run the following command, it will tell which usb port is the musb-hdrc.0.auto udc.

    # ls -l /sys/class/udc/musb-hdrc.0.auto
  • Hi Bin,

    sorry for the typos.

    Here are the outputs:


    cat /proc/device-tree/ocp/usb\@47400000/usb\@47401000/dr_mode; echo

    peripheral


    cat /proc/device-tree/ocp/usb\@47400000/usb\@47401800/dr_mode; echo

    otg


    according to the dts / dtb file usb section:

    the output from dr_mode seems correct. Note usb port 0 is disabled in device tree!


            usb@47400000 {
                compatible = "ti,am33xx-usb";
                reg = <0x47400000 0x1000>;
                ranges;
                #address-cells = <0x1>;
                #size-cells = <0x1>;
                ti,hwmods = "usb_otg_hs";
                status = "okay";
                linux,phandle = <0xaf>;
                phandle = <0xaf>;

                control@44e10620 {
                    compatible = "ti,am335x-usb-ctrl-module";
                    reg = <0x44e10620 0x10 0x44e10648 0x4>;
                    reg-names = "phy_ctrl", "wakeup";
                    status = "okay";
                    linux,phandle = <0x3a>;
                    phandle = <0x3a>;
                };

                usb-phy@47401300 {
                    compatible = "ti,am335x-usb-phy";
                    reg = <0x47401300 0x100>;
                    reg-names = "phy";
                    status = "okay";
                    ti,ctrl_mod = <0x3a>;
                    linux,phandle = <0x3b>;
                    phandle = <0x3b>;
                };

                usb@47401000 {
                    compatible = "ti,musb-am33xx";
                    status = "disabeld";
                    reg = <0x47401400 0x400 0x47401000 0x200>;
                    reg-names = "mc", "control";
                    interrupts = <0x12>;
                    interrupt-names = "mc";
                    dr_mode = "peripheral";
                    mentor,multipoint = <0x1>;
                    mentor,num-eps = <0x10>;
                    mentor,ram-bits = <0xc>;
                    mentor,power = <0x1f4>;
                    phys = <0x3b>;
                    dmas = <0x3c 0x0 0x0 0x3c 0x1 0x0 0x3c 0x2 0x0 0x3c 0x3 0x0 0x3c 0x4 0x0 0x3c 0x5 0x0 0x3c 0x6 0x0 0x3c 0x7 0x0 0x3c 0x8 0x0 0x3c 0x9 0x0 0x3c 0xa 0x0 0x3c 0xb 0x0 0x3c 0xc 0x0 0x3c 0xd 0x0 0x3c 0xe 0x0 0x3c 0x0 0x1 0x3c 0x1 0x1 0x3c 0x2 0x1 0x3c 0x3 0x1 0x3c 0x4 0x1 0x3c 0x5 0x1 0x3c 0x6 0x1 0x3c 0x7 0x1 0x3c 0x8 0x1 0x3c 0x9 0x1 0x3c 0xa 0x1 0x3c 0xb 0x1 0x3c 0xc 0x1 0x3c 0xd 0x1 0x3c 0xe 0x1>;
                    dma-names = "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", "rx14", "rx15", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx14", "tx15";
                    linux,phandle = <0xb0>;
                    phandle = <0xb0>;
                };

                usb-phy@47401b00 {
                    compatible = "ti,am335x-usb-phy";
                    reg = <0x47401b00 0x100>;
                    reg-names = "phy";
                    status = "okay";
                    ti,ctrl_mod = <0x3a>;
                    linux,phandle = <0x3d>;
                    phandle = <0x3d>;
                };

                usb@47401800 {
                    compatible = "ti,musb-am33xx";
                    status = "okay";
                    reg = <0x47401c00 0x400 0x47401800 0x200>;
                    reg-names = "mc", "control";
                    interrupts = <0x13>;
                    interrupt-names = "mc";
                    dr_mode = "otg";
                    mentor,multipoint = <0x1>;
                    mentor,num-eps = <0x10>;
                    mentor,ram-bits = <0xc>;
                    mentor,power = <0x1f4>;
                    phys = <0x3d>;
                    dmas = <0x3c 0xf 0x0 0x3c 0x10 0x0 0x3c 0x11 0x0 0x3c 0x12 0x0 0x3c 0x13 0x0 0x3c 0x14 0x0 0x3c 0x15 0x0 0x3c 0x16 0x0 0x3c 0x17 0x0 0x3c 0x18 0x0 0x3c 0x19 0x0 0x3c 0x1a 0x0 0x3c 0x1b 0x0 0x3c 0x1c 0x0 0x3c 0x1d 0x0 0x3c 0xf 0x1 0x3c 0x10 0x1 0x3c 0x11 0x1 0x3c 0x12 0x1 0x3c 0x13 0x1 0x3c 0x14 0x1 0x3c 0x15 0x1 0x3c 0x16 0x1 0x3c 0x17 0x1 0x3c 0x18 0x1 0x3c 0x19 0x1 0x3c 0x1a 0x1 0x3c 0x1b 0x1 0x3c 0x1c 0x1 0x3c 0x1d 0x1>;
                    dma-names = "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", "rx14", "rx15", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx14", "tx15";
                    linux,phandle = <0xb1>;
                    phandle = <0xb1>;
                };

                dma-controller@47402000 {
                    compatible = "ti,am3359-cppi41";
                    reg = <0x47400000 0x1000 0x47402000 0x1000 0x47403000 0x1000 0x47404000 0x4000>;
                    reg-names = "glue", "controller", "scheduler", "queuemgr";
                    interrupts = <0x11>;
                    interrupt-names = "glue";
                    #dma-cells = <0x2>;
                    #dma-channels = <0x1e>;
                    #dma-requests = <0x100>;
                    status = "okay";
                    linux,phandle = <0x3c>;
                    phandle = <0x3c>;
                };
            };


    Loading rndis driver:

    # modprobe -v usb_f_rndis



    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/libcomposite.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/u_ether.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/usb_f_rndis.ko


    # lsmod


    Module                  Size  Used by
    usb_f_rndis            26581  0
    u_ether                14733  1 usb_f_rndis
    libcomposite           54488  1 usb_f_rndis
    evdev                  14151  1
    uio_pdrv_genirq         4243  0
    uio                    11100  1 uio_pdrv_genirq
    spidev                  9289  0
    tieqep                 10422  0
    ip_tables              15525  0
    x_tables               21069  1 ip_tables
    pru_rproc              15879  2
    pruss_intc              9009  1 pru_rproc
    pruss                  12346  1 pru_rproc


    #dmesg | grep usb


    [    1.532458] usbcore: registered new interface driver usbfs
    [    1.532535] usbcore: registered new interface driver hub
    [    1.532655] usbcore: registered new device driver usb
    [    2.182061] usbcore: registered new interface driver usb-storage
    [    2.184121] 47401300.usb-phy supply vcc not found, using dummy regulator
    [    2.185650] 47401b00.usb-phy supply vcc not found, using dummy regulator
    [    2.188133] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
    [    2.188154] musb-hdrc: MHDRC RTL version 2.0
    [    2.188164] musb-hdrc: setup fifo_mode 4
    [    2.188184] musb-hdrc: 28/31 max ep, 16384/16384 memory
    [    2.188336] musb-hdrc musb-hdrc.0.auto: MUSB HDRC host driver
    [    2.188388] musb-hdrc musb-hdrc.0.auto: new USB bus registered, assigned bus number 1
    [    2.188944] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
    [    2.188961] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    [    2.188971] usb usb1: Product: MUSB HDRC host driver
    [    2.188980] usb usb1: Manufacturer: Linux 4.4.91-ti-r133 musb-hcd
    [    2.188989] usb usb1: SerialNumber: musb-hdrc.0.auto
    [    2.278926] usbcore: registered new interface driver usbhid
    [    2.278938] usbhid: USB HID core driver


    # ls -l /sys/class/udc/musb-hdrc.0.auto


    lrwxrwxrwx 1 root root 0 Jan  1  2000 /sys/class/udc/musb-hdrc.0.auto -> ../../devices/platform/ocp/47400000.usb/47401c00.usb/musb-hdrc.0.auto/udc/musb-hdrc.0.auto


  • Stefan,

    Stefan Blattmann said:

    Loading rndis driver:

    # modprobe -v usb_f_rndis

    I believe this is the problem. You cannot _directly_ use usb_f_rndis driver alone, it is a USB "function", not a "gadget", two different things in the USB world. usb_f_rndis mainly is used in USB gadget configfs.

    In your use case, to use usb-ethernet gadget, you can use "modprobe g_ether" instead. Please let me know if this command solves the USB port VBUS power problem.

  • Hi Bin,

    I modprobe the g_ether

    # modprobe -v g_ether


    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/libcomposite.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/u_ether.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/usb_f_rndis.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/legacy/g_ether.ko


    # lsmod


    usb_f_ecm              11448  1
    g_ether                 5763  0
    usb_f_rndis            26581  2 g_ether
    u_ether                14733  3 usb_f_ecm,usb_f_rndis,g_ether
    libcomposite           54488  3 usb_f_ecm,usb_f_rndis,g_ether
    evdev                  14151  1
    uio_pdrv_genirq         4243  0
    uio                    11100  1 uio_pdrv_genirq
    spidev                  9289  0
    tieqep                 10422  0
    ip_tables              15525  0
    x_tables               21069  1 ip_tables
    pru_rproc              15879  2
    pruss_intc              9009  1 pru_rproc
    pruss                  12346  1 pru_rproc


    # lsusb


    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


    But there is still no usb power on the Port.

  • Stefan Blattmann said:

    I modprobe the g_ether

    # modprobe -v g_ether


    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/libcomposite.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/u_ether.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/usb_f_rndis.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/legacy/g_ether.ko

    Do you see more logs after this? I got more, please see my log below.

    If now you change back USB1 port dr_mode to "host" in device tree, does the port has vbus power?

    I just tested it on my BeagleboneBlack. It works for me. Please see the details below.

    diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
    index 07ed84c0b8f2..1dd5f540c15b 100644
    --- a/arch/arm/boot/dts/am335x-bone-common.dtsi
    +++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
    @@ -211,13 +211,13 @@
     };
     
     &usb0 {
    -       status = "okay";
    +       status = "disabled";
            dr_mode = "peripheral";
     };
     
     &usb1 {
            status = "okay";
    -       dr_mode = "host";
    +       dr_mode = "otg";
     };
     
     &cppi41dma  {

    am335x-evm login: root
    root@am335x-evm:~# modprobe -v g_ether
    insmod /lib/modules/4.4.41-03567-g7c580a51af52-dirty/kernel/drivers/usb/gadget/libcomposite.ko 
    insmod /lib/modules/4.4.41-03567-g7c580a51af52-dirty/kernel/drivers/usb/gadget/function/u_ether.ko 
    insmod /lib/modules/4.4.41-03567-g7c580a51af52-dirty/kernel/drivers/usb/gadget/function/usb_f_rndis.ko 
    insmod /lib/modules/4.4.41-03567-g7c580a51af52-dirty/kernel/drivers/usb/gadget/legacy/g_ether.ko 
    [   44.380437] using random self ethernet address
    [   44.388473] using random host ethernet address
    [   44.404250] usb0: HOST MAC 2e:90:31:a5:bb:fa
    [   44.417178] usb0: MAC 16:e8:5a:b4:4d:c3
    [   44.423824] using random self ethernet address
    [   44.429719] using random host ethernet address
    [   44.442823] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
    [   44.449474] g_ether gadget: g_ether ready
    root@am335x-evm:~# [   44.950961] usb 1-1: new high-speed USB device number 2 using musb-hdrc
    [   45.094926] usb 1-1: New USB device found, idVendor=13b1, idProduct=003a
    [   45.101742] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [   45.108907] usb 1-1: Product: Linksys AE2500
    [   45.117051] usb 1-1: Manufacturer: Cisco
    [   45.123614] usb 1-1: SerialNumber: 000000000001
    
    root@am335x-evm:~#
    root@am335x-evm:~# lsusb
    Bus 001 Device 002: ID 13b1:003a Linksys AE2500 802.11abgn Wireless Adapter [Broadcom BCM43236]
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
  • if i change the dr_mode to host it works fine and peripheral also.

    i use the kernel version

    # uname -r


    4.4.91-ti-r133


    # modprobe -v g_ether


    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/libcomposite.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/u_ether.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/usb_f_rndis.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/legacy/g_ether.ko


    # dmesg


    [    8.782348] systemd-journald[242]: Received request to flush runtime journal from PID 1
    [   11.364378] cgroup: new mount options do not match the existing superblock, will be ignored
    [   12.660167] random: nonblocking pool is initialized
    [  117.750185] using random self ethernet address
    [  117.750215] using random host ethernet address
    [  117.751329] usb0: HOST MAC 0e:15:d8:75:71:12
    [  117.751546] usb0: MAC d2:b9:f6:70:06:20
    [  117.751608] using random self ethernet address
    [  117.751621] using random host ethernet address
    [  117.751773] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
    [  117.751788] g_ether gadget: g_ether ready


    # lsusb


    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


  • rndis works probably in otg mode after loading the  # modprobe -v g_ether

    # dmesg


    [   47.837418] using random self ethernet address
    [   47.837450] using random host ethernet address
    [   47.838586] usb0: HOST MAC d2:a6:bd:06:c5:68
    [   47.838804] usb0: MAC 9e:98:26:18:aa:ae
    [   47.838867] using random self ethernet address
    [   47.838881] using random host ethernet address
    [   47.839032] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
    [   47.839045] g_ether gadget: g_ether ready
    [   48.300288] g_ether gadget: high-speed config #1: CDC Ethernet (ECM)


    but host mode is not working

  • Stefan,

    I cannot think of any obvious reason why host mode doesn't have vbus power after a gadget driver is loaded.
    Please use the following command to dump a register after loaded g_ether.
    # devmem2 0x47401c60 b

    What is the revision of your beaglebone black? Mine is C0.
    If you cannot find any label on the board showing the revision, you can use the following commands to read it from U-Boot prompt.

    # i2c dev 0
    # i2c probe
    # i2c md 0x50 0.2
  • Bin,

    # devmem2 0x47401c60 b


    /dev/mem opened.
    Memory mapped at address 0xb6f14000.
    Value at address 0x1195383904 (0xb6f14c60): 0x128


    hexdump -e '8/1 "%c"' "/sys/bus/i2c/devices/0-0050/eeprom" -s 13 -n 3 2>&1


    c0


    I alos checkt the revision the c0 version uses the 4GB NAND Flash so

    # df


    Filesystem     1K-blocks    Used Available Use% Mounted on
    udev              221852       0    221852   0% /dev
    tmpfs              49936    3788     46148   8% /run
    /dev/mmcblk0p1   3357264 1715736   1451272  55% /
    tmpfs             249672       0    249672   0% /dev/shm
    tmpfs               5120       0      5120   0% /run/lock
    tmpfs             249672       0    249672   0% /sys/fs/cgroup
    tmpfs              49932       0     49932   0% /run/user/0


  • Stefan,

    Stefan Blattmann said:

    # devmem2 0x47401c60 b


    /dev/mem opened.
    Memory mapped at address 0xb6f14000.
    Value at address 0x1195383904 (0xb6f14c60): 0x128

    Are you sure you read back 0x128? not a copy&paste error?

    The command should only read one byte, getting 0x128 is impossible.

    Stefan Blattmann said:

    hexdump -e '8/1 "%c"' "/sys/bus/i2c/devices/0-0050/eeprom" -s 13 -n 3 2>&1


    c0

    Okay, we have the same revision. Hardware factor is out.

  • Bin,

    i compiled memdv2 from

    https://github.com/VCTLabs/devmem2

    # make

    # make install

    i recheck the output from

    # devmem2 0x47401c60 b and get


    root@beaglebone:~# devmem2 0x47401c60 b
    /dev/mem opened.
    Memory mapped at address 0xb6fe3000.
    Value at address 0x1195383904 (0xb6fe3c60): 0x128


  • Stefan,

    I am not sure why the tool results more than one byte. But please use the following command to read the register instead.

    # grep -i devctl /sys/kernel/debug/musb-hdrc.0.auto/regdump
  • Bin,

    ok,

    here the output from "grep -i devctl /sys/kernel/debug/musb-hdrc.0.auto/regdump"

    output at bootup without loading the g_ether


    root@beaglebone:~#  grep -i devctl /sys/kernel/debug/musb-hdrc.0.auto/regdump
    DevCtl      : 80

    output after loading g_ether


    root@beaglebone:~# modprobe -v g_ether
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/libcomposite.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/u_ether.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/function/usb_f_rndis.ko
    insmod /lib/modules/4.4.91-ti-r133/kernel/drivers/usb/gadget/legacy/g_ether.ko
    root@beaglebone:~# grep -i devctl /sys/kernel/debug/musb-hdrc.0.auto/regdump
    DevCtl      : 80


  • Stefan Blattmann said:
    root@beaglebone:~# modprobe -v g_ether
    ...
    root@beaglebone:~# grep -i devctl /sys/kernel/debug/musb-hdrc.0.auto/regdump
    DevCtl      : 80

    I was expecting DevCtl register should be 0x19 now. You wouldn't have vbus power if it is 0x80.

    One more thing to check, please run the following two commands after "modprobe g_ether".

    # ls -l /sys/class/udc/

    # cat /sys/class/udc/musb-hdrc.0.auto/uevent

  • Stefan,

    Have you modified the Beaglebone Black board? The USB1 port has its ID pin grounded, did you remove the grounding?
  • Hi Bin,

    # ls -l /sys/class/udc/


    root@beaglebone:~# ls -l /sys/class/udc/
    total 0
    lrwxrwxrwx 1 root root 0 Nov  3 17:17 musb-hdrc.0.auto -> ../../devices/platform/ocp/47400000.usb/47401c00.usb/musb-hdrc.0.auto/udc/musb-hdrc.0.auto
    root@beaglebone:~#


    cat /sys/class/udc/musb-hdrc.0.auto/uevent


    root@beaglebone:~# cat /sys/class/udc/musb-hdrc.0.auto/uevent
    DRIVER=g_ether
    USB_UDC_NAME=musb-hdrc
    USB_UDC_DRIVER=g_ether
    root@beaglebone:~#


    actually i didnt modified the id pin on the bbb

  • Stefan,

    We checked everything which can I think of going wrong, all looks good, except the driver doesn't work in the way it suppose to to put the musb controller to host mode - DevCtl register is 0x80 which is supposed to be 0x19 after loaded a gadget driver.

    Did you add any customized kernel boot option in uboot? Please run command 'cat /proc/cmdline'.

    If nothing special in kernel boot parameters, the only thing which could cause the issue is the musb driver. You use kernel 4.4.91-ti-r133 which seems not from TI Processor SDK package. Can you please test with the pre-built binaries in the TI Processor SDK package to see if it has the same issue?

    Can you please share the change you did in dts in patch format? I remembered you posted your dts before, but it is not in patch format, It is not easy for me to tell what is changed.

  • Hi bin,

    here the outputs:

    cat /proc/cmdline


    console=ttyO0,115200n8 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet


    tomorrow i upload the patch file from the devicetree

  • Stefan,

    Your kernel params look to be okay.
    Can you please test with the pre-built binaries in the TI Processor SDK package to see if it has the same issue?
  • Stefan,

    I haven’t heard back from you, I’m assuming you were able to resolve your issue. If not, just post a reply below (or create a new thread if the thread has locked due to time-out). thanks.
  • Dear Stefan,

    thank you for the constructive exchange so far.

    We had an internal call regarding this open issue and our BU is ready to support you further. 

    Please try to reproduce this issue based on latest SW package provided in previous message and report back asap.

    Thank you

    Best regards

    Karim

    Member Group Technical Staff

  • Hello Karim,

    Hello Bin,

    Sorry for my delayed answer, i did't  work only on the usb otg issue.

    I have fixed the problem wit another BeagleBoneBlack and a custom linux build  with buildroot. I seems that my test BeagleBone have a hardware defekt.

    The buildroot config:


    BR2_arm=y
    BR2_cortex_a8=y
    BR2_ARM_FPU_NEON=y
    BR2_GLOBAL_PATCH_DIR="board/testo/beagleBoneTesto/patches"
    BR2_SSP_ALL=y
    BR2_RELRO_FULL=y
    BR2_FORTIFY_SOURCE_2=y
    BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
    BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_14=y
    BR2_BINUTILS_VERSION_2_30_X=y
    BR2_GCC_VERSION_7_X=y
    BR2_TOOLCHAIN_BUILDROOT_CXX=y
    BR2_GCC_ENABLE_LTO=y
    BR2_TARGET_GENERIC_ISSUE="Welcome to Testo BeagleBone "
    BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
    BR2_TARGET_GENERIC_GETTY_PORT="ttyO0"
    BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
    BR2_ROOTFS_OVERLAY="board/testo/beagleBoneTesto/add2rootfs"
    BR2_ROOTFS_POST_IMAGE_SCRIPT="board/testo/beagleBoneTesto/post-image.sh"
    BR2_LINUX_KERNEL=y
    BR2_LINUX_KERNEL_CUSTOM_GIT=y
    BR2_LINUX_KERNEL_CUSTOM_REPO_URL="github.com/.../linux.git"
    BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="5d84ea71b463b8c98bad9fcd8d92e0781a0e5b2a"
    BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
    BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/testo/beagleBoneTesto/linux.config"
    BR2_LINUX_KERNEL_DTS_SUPPORT=y
    BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y
    BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="board/testo/beagleBoneTesto/dts/am335x-bbt.dts"
    BR2_PACKAGE_BUSYBOX_CONFIG="board/testo/beagleBoneTesto/busybox.config"
    BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
    BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES=y
    BR2_PACKAGE_BUSYBOX_WATCHDOG=y
    BR2_PACKAGE_SWUPDATE=y
    # BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE is not set
    BR2_TARGET_ROOTFS_EXT2=y
    BR2_TARGET_ROOTFS_EXT2_4=y
    BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
    BR2_TARGET_UBOOT=y
    BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
    BR2_TARGET_UBOOT_CUSTOM_VERSION=y
    BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2018.01"
    BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG=y
    BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE="board/testo/beagleBoneTesto/uboot.config"
    BR2_TARGET_UBOOT_NEEDS_DTC=y
    # BR2_TARGET_UBOOT_FORMAT_BIN is not set
    BR2_TARGET_UBOOT_FORMAT_IMG=y
    BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
    BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="spl/u-boot-spl.bin"
    BR2_TARGET_UBOOT_SPL=y
    BR2_TARGET_UBOOT_SPL_NAME="MLO"
    BR2_PACKAGE_HOST_DOSFSTOOLS=y
    BR2_PACKAGE_HOST_GENIMAGE=y

    BR2_PACKAGE_HOST_MTOOLS=y


    Next step for me is to port that config on a custom board with the am3358.

    Thanks for your help!!

  • Stefan,

    Stefan Blattmann said:
    I have fixed the problem wit another BeagleBoneBlack and a custom linux build  with buildroot. I seems that my test BeagleBone have a hardware defekt.

    I am glad to hear the issue is solved. I am closing this thread. Please open a new one when you have new any issue/question for your project. Thanks.