-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Have to Unplug / Re-Plug USB Host Keyboard #8886
Comments
I tried toggling that pin in boot.py as well with this code:
But it still results in the same |
With #8937 you will be able to use the USB_HOST_5V_POWER pin from code |
@hathach How do we initialize the USB host stuff so that we can see devices that are already attached? Do we need to toggle power or is there a TinyUSB bug here? |
when initializing usb host, it should reset controller, any current attached device should go to enumeration process as newly plugged. Otherwise, it is a bug with controller, in this case is the pio-usb controller. Let me try to reproduc this first, @FoamyGuy do you have any quick code.py to test with. |
@hathach during this test I was not using any specific code. I think just the default The code itself wasn't trying to interact with the keyboard. I was trying to use the keyboard to interact with the REPL after the code finished executing. |
@hathach CircuitPython 9 will automatically use a connected keyboard as input. This is done by the supervisor using the TinyUSB host HID driver. So, no specific code.py is needed on the RP2040 USB host feather because the |
@jepler I am able to reproduce the issue with my generic low speed usb keyboard. I will try to find an full speed usb to test with as well, just curious if your keyboard is low speed or full speed ? they are handled differently in pio-usb. |
I believe my keyboard is low speed as well. |
I tested with this firmware version from S3
With a basic With this version loaded I still don't seem to be able to interact with the REPL using the keyboard plugged in to the USB A Host port until I unplug / re-plug it. I wasn't certain if the build that has PR8999 in it's name includes that PR or not for certain, so I also tried what is the absolute newest build listed in S3 at the time of testing which was:
And I see the same behavior with that one. Still unable to interact unless I unplug / re-plug the keyboard. I did notice with these new versions that while I am spamming buttons on the keyboard to test if they will be recognized occasionally all 3 indicator LEDs on the keyboard light up for about half a second and then turn back off. Which does also occur when you first plug in the keyboard. It appears to me that maybe it's attempting to get connected and it manages to make those lights turn on for a second as if it had connected, but afterward the button presses still have no reaction in the REPL. The timing of those lights turning on when they do doesn't seem consistent, sometimes they turn on within only a few seconds of pressing keys to test, but other times they don't turn on for 30 seconds or longer. |
All of my testing was performed with a Feather RP2040 USB Host (https://www.adafruit.com/product/5723) and it has been plugged into an Ubuntu PC for power and serial communication during my testing. |
I also tested with both feather usb host + pico (with testbed brain) and a Linux PC. It probably has something to do with keyboard. Can you enable the |
@hathach I can try but I'm not sure how to do that. Is there documentation for that process somewhere I could reference? Or if not separately documented somewhere can you tell me where to put Once that is enabled how are they logs accessed? do they just get sent out over the serial line? so if I'm connected to REPL / serial console I will see them? Or I need to connect to some other port or something for those? |
We have circuitpython/py/circuitpy_mpconfig.h Line 483 in 60bd748
|
I tried adding this at the end of this file: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.h
I was able successfully make a build but as far as I can tell enabling the debugging did not work. When the device connects to the PC there is only 1 serial port and it's the standard serial output / REPL. If I enable the USB Console line with boot.py then it typically appears as /dev/ttyACM1, I'm assuming that is how it would connect for debugging too, but no other ports other than the standard ttyACM0 appear. I also tried
Because @hathach message mentioned Honestly though I think my local environment or builds might be messed up anyway. I'm noticing that if I build from main and then flash it to my device that USB Host never seems to work. No matter if I un-plug and re-plug the REPL will never recognize the keyboard. I tried downloading the absolute newest from S3 and on that one I the keyboard does get recognized and works correctly after an un-plug / re-plug (which is same behavior I see with RC1). I'm not sure why but my local builds seem to have broken USB Host in general beyond the debug not exposing the extra port. If someone else can make and share a debug build that is known to have working USB Host and debugging enabled I could download it and flash it to my device and share the resulting output. |
Here is a build for the rp2040 usb host feather. The debug statements are transmitted out the TX pin. Here is my debug output that shows the same issue. I've marked where I unplugged and replugged the device.
|
@tannewt thanks for the log, I will try to find other keyboards to test with, and also look more at the log. |
Retest after #9571 |
CircuitPython version
Code/REPL
Behavior
I've tested various states of powering on the microcontroller with and without the USB Keyboard plugged in to the host port and found that if the microcontroller powers up with the keyboard plugged in, the keyboard will not work until it has been unplugged and re-plugged.
I tested the following scenarios:
Description
No response
Additional information
I noticed that there is a
board.USB_HOST_5V_POWER
pin defined in this device. I attempted to use digitalio to toggle it off and back on to simulate the unplug / re-plug action but it raised an error about pin in use. I only tested from code.py but will attempt from boot.py later.If it is possible to toggle that pin and have it serve the same purpose as unplugging and re-plugging then user code would have a way to work around this issue without needing the explicit action from the human user to unplug and re-plug.
The text was updated successfully, but these errors were encountered: