Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial simulated disconnect causes problems with usb hub #37

Open
Sod-Almighty opened this issue Jan 12, 2024 · 0 comments
Open

Initial simulated disconnect causes problems with usb hub #37

Sod-Almighty opened this issue Jan 12, 2024 · 0 comments

Comments

@Sod-Almighty
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant