• Resolved

LM3S3748 USB HOST supporting Hub

I am working connect USB Keyboard and USB Mouse to LM3S3748 USB Host at the same time using USB HUB.

I can find USB Keyboard and  Mouse sample code, there are no hub sample code.

Could you provide hub sample code?

  • We can help with using the USB hub functions.  The first thing to be aware of is that the LM3S3748 device has an erratum for USB hub operation with low-speed USB devices (Errata 12.5).  Hub will only work on devices with date code 0x1A or later.   Does your target device have a 0x1A or later date code?

    Jonathan Guy

  • In reply to Jonathan Guy:

    If you want to try enable the hub code you will need to add a small bit of code to your application:

    // The size of the host controller's memory pool in bytes.

    // The memory pool to provide to the hub driver. This pool is used to hold the
    // configuration descriptors of the devices attached to the hub. It must be
    // sized to be at least
    // (MAX_USB_DEVICES * (largest expected configuration descriptor)) bytes.
    unsigned char g_pucHubPool[HUB_POOL_SIZE];
    // The instance data for the hub, this is internal data and should not be
    // accessed by the application.
    tHubInstance g_HubInstance;

    // This is a null function will get events from the hub.
    unsigned long
    HubCallback(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgParam,
    void *pvMsgData)
    In main() before HCDInit() call
    // Open a hub instance and provide it with the memory required to hold
    // configuration descriptors for each attached device.
    USBHHubOpen(HubCallback, g_pucHubPool, HUB_POOL_SIZE, &g_HubInstance, 1);
    The remaining calls to initialize the mouse and keyboard should remain just as in the normal examples.  The errata still applies and if you have an older part you will see intermittent behavior when using the low speed devices.  
    Please note that nearly all evaluation boards will have the older devices and will be subject to the errata.
  • In reply to Stellaris Paul:

    Congratulation to hub support !!
    It should produce huge advantage to Stellaris among Cortex-M3/M4 MCUs.

    I noticed a couple of minor timing problem in usbhhub.c in the latest StellarisWare 8555.

    The USB2.0 spec defines these timing around device connection - bus reset in "USB 2.0 Connect Timing ECN.pdf", distributed with USB2.0 spec zip file,

    Here are excerpts from "USB 2.0 Connect Timing ECN.pdf"

    delta-T4 (Tcon_rst)
    This is a debounce interval with a minimum duration of 100 ms that is provided by USB System Software. It ensures that the electrical and mechanical connection is stable before software attempts to reset the attached device...

    delta-T6 (Trstrcy)
    The USB System software guarantees a minimum of 10 ms for reset recovery. Peripheral response to any bus transactions addressed to the default device address during the reset recovery time is undefined.

    Any hub doesn't provide these timing. Host stack is responsible to ensure these timing.

    In the current usbhhub.c, USBHHubMain() orders bus reset to hub immediately after the detection of device connection (HUB_PORT_STATUS_DEVICE_PRESENT), in this calling sequence.
    HubDriverDeviceConnect() -> HubDriverDeviceReset() -> HubSetPortFeature( HUB_FEATURE_PORT_RESET )

    Above delta-T4 delay comes here, between the detection of connection and bus reset order.

    Also after seeing HUB_PORT_CHANGE_RESET, USBHHubMain() starts enumeration immediately in this calling sequence.
    HubDriverReset() -> USBHCDHubDeviceConnected()

    Above delta-T6 delay is inserted here.

    Some devices with MCU are still running their startup initialization when they assert D+ (D-) pull-up. Especially, with fixed D+ (D-) pull-up.  Such devices misses bus reset if host would issue bus reset too early. Delta-T4 saves such devices.

    Hope this help.


  • In reply to Stellaris Paul:

    I added above code adviced from Paul-san and testing.

    Also I added delta-T4 and T6 delay adviced from Chinzei-san at USBHHubMain() in usbhhub.c,

    When I connect only HS HUB, "UARTprintf("Unsupported Device Connected\n")" is come on terminal soft.

    Date code on the LM3S3743 is IQC50A0D0, so I understand LS HID device under HUB will fail

    to connect.

    I will continue investigation.

    If you miss something, please let me know.

  • In reply to Tsuneo Chinzei:

    Glad to hear that it is working for you.  

    I will open an issue for the connect timing with the hub so that we can look into it.

  • In reply to Stellaris Paul:

    I found the reason hub driver is not roaded.

    Fllowing code is need to add,

    static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
     &g_USBHIDClassDriver, &g_USBHubClassDriver,&g_sUSBEventDriver

    I supposed FS Keyboard under the hub is not work, But is working now.

    Key code come on lcd display and windows serial terminal soft..


  • In reply to sakaken:

    Sorry, I forgot about that.  That is what loads the Hub driver so that the USB library can work with hubs.

  • In reply to Stellaris Paul:

    Now I could support USB Host-Hub-Keyboard and Mouse.

    I need to support multi connection hub, Host-Hub-Hub-Keyboard and Mouse.

    Could you advice how to modify usbhhub.c?

  • In reply to sakaken:

    Any of you can explain how Ican add delta T4 and delta T7 delays?? my hub does not work lways. I think the reason of this problem is timing, is it right??

  • In reply to betulturk_deu_muh:

    Betul, your problem is more than likely due to the errata on hubs with low speed devices.  You will need to check the date code listed in the errata for your part to determine if you can run with a hub and low speed devices.