Skip to content

Initial simulated disconnect causes problems with usb hub #37

@Sod-Almighty

Description

@Sod-Almighty

I have a specific USB hub that refuses to detect any device using the V-usb example code. The device doesn't show up in Windows Device Manager or Linux lsusb. I have narrowed it down to the following lines of code in main.c:

usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0;
while(--i){             /* fake USB disconnect for > 250 ms */
    wdt_reset();
    _delay_ms(1);
}

If I remove that piece of code, the problem goes away. The problem also goes away if I use a different hub, or if I connect directly to the computer without a hub, or if I first plug the device into the hub and then connect the hub to the computer.

My theory is that this "disconnection" is not actually happening. So when the hub detects the device insertion, and asks it for identification, it gets no response because the device is still within this arbitrary delay period. And so it gives up.

So I guess my questions are:

  1. What purpose does this "enforce re-enumeration" process serve? What problem is it intended to solve?
  2. Why might it be causing the device to fail to enumerate? Why does it fail to perform as intended?
  3. Am I okay to just remove the offending piece of code? Or can I change it in some way to work better?

The device I'm flashing is an ATmega88, which happens to be on a USBasp clone board (because it was convenient). The schematic is:

schematic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions