-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
BLE on ESP32 inconsistent init time (sometimes > 10s) #5489
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
This is most likely a hardware or IDF issue. Best to wait for a stable IDF version which includes nimble (3.3.1), see #5282 |
It is also happening to me using the following version:
It also takes a non-deterministic time. By the way, I just realized here at #5524 that BLE is now supported by the IDF v3 firmware, and the IDF stable version is v3, not v4. I am gonna try it and observe if this change solves the problem. |
Used |
Used esp32-idf4-20200326-v1.12-307-gad004db66.bin and the inconsistent init time persists. |
@dpgeorge Any updates on when this issue will be looked at? Thanks. |
I looked in to this problem. I was able to reproduce the slow start up time with an IDF example (bluetooth/nimble/bleprph) on both v3.3.2 and v4.0, but to get the problem to show needed the nimble task to be pinned to core 1 (which is what MicroPython's config does). The problem does not show up on the very latest IDF version, v4.2-dev-1126-gd85d3d969 (with nimble pinned to core 1). Pinning nimble to core 0 makes the problem go away in both v3.3.2 and v4.0, as far as my testing showed (on both the IDF example and MicroPython firmware). Summary: this can probably be fixed by one of the following:
Since point (2) is non-trivial, and we don't yet support LAN or PPP for v4.x, I suggest option (1), at least for now. |
Hmmm, doesn't pinning MP to core0 (that's the "PRO" core, right?) effectively makes the second core unused? That's pretty drastic too... At what point is the cure worse than the disease? |
It was like this for a long time, because dual-core mode was very unreliable in the early days (and still is it seems). Sometimes the BLE init delay is around 30 seconds which is really unusable. And since it looks fixed in very recent IDF versions putting it all on core 0 is just a workaround for now. |
@dpgeorge Thank you for investigating and offering the workaround of pinning both the Micropython and Nimble task to core 0. I can confirm this works. |
This issue has been a major frustration while trying to test #6343 I would like to suggest that we go with @dpgeorge's suggestion of pinning both MP and NimBLE to Core 0 until the issue is fixed in the IDF. (I've added a commit to #6343 to do exactly that). This appears to be causing more issues than just slow startup, and generally the reliability has improved since pinning both to core 0. According to the IDF 4.1-rc1 release notes, this issue might be fixed by "Fixed HCI timeout issues when using multiple cores and sleep is enabled" (I don't really want to go down the rabbit hole of figuring out the implications of "and sleep is enabled"). I agree with @tve that it's unfortunate to put everything on the PRO core, but right now it makes BLE very hard to test and it's not a good experience for users. The other fix (if we don't want to wait for 4.1) would be to make the NimBLE->MP bindings work across cores (this means making the BLE ringbuffer and MP scheduler multi-core safe). |
MicroPython and NimBLE must be on the same core, for synchronisation of the BLE ringbuf and the MicroPython scheduler. However, in the current IDF versions (3.3 and 4.0) there are issues (see e.g. micropython#5489) with running NimBLE on core 1. This change - pinning both tasks to core 0 - makes it possible to reliably run the BLE multitests on esp32 boards.
MicroPython and NimBLE must be on the same core, for synchronisation of the BLE ringbuf and the MicroPython scheduler. However, in the current IDF versions (3.3 and 4.0) there are issues (see e.g. micropython#5489) with running NimBLE on core 1. This change - pinning both tasks to core 0 - makes it possible to reliably run the BLE multitests on esp32 boards.
MicroPython and NimBLE must be on the same core, for synchronisation of the BLE ringbuf and the MicroPython scheduler. However, in the current IDF versions (3.3 and 4.0) there are issues (see e.g. micropython#5489) with running NimBLE on core 1. This change - pinning both tasks to core 0 - makes it possible to reliably run the BLE multitests on esp32 boards.
Fixed in 311b851 by pinning everything to core 0. Can be improved in the future after updating to a newer IDF that fixes the bug. |
This follows up on micropython#5489, where we changed the esp32 core pinning to core 0 in order to work around an issue with IDF < 4.2.0. Now that IDF > 4.2.0 is available, we allow pinning back to core 1, which eliminates some problematic callback latency with wifi enabled.
This follows up on #5489, where we changed the esp32 core pinning to core 0 in order to work around an issue with IDF < 4.2.0. Now that IDF > 4.2.0 is available, we allow pinning back to core 1, which eliminates some problematic callback latency with WiFi enabled. NimBLE is also pinned to core 1 - the same core as MicroPython - when using IDF >=4.2.
This follows up on micropython#5489, where we changed the esp32 core pinning to core 0 in order to work around an issue with IDF < 4.2.0. Now that IDF > 4.2.0 is available, we allow pinning back to core 1, which eliminates some problematic callback latency with WiFi enabled. NimBLE is also pinned to core 1 - the same core as MicroPython - when using IDF >=4.2.
Initiating and activating bluetooth with
normally take around 200ms to execute. But sometimes it takes over 10 seconds.
occurs with
esp32-idf4-20191220-v1.12.bin
Further Details at this forum post.
The text was updated successfully, but these errors were encountered: