cherry-embedded / CherryUSB

CherryUSB is a tiny and portable USB Stack (device & host) for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.17k stars 249 forks source link

USBH_HUB: Interrupt polling stops after NAK #154

Closed harbaum closed 8 months ago

harbaum commented 8 months ago

The HUB is not polled if the URB is NAK'd. The following line should also wake the thread up on NAK (when nbytes is 0). So this like should simply be removed: https://github.com/cherry-embedded/CherryUSB/blob/ce2a438c991b92db35c4ed70be1d85ab3bc68fac/class/hub/usbh_hub.c#L322

Furthermore, i'd suggest adding a few milliseconds delay before https://github.com/cherry-embedded/CherryUSB/blob/ce2a438c991b92db35c4ed70be1d85ab3bc68fac/class/hub/usbh_hub.c#L629 so the HUB is not polled full throttle.

The value of bInterval should IMHO be used to determine the poll rate.

sakumisu commented 8 months ago

No, nbytes cannot return 0 and no nak status wiil return.

harbaum commented 8 months ago

But it happens:

static void hub_int_complete_callback(void *arg, int nbytes)
{
    struct usbh_hub *hub = (struct usbh_hub *)arg;

    printf("hub_int_complete_callback(%p, %d)\r\n", arg, nbytes);

    if (nbytes > 0) {
        usbh_hub_thread_wakeup(hub);
    }
}

results in:

hub_int_complete_callback(0x62fc9614, 0)

And the hub stops working. Remove that "if()" and the hub keeps working.

sakumisu commented 8 months ago

This is driver bug, you should update cherryusb code.

sakumisu commented 8 months ago

Maybe you use bl616, right? You should update ehci driver with 0.10.2, then you can fix this issue.

harbaum commented 8 months ago

I've updated to 10.2 and the problem seems to be gone. Thanks a lot!

Edit: And yes, I am talking about bl616