[U-Boot] mpc5121 - EHCI problems with some (but not all) USB hubs

Dear All,
I am attempting to integrate the USB on the Freescale mpc5121 processor on the mpc5121ads board from Silicon Turnkey for upgrades of kernel, u-boot etc.
I have succeeded in integrating Francesco Rendine 's EHCI patch for the MPC5121 (see http://lists.denx.de/pipermail/u-boot/2009-June/055021.html ) and I have the general functionality of upgrading from a USB stick working straight from the USB, or through some (but not all) USB hubs.
However, I am having problem using the driver with some (but not all) USB hubs. I have some USB hubs that work "out of the box", but I have other hubs that cause booting u-boot to hang after attempting to initialise the USB. The ones that do work, and the ones that fail all fail in the same place the great majority of the time (they succeed very occasionally).
I have traced the hang to the following lines in drivers/usb/host/ehci-hcd.c:
/* Wait for TDs to be processed. */ ts = get_timer(0); vtd = td; do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); if (!(token & 0x80)) break;
/* This was my own line I added to check. The get_timer(ts) always returns 0 and never exits the loop */ debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); } while (get_timer(ts) < CONFIG_SYS_HZ);
One of the hubs that fails is part of a 4-port USB-Serial converter (it's a hub to 4 FTDI chips) and is described as: Manufacturer ALCOR Product Generic USB Hub
Another of the (mostly) failing hubs is a generic "i-rocks" brand: Manufacturer Product USB2.0 Hub
It happens even when the hubs are self-powered, or connected through a hub that is itself powered externally (we've had power problems from the mpc5121ads board's USB in the past).
The hubs (and USB-Serial adaptors) are perfectly recognised under Linux, if USB is not started in U-Boot and we proceed to a normal Linux boot sequence.
Is anyone able to suggest what might be going wrong, or some further testing that may help reveal the problem?
Best regards Damien Dusha.

Dear all,
I am following up on a post I made earlier in the week on U-Boot hanging (infinite looping) in a particular part of drivers/usb/host/ehci-hcd.c . I also reported that it works for some hubs and not for others.
I have been attempting to debug this problem and I have found something of interest. In one instance, one of the hubs that work has the _same_ chipset of another hub that doesn't work - it has the same product ID and vendor ID. However, there are what looks to be some configuration differences between the devices.
I have attached below what Linux reports for lsusb for both hubs and I have highlighted the differences. Are these differences likely to have any bearing on the operation of the hub? Is there any other testing for information that I can supply that may assist in helping to solve the issue?
Best regards Damien Dusha.
For the "broken" hub (with highlighted differences):
Bus 003 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused -----------------> bDeviceProtocol 0 Full speed (or root) hub <----------------- DIFFERENT bMaxPacketSize0 64 idVendor 0x05e3 Genesys Logic, Inc. idProduct 0x0608 USB-2.0 4-Port HUB bcdDevice 7.02 iManufacturer 0 iProduct 1 USB2.0 Hub iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA 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 0x0001 1x 1 bytes ---------------> bInterval 255 <----------------------- DIFFERENT Hub Descriptor: bLength 9 bDescriptorType 41 nNbrPorts 4 ------> wHubCharacteristic 0x00e9 <--------------- DIFFERENT ----> Per-port power switching ---> Per-port overcurrent protection ---> Port indicators bPwrOn2PwrGood 50 * 2 milli seconds bHubContrCurrent 100 milli Ampere DeviceRemovable 0x00 PortPwrCtrlMask 0xff Hub Port Status: Port 1: 0000.0100 power Port 2: 0000.0100 power Port 3: 0000.0100 power Port 4: 0000.0100 power Device Qualifier (for other device speed): bLength 10 bDescriptorType 6 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused ------------> bDeviceProtocol 1 Single TT <------------------------ DIFFERENT bMaxPacketSize0 64 bNumConfigurations 1 Device Status: 0x0001 Self Powered
Whereas on the working version of a hub with the same product and vendor ID:
Bus 001 Device 015: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 1 Single TT <---------- DIFFERENT bMaxPacketSize0 64 <snip> Hub Descriptor: bLength 9 bDescriptorType 41 nNbrPorts 4 wHubCharacteristic 0x00e0 <------------- DIFFERENT Ganged power switching Ganged overcurrent protection TT think time 32 FS bits Port indicators <snip> Device Qualifier (for other device speed): bLength 10 bDescriptorType 6 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 0 Full speed (or root) hub <------------ DIFFERENT bMaxPacketSize0 64 bNumConfigurations 1
On Tue, Sep 22, 2009 at 4:32 PM, Damien Dusha d.dusha@gmail.com wrote:
Dear All,
I am attempting to integrate the USB on the Freescale mpc5121 processor on the mpc5121ads board from Silicon Turnkey for upgrades of kernel, u-boot etc.
I have succeeded in integrating Francesco Rendine 's EHCI patch for the MPC5121 (see http://lists.denx.de/pipermail/u-boot/2009-June/055021.html ) and I have the general functionality of upgrading from a USB stick working straight from the USB, or through some (but not all) USB hubs.
However, I am having problem using the driver with some (but not all) USB hubs. I have some USB hubs that work "out of the box", but I have other hubs that cause booting u-boot to hang after attempting to initialise the USB. The ones that do work, and the ones that fail all fail in the same place the great majority of the time (they succeed very occasionally).
I have traced the hang to the following lines in drivers/usb/host/ehci-hcd.c:
/* Wait for TDs to be processed. */ ts = get_timer(0); vtd = td; do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); if (!(token & 0x80)) break;
/* This was my own line I added to check. The get_timer(ts) always returns 0 and never exits the loop */ debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); } while (get_timer(ts) < CONFIG_SYS_HZ);
One of the hubs that fails is part of a 4-port USB-Serial converter (it's a hub to 4 FTDI chips) and is described as: Manufacturer ALCOR Product Generic USB Hub
Another of the (mostly) failing hubs is a generic "i-rocks" brand: Manufacturer Product USB2.0 Hub
It happens even when the hubs are self-powered, or connected through a hub that is itself powered externally (we've had power problems from the mpc5121ads board's USB in the past).
The hubs (and USB-Serial adaptors) are perfectly recognised under Linux, if USB is not started in U-Boot and we proceed to a normal Linux boot sequence.
Is anyone able to suggest what might be going wrong, or some further testing that may help reveal the problem?
Best regards Damien Dusha.

Damien Dusha wrote:
Dear All,
I am attempting to integrate the USB on the Freescale mpc5121 processor on the mpc5121ads board from Silicon Turnkey for upgrades of kernel, u-boot etc.
I have succeeded in integrating Francesco Rendine 's EHCI patch for the MPC5121 (see http://lists.denx.de/pipermail/u-boot/2009-June/055021.html ) and I have the general functionality of upgrading from a USB stick working straight from the USB, or through some (but not all) USB hubs.
However, I am having problem using the driver with some (but not all) USB hubs. I have some USB hubs that work "out of the box", but I have other hubs that cause booting u-boot to hang after attempting to initialise the USB. The ones that do work, and the ones that fail all fail in the same place the great majority of the time (they succeed very occasionally).
I have traced the hang to the following lines in drivers/usb/host/ehci-hcd.c:
/* Wait for TDs to be processed. */ ts = get_timer(0); vtd = td; do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); if (!(token & 0x80)) break;
/* This was my own line I added to check. The
get_timer(ts) always returns 0 and never exits the loop */ debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); } while (get_timer(ts) < CONFIG_SYS_HZ);
I think that the git_timer is not proprer implemented here and so what happen if you go out the busy loop and return an error to the message? Can you try on another hardware with u-boot?
One of the hubs that fails is part of a 4-port USB-Serial converter (it's a hub to 4 FTDI chips) and is described as: Manufacturer ALCOR Product Generic USB Hub
Another of the (mostly) failing hubs is a generic "i-rocks" brand: Manufacturer Product USB2.0 Hub
It happens even when the hubs are self-powered, or connected through a hub that is itself powered externally (we've had power problems from the mpc5121ads board's USB in the past).
The hubs (and USB-Serial adaptors) are perfectly recognised under Linux, if USB is not started in U-Boot and we proceed to a normal Linux boot sequence.
Is anyone able to suggest what might be going wrong, or some further testing that may help reveal the problem?
Best regards Damien Dusha. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On Fri, Sep 25, 2009 at 2:04 AM, Michael Trimarchi trimarchi@gandalf.sssup.it wrote:
Damien Dusha wrote:
Dear All,
I am attempting to integrate the USB on the Freescale mpc5121 processor on the mpc5121ads board from Silicon Turnkey for upgrades of kernel, u-boot etc.
I have succeeded in integrating Francesco Rendine 's EHCI patch for the MPC5121 (see http://lists.denx.de/pipermail/u-boot/2009-June/055021.html ) and I have the general functionality of upgrading from a USB stick working straight from the USB, or through some (but not all) USB hubs.
However, I am having problem using the driver with some (but not all) USB hubs. I have some USB hubs that work "out of the box", but I have other hubs that cause booting u-boot to hang after attempting to initialise the USB. The ones that do work, and the ones that fail all fail in the same place the great majority of the time (they succeed very occasionally).
I have traced the hang to the following lines in drivers/usb/host/ehci-hcd.c:
/* Wait for TDs to be processed. */ ts = get_timer(0); vtd = td; do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); if (!(token & 0x80)) break;
/* This was my own line I added to check. The get_timer(ts) always returns 0 and never exits the loop */ debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); } while (get_timer(ts) < CONFIG_SYS_HZ);
I think that the git_timer is not proprer implemented here and so what happen if you go out the busy loop and return an error to the message? Can you try on another hardware with u-boot?
Yesterday, we tried the following:
/* Add long delay before entering the loop */ udelay(10000);
/* Wait for TDs to be processed. */ /* Remove the loop and exit immediately. Do not wait for timer */ // ts = get_timer(0); //vtd = td; //do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); // if (!(token & 0x80)) // break;
// debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); //} while (get_timer(ts) < CONFIG_SYS_HZ);
With the following result: * If only "working" hubs and a USB stick is attached, it will do our auto upgrade sequence as normal. * If a "broken" hub is present, U-Boot will report that the devices are found, but will not actually read a USB stick attached to the hub. It will not read a stick, even if the stick is attached to a "working" hub, and the "broken" hub is cascaded off the working hub.
Unfortunately, I have no other EHCI hardware available - only a 5200LITE and a AVR32 dev board in the back of the cupboard somewhere.
-- Damien.

Hi Michael,
On Fri, Sep 25, 2009 at 9:19 AM, Damien Dusha d.dusha@gmail.com wrote:
On Fri, Sep 25, 2009 at 2:04 AM, Michael Trimarchi trimarchi@gandalf.sssup.it wrote:
Damien Dusha wrote:
Dear All,
I am attempting to integrate the USB on the Freescale mpc5121 processor on the mpc5121ads board from Silicon Turnkey for upgrades of kernel, u-boot etc.
I have succeeded in integrating Francesco Rendine 's EHCI patch for the MPC5121 (see http://lists.denx.de/pipermail/u-boot/2009-June/055021.html ) and I have the general functionality of upgrading from a USB stick working straight from the USB, or through some (but not all) USB hubs.
However, I am having problem using the driver with some (but not all) USB hubs. I have some USB hubs that work "out of the box", but I have other hubs that cause booting u-boot to hang after attempting to initialise the USB. The ones that do work, and the ones that fail all fail in the same place the great majority of the time (they succeed very occasionally).
I have traced the hang to the following lines in drivers/usb/host/ehci-hcd.c:
/* Wait for TDs to be processed. */ ts = get_timer(0); vtd = td; do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); if (!(token & 0x80)) break;
/* This was my own line I added to check. The get_timer(ts) always returns 0 and never exits the loop */ debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); } while (get_timer(ts) < CONFIG_SYS_HZ);
I think that the git_timer is not proprer implemented here and so what happen if you go out the busy loop and return an error to the message? Can you try on another hardware with u-boot?
Today we've done a little more testing and indeed, the timer wasn't ticking as expected. In this case, the fix was quite simple - I was doing my auto-update routunes (which initialises the USB) in the board-specific misc_init_r(void) function (which a couple of others boards did), which, after studying lib_ppc/board.c is called _before_ interrupt_init(). Hence, interrupts were not enabled and therefore the timer never ticked.
As a result, I've moved the auto-update routines to a last_stage_init(void) function, which does it as the last thing before getting into the main loop. It's interesting that configuring USB doesn't bring it up somewhere in that init sequence of board_init_r, but that's another question for another day.
While this solves the "hanging" issue previously reported, it does not yet solve the hub bring-up problem. that I have previously reported although I now have some new information from testing. * If I cascade the "working" hubs, it will recognise the USB drive and update as expected.\ * If I connect one of the USB 1.1 hubs (which are 4-port USB-Serial devices) through a "working" hub, it will sometimes recognise the USB stick, sometimes not, and sometimes appear to hang (or at least until my patience runs out and I reset the board), and seems to be order dependant (i.e. which ports on the "working" hub they are connected to), though I am still gathering evidence on that point. * If I connect more than one of the 4-port USB-Serial converters (USB 1.1 hubs), through a "working" hub, I have only seen a hang and/or failed recognitions. * If I connect the "broken" USB high-speed hub anywhere in the system, I get the following error messages:
USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... USB device not accepting new address (error=20) 4 USB Device(s) found
or
Entering "do_auto_update" USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... 3 USB Device(s) found 0 Storage Device(s) found
or, in one instance, it actually performs an upgrade:
USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... 4 USB Device(s) found 1 Storage Device(s) found Interface: USB Device 0: Vendor: LEXAR Rev: 1100 Prod: JD FIREFLY Type: Removable Hard Disk Capacity: 960.0 MB = 0.9 GB (1966080 x 512) Partition 1: Filesystem: FAT16 "NO NAME " reading pre.img .
In short, it's not at all reliable and I have some anecdotal evidence it has to do with the ordering of the ports, though I will try to gather more evidence to effect over the next little while.
I hope this information can help.
-- Damien

Damien Dusha wrote:
Hi Michael,
On Fri, Sep 25, 2009 at 9:19 AM, Damien Dusha d.dusha@gmail.com wrote:
On Fri, Sep 25, 2009 at 2:04 AM, Michael Trimarchi trimarchi@gandalf.sssup.it wrote:
Damien Dusha wrote:
Dear All,
I am attempting to integrate the USB on the Freescale mpc5121 processor on the mpc5121ads board from Silicon Turnkey for upgrades of kernel, u-boot etc.
I have succeeded in integrating Francesco Rendine 's EHCI patch for the MPC5121 (see http://lists.denx.de/pipermail/u-boot/2009-June/055021.html ) and I have the general functionality of upgrading from a USB stick working straight from the USB, or through some (but not all) USB hubs.
However, I am having problem using the driver with some (but not all) USB hubs. I have some USB hubs that work "out of the box", but I have other hubs that cause booting u-boot to hang after attempting to initialise the USB. The ones that do work, and the ones that fail all fail in the same place the great majority of the time (they succeed very occasionally).
I have traced the hang to the following lines in drivers/usb/host/ehci-hcd.c:
/* Wait for TDs to be processed. */ ts = get_timer(0); vtd = td; do { /* Invalidate dcache */ ehci_invalidate_dcache(&qh_list); token = hc32_to_cpu(vtd->qt_token); if (!(token & 0x80)) break; /* This was my own line I added to check. The
get_timer(ts) always returns 0 and never exits the loop */ debug("get_timer: %d, CONFIG_SYS_HZ: %d\n", get_timer(ts), CONFIG_SYS_HZ); } while (get_timer(ts) < CONFIG_SYS_HZ);
I think that the git_timer is not proprer implemented here and so what happen if you go out the busy loop and return an error to the message? Can you try on another hardware with u-boot?
Today we've done a little more testing and indeed, the timer wasn't ticking as expected. In this case, the fix was quite simple - I was doing my auto-update routunes (which initialises the USB) in the board-specific misc_init_r(void) function (which a couple of others boards did), which, after studying lib_ppc/board.c is called _before_ interrupt_init(). Hence, interrupts were not enabled and therefore the timer never ticked.
As a result, I've moved the auto-update routines to a last_stage_init(void) function, which does it as the last thing before getting into the main loop. It's interesting that configuring USB doesn't bring it up somewhere in that init sequence of board_init_r, but that's another question for another day.
While this solves the "hanging" issue previously reported, it does not yet solve the hub bring-up problem. that I have previously reported although I now have some new information from testing.
- If I cascade the "working" hubs, it will recognise the USB drive
and update as expected.\
- If I connect one of the USB 1.1 hubs (which are 4-port USB-Serial
devices) through a "working" hub, it will sometimes recognise the USB stick, sometimes not, and sometimes appear to hang (or at least until my patience runs out and I reset the board), and seems to be order dependant (i.e. which ports on the "working" hub they are connected to), though I am still gathering evidence on that point.
- If I connect more than one of the 4-port USB-Serial converters
(USB 1.1 hubs), through a "working" hub, I have only seen a hang and/or failed recognitions.
- If I connect the "broken" USB high-speed hub anywhere in the
system, I get the following error messages:
USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... USB device not accepting new address (error=20) 4 USB Device(s) found
or
Entering "do_auto_update" USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... 3 USB Device(s) found 0 Storage Device(s) found
or, in one instance, it actually performs an upgrade:
USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... 4 USB Device(s) found 1 Storage Device(s) found Interface: USB Device 0: Vendor: LEXAR Rev: 1100 Prod: JD FIREFLY Type: Removable Hard Disk Capacity: 960.0 MB = 0.9 GB (1966080 x 512) Partition 1: Filesystem: FAT16 "NO NAME " reading pre.img .
Looking at linux:
we have phy_mode = FSL_USB2_PHY_UTMI_WIDE
portsc |= PORT_PTS_PTW;
ehci_writel(ehci, portsc, &ehci->regs->port_status[0]);
if (!strcmp(getenv("usb_phy_type"), "utmi")) + out_le32(&(hcor->or_portsc[0]), PORT_PTS_UTMI); + else + out_le32(&(hcor->or_portsc[0]), PORT_PTS_ULPI);
In this case you must config as a PORT_PTS_PTW so maybe add a if else
Michael
In short, it's not at all reliable and I have some anecdotal evidence it has to do with the ordering of the ports, though I will try to gather more evidence to effect over the next little while.
I hope this information can help.
-- Damien
participants (2)
-
Damien Dusha
-
Michael Trimarchi