-
Notifications
You must be signed in to change notification settings - Fork 476
Bluetooth hci_power_control() interferes with Adafruit TinyUSB #2022
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
Comments
Very odd indeed! I was able to repro the failure with the combined sketch below:
My first guess was there was a linking order issue and the core's USB setup was overriding the Adafruit one, but I see the
Moving the BT startup afterwards also works, as you reported. I also instrumented things and At this point there's actually no code from the core here that's being invoked in these paths. I think you'll need to move this to their repo since they understand what's going on to reset the USB interface on the |
Yup, the Adafruit library of TinyUSB is not signaling the PC to re-read the descriptor when this happens and hence the PC will keep the old one. If you cause the USB bus to rescan, the device does show up properly:
(my usbreset for Linux is
So this is a TinyUSB issue most likely. Adafruit is making a new descriptor and informing TinyUSB about it, but for some reason TinyUSB can't tell the PC about it. Might want to ping them with this info, it may be a simple fix... |
Thanks a lot for looking into this! I'll open an issue with the Adafruit library. |
So this is not actually a problem in the library or the core. It's a race condition. The host device has enumerated the USB stack by the time the HCI comes up, leading to the MIDI (or other) addition not being recognized. adafruit/Adafruit_TinyUSB_Arduino#454 After
The Adafruit guys had this on all their examples because of the ESP-S3, and you need it here on the RP2040 in your code, too. |
Hi,
I'm trying to use Bluetooth LE together with the Adafruit TinyUSB library. When initializing the Bluetooth stack first, this breaks the USB code.
I've narrowed it down to the call to the
hci_power_control(HCI_POWER_ON)
function. Here's a minimal example:sketch.ino
power_on_hci.cpp (second tab)
You can change the
#if 1
to#if 0
to see the difference: when leaving out the call tohci_power_control(HCI_POWER_ON)
, the Pico W correctly show up as a USB MIDI device; when including the call tohci_power_control(HCI_POWER_ON)
, it only shows up as a serial port. (See the difference between the USB descriptor at the bottom of this post.)Version and hardware:
earlephilhower/arduino-pico
3.7.2rp2040:rp2040:rpipicow:usbstack=tinyusb,ipbtstack=ipv4btcble
Context: I'm the developer of the https://github.com/tttapa/Control-Surface library, and a user reported this issue: tttapa/Control-Surface#1014 (reply in thread).
The full BLE code used there can be found here: https://github.com/tttapa/Control-Surface/blob/d6a5fb1313f8e483b13619dba1fa80d0ec09ca62/src/MIDI_Interfaces/BLEMIDI/BTstack/gatt_midi.cpp (although I don't think this really matters for this issue, simply calling
hci_power_control
suffices to reproduce the issue).Difference in USB descriptors between
#if 0
and#if 1
(click to open)The text was updated successfully, but these errors were encountered: