Skip to content

companion_radio: tear down QSPI peripheral when its init fails (fixes #2827)#2828

Open
benskigomez wants to merge 1 commit into
meshcore-dev:mainfrom
benskigomez:fix/m6-ble-qspi-init-poisons-softdevice
Open

companion_radio: tear down QSPI peripheral when its init fails (fixes #2827)#2828
benskigomez wants to merge 1 commit into
meshcore-dev:mainfrom
benskigomez:fix/m6-ble-qspi-init-poisons-softdevice

Conversation

@benskigomez

Copy link
Copy Markdown

Problem

On nRF52 BLE companion builds, a failed external-flash init leaves BLE completely dead. The Elecrow ThinkNode M6 never advertises over BLE on any firmware version (#2827), even though the same unit runs fine over LoRa and pairs over BLE under other firmware.

Root cause

When nrfx_qspi_init() fails (the M6 returns NRFX_ERROR_TIMEOUT / 0xBAD0007 during QSPI activation), it has already enabled the QSPI peripheral and enabled QSPI_IRQn in the NVIC at priority 0 (reserved for the SoftDevice) — and cleans none of it up before returning. The next step, Bluefruit.begin() enabling the SoftDevice, then fails; every later BLE call returns NRF_ERROR_SOFTDEVICE_NOT_ENABLED, so the node never advertises. USB companion builds are unaffected because they never enable the SoftDevice.

Fix

On the QSPIFlash.begin() failure path, disable QSPI_IRQn and power the QSPI peripheral back down before continuing. Runs only on the failure path, so boards whose QSPI init succeeds are unaffected.

Validation

On a ThinkNode M6 (with the QSPI init still timing out): the SoftDevice now enables, the node advertises, and the MeshCore app pairs and exchanges frames. Confirmed via boot-stage instrumentation that the SoftDevice enable goes from failing to succeeding once the peripheral is torn down.

Notes

The underlying M6 QSPI-init timeout is a separate issue (the custom QSPI flash driver doesn't bring up the MX25R1635F); this PR makes BLE robust to that failure rather than fixing the flash itself.

…eshcore-dev#2827)

On nRF52 BLE companion builds, a failed external-flash init left BLE
completely dead: the node never advertised on the Elecrow ThinkNode M6
on any firmware version, even though the same unit runs fine over LoRa
and pairs over BLE under other firmware.

Root cause: when nrfx_qspi_init() fails (the M6 returns
NRFX_ERROR_TIMEOUT / 0xBAD0007 during QSPI activation), it has already
enabled the QSPI peripheral and enabled QSPI_IRQn in the NVIC at
priority 0 (reserved for the SoftDevice), and it does not clean any of
that up before returning. The very next step, the SoftDevice enable in
Bluefruit.begin(), then fails (returns false) and every later BLE call
reports NRF_ERROR_SOFTDEVICE_NOT_ENABLED, so the node never advertises.
USB companion builds are unaffected because they never enable the
SoftDevice.

Fix: on the QSPIFlash.begin() failure path, disable QSPI_IRQn and
power the QSPI peripheral back down before continuing. This only runs
on the failure path, so boards whose QSPI init succeeds are unaffected,
and BLE now comes up cleanly even when the external flash is absent or
fails to initialize.

Validated on a ThinkNode M6: with the QSPI init still timing out, the
SoftDevice now enables, the node advertises, and the MeshCore app pairs
and exchanges frames.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants