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

rp2 usb host: device won't enumerate during sleep() #9905

Open
jepler opened this issue Dec 20, 2024 · 0 comments
Open

rp2 usb host: device won't enumerate during sleep() #9905

jepler opened this issue Dec 20, 2024 · 0 comments
Labels
bug rp2 Both RP2 microcontrollers
Milestone

Comments

@jepler
Copy link
Member

jepler commented Dec 20, 2024

CircuitPython version

d73473b647d76516d15c7c483951afb5cfd1af81 (#9901) on Metro RP2350

Code/REPL

import board, digitalio, time, usb, usb_host
pwr = digitalio.DigitalInOut(board.USB_HOST_5V_POWER)
port = usb_host.Port(board.USB_HOST_DATA_PLUS, board.USB_HOST_DATA_MINUS)
pwr.switch_to_output(True)
usb.core.find(find_all=True)
print("Here are the devices", list(usb.core.find(find_all=True)))
print("Sleeping 3s")
time.sleep(3) 
print("Here are the devices", list(usb.core.find(find_all=True)))
print()
 
print("busy-waiting 3s")
t = time.monotonic_ns()
e = t + 3_000_000_000
while (now := time.monotonic_ns()) < e:
    devices = list(usb.core.find(find_all=True))
    if devices:      
        print(f"busy-waiting found device after {(now-t)*1e-9}s")
        break
    pass  
print("Here are the devices", list(usb.core.find(find_all=True)))
print()

Behavior

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Here are the devices []
Sleeping 3s
Here are the devices []

busy-waiting 3s
busy-waiting found device after 0.0511474s

Description

Something is failing to happen during time.sleep() that prevents an attached USB device from enumerating. When a busy-loop is used, my particular keyboard enumerates in about 1/20s. But even a long sleep of 3s doesn't work.

Additional information

No response

@jepler jepler added the bug label Dec 20, 2024
@dhalbert dhalbert added this to the 9.2.x milestone Dec 22, 2024
@dhalbert dhalbert added the rp2 Both RP2 microcontrollers label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rp2 Both RP2 microcontrollers
Projects
None yet
Development

No branches or pull requests

2 participants