Commit b3d88cf
extmod/nimble/modbluetooth_nimble: Handle port init failures.
This commit fixes an issue related to the NimBLE initialisation
procedure in low memory environments on ESP32 boards.
MicroPython uses at least two different NimBLE stacks across the
supported ports, mynewt (imported as an external library), and the one
provided by Espressif in their own SDKs. The problem is that these two
ports differ in the signature for `nimble_port_init(void)`, with mynewt
returning `void`, and Espressif's returning a status code on failure.
On ESP32 boards, allocating almost all the available heap and then
turning on the Bluetooth stack would trigger a failure in the NimBLE
initialisation function that is not handled by the NimBLE integration
code, as there's no expectation of a recoverable condition. Since the
stack initialisation would progress, then uninitialised memory accesses
crash the board.
Since we cannot really modify neither mynewt nor Espressif SDKs, the
next best thing is to provide two conditional initialisation paths
depending on a configuration setting. This would make Espressif ports
recover from a failed initialisation whilst retaining the existing
behaviour on other ports.
This fixes micropython#14293.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>1 parent b1d635f commit b3d88cf
2 files changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
621 | 630 | | |
| 631 | + | |
622 | 632 | | |
623 | 633 | | |
624 | 634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
0 commit comments