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.

AM335X BeagleBone Black USB0 HOST U-BOOT

Hi All,

I am trying to use USB0 to detect my USB Thumb Drive in U-Boot prompt but no luck. I can detect USB Thumb Drive on USB1 but not USB0. Can anyone give me some tips to make it become HOST from Peripheral?

Here are the changes on Hardware and Software.

Hardware:

Grounded ID-pin and supply 5V to USB0_VBUS.

Software:

Change the USB0_MODE from MUSB_PERIPHERAL to MUSB_HOST

Note: I have tested the Hardware modification where I can detect USB Thumb Drive in Kernel Space when it is fully booted up.

  • Hi Zhi,

    On the hardware side it's not enough to ground the ID-pin. 5V should be provided on the USB connector through a power switch controlled by USB0_DRVVBUS. USB0_VBUS should be connected to the USB connector supply. In short - you will need to repeat the USB1 schematic.

  • Correct. I have done what you have just mentioned. I have also verify the hardware side by the Kernel. I manage to get the Kernel detect the USB Thumb Drive on USB0. 

    But I have no idea how to make it detect in U-boot

  • Zhi Yong,

    Which Linux SDK version do you use?

    When modify uboot config to set USB0 to host mode, you also have to set USB1 to peripheral mode. In uboot only ONE USB port is allowed to be in host mode. Following is the patch which has been tested in Linux SDK 5.7.0.0 uboot.

    diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
    index 311765d..f0c9b94 100644
    --- a/include/configs/am335x_evm.h
    +++ b/include/configs/am335x_evm.h
    @@ -421,9 +421,9 @@
     #define CONFIG_USB_GADGET_VBUS_DRAW    2
     #define CONFIG_MUSB_HOST
     #define CONFIG_AM335X_USB0
    -#define CONFIG_AM335X_USB0_MODE        MUSB_PERIPHERAL
    +#define CONFIG_AM335X_USB0_MODE        MUSB_HOST
     #define CONFIG_AM335X_USB1
    -#define CONFIG_AM335X_USB1_MODE MUSB_HOST
    +#define CONFIG_AM335X_USB1_MODE MUSB_PERIPHERAL
     
     #ifdef CONFIG_MUSB_HOST
     #define CONFIG_CMD_USB
    
  • Hi  Bin,

    Thank you for the tips but may I know why this happen? Is this the U-Boot's limitation?

    I am using the U-Boot from Robert Nilson but I am familiar to your patch. I shall try your patch tomorrow. I assume this shall work flawlessly. 

  • Zhi Yong,

    Yes, it is uboot code limitation. in the last time I was debugging this issue, the uboot usb init code looks as following.

    int host_port;  /* global var */
    
    for (int i; i < 2; i++) {
        if (USB[i] port mode is MUSB_HOST)
            host_port = i;
    }
    

    You can see, if both ports are set to host mode, the global variable host_port is always pointing to USB1.

  • Thank you Bin for your kindness help! I have finally made it works! 

    May I know where can I found those snipe code that you have attached?

  • Zhi Yong,

    In the Linux SDK 6.0 uboot source, musb_register() in drivers/usb/musb-new/musb_uboot.c initializes the static variable 'host'.

    Then arch_misc_init() in arch/arm/cpu/armv7/am33xx/board.c calls musb_register() to register USB0 & USB1 in sequence, so at the end the variable 'host' would point to USB1 if both USB0 and USB1 were defined as MUSB_HOST.

  • Bin,

    I got it! Yes, you are right. Another issue I have encounter while I was trying to use "usb reset" to detect my USB Thumb Drive. The issue is, first time using the command and u-boot managed to detect my USB but file on the second try until I have to restart the BBB. 

    Any explanation on this?

  • Zhi Yong,

    I don't see this issue with AM335x GPEVM with uboot from SDK6.0 and SDK7.0, 'usb reset' works multiple times without power cycle the board. I will try to find a BBB board to see if I can replicate the issue.

    What version of uboot/SDK do you use? What revision of BBB?

  • Hi Bin,

    If my memory serve me right, I did not encounter this issue on USB1. But when I modified U-boot to make USB0 to be host then it only appears.

  • Zhi Yong,

    The BBB USB0 port is in peripheral-only mode because its USB0_ID pin is floating to the receptacle and USB0_VBUS pin does not connect to any on-board power source.

    What hw mod have you done on BBB to make its USB0 port working in host mode? I am wondering if it is somehow related to the first VBUS sensing we discussed before.

  • Hi Bin,

    I have grounded the USB0_ID pin from floating and permanently supply USB0_VBUS with 5V DC. After your patch in U-boot, it is able to detect USB Thumb Drive. You could be right, it might be affected by the patch?

    Initially I though USB0_ID pin is design to determine the USB to behave like a HOST/Periphera but seems like the VBUS has replace its role?

  • Zhi Yong,

    If USB0_VBUS is directly connected to 5V, I believe you also need to patch the u-boot code to clear the bit-19, as we did in the kernel driver, though I never tested it in uboot.

    USBx_ID pin plays an important role in determine the operation mode, but the VBUS status is also another factor. You can get more detail about this from the OTG Specs.