Open kice opened 3 years ago
Hi, thanks for your feedback
Both BLE and USB Host uses group timers so it'll always crash.
It'll probably crash with WiFi too, best test case scenario was using SPI for SD and TFT in separate tasks with a semaphore.
This library is just a wrapper over a proof of concept anyway, for real USB project I use an ESP32-S2 instead, it doesn't have the dual core but tinyusb support is getting better every day.
I knew that ESP32 has USB support, but without BLE is not what I want. I do have an ESP32-S3 on the way, but before that (but also third parties ESP32-S3 hit the market ) I would like to see if we could avoid the group timer crash.
As you can guess, I want to make a BT keyboard using normal wired USB keyboard. I assume if I use software group timer should be fine? But not sure what's the draw back for it since I don't have any experience with esp 32.
Or maybe use macros to hook into the BLE keyboard library if it is just software compatibility issue.
have you tried to play with USB_SOFT_HOST::TimerPause()
and USB_SOFT_HOST::TimerResume()
?
I am a complete noob here but can't we switch to the other Timer Group since there are two? If BLE uses timer_group_0, USH can use the timer_group_1, can't it? Like on here author mentions he had to switch to timer group 1 to prevent crashes: https://ojdip.net/2020/11/esp32-cube-timer/
I'm noob too and can't understand much of the code in this library, especially group timers :-)
My assumptions were that Arduino comes with some config settings that can't be changed and now I'm in doubt.
timer group init and timer group isr both have the hardcoded TIMER_GROUP_0
, if you find out using TIMER_GROUP_1
instead is working then I'll add a setter to the library.
Another important detail is the version of arduino-core (2.0.0 recommended), if for some reason you're with an older version, this library may produce a different (sluggish) behaviour.
#if defined ESP_IDF_VERSION_MAJOR && ESP_IDF_VERSION_MAJOR >= 4
#define USE_NATIVE_GROUP_TIMERS
#else
#warning "Using software group timers"
#endif
I have made it worked in a hacky way. I tried changing to TIMER_GROUP_1 but it was still crashing.
I have finally made it working by just replacing ESP_INTR_FLAG_IRAM
with NULL (maybe it should be nullptr but anyway) on this line: https://github.com/tobozo/ESP32-USB-Soft-Host/blob/main/src/ESP32-USBSoftHost.hpp#L168
USH should be initialized before BleKeyboard and I only tested with #define USE_NIMBLE
Sad part was it worked with a cheap logitech office keyboard but not with my mechanical one. Probably because it's fullspeed for some reason. Same with my Logitech mouse, it doesn't work.
bump
I found @martibn's annotated commit while browsing forks
I've added USH.setISRAllocFlag(int intr_alloc_flags)
to the main class, it should be called before USH.init()
.
The compiler complains when I use USH.setISRAllocFlag(NULL)
though, and I can't verify if USH.setISRAllocFlag(0)
produces the expected behaviour since I don't have an easily reproductible example for that.
@ugurbor can you confirm setting 0
or NULL
instead of ESP_INTR_FLAG_IRAM
produces satisfying results when using BT?
Base on the example here, I added ESP32 BLE Keyboard library to it.
I found that it crashes at whatever execute later,
bleKeyboard.begin()
orUSH.init()
.The ESP32 I am using is ESP32-DevkitC (ESP32WROOM32D).
ble.begin() before USH.init()
ble.begin() after USH.init()