Files
Alessandro Gatti b3d88cf210 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 #14293.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2026-03-21 16:27:37 +11:00
..
2019-10-01 09:51:02 +10:00