Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/platform/nrf52/NRF52Bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "HardwareRNG.h"
#include "PowerFSM.h"
#include "configuration.h"
#include "error.h"
#include "main.h"
#include "mesh/PhoneAPI.h"
#include "mesh/mesh-pb-constants.h"
Expand Down Expand Up @@ -275,7 +276,16 @@ void NRF52Bluetooth::setup()
LOG_INFO("Init the Bluefruit nRF52 module");
Bluefruit.autoConnLed(false);
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
if (!Bluefruit.begin()) {
// sd_ble_enable() rejected our RAM base: the linker RAM ORIGIN
// (src/platform/nrf52/nrf52840_s140_v*.ld) is below what the SoftDevice needs for the
// current Bluefruit config. Without this check the node would silently run without BLE.
// Rebuild with -DCFG_DEBUG=1 to get "SoftDevice's RAM requires: 0x..." in the log, then
// raise the ORIGIN accordingly.
LOG_ERROR("Bluefruit.begin failed - SoftDevice RAM reservation too small for this config");
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_UNSPECIFIED);
return;
}
// Clear existing data.
Bluefruit.Advertising.stop();
Bluefruit.Advertising.clearData();
Expand Down
11 changes: 10 additions & 1 deletion src/platform/nrf52/nrf52840_s140_v6.ld
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ MEMORY
* - Max ATT MTU
* - Concurrent connection peripheral + central + secure links
* - Event Len, HVN queue, Write CMD queue
*
* With our fixed Bluefruit config (1 peripheral link, BANDWIDTH_MAX / MTU 247,
* 0x1000 attr table) sd_ble_enable() reports a requirement well below the old
* 0x20006000 ORIGIN; every byte of gap is unusable RAM. 0x20004000 keeps a
* ~2+ KB margin over the reported base. NRF52Bluetooth::setup() now checks
* Bluefruit.begin() and records a critical error if the SoftDevice ever
* rejects this base (e.g. after an SD/Bluefruit config change) - re-measure
* with CFG_DEBUG=1 (Bluefruit logs "SoftDevice's RAM requires: 0x...")
* before raising bandwidth/MTU/link settings.
*/
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000
RAM (rwx) : ORIGIN = 0x20004000, LENGTH = 0x20040000 - 0x20004000
}

SECTIONS
Expand Down
13 changes: 11 additions & 2 deletions src/platform/nrf52/nrf52840_s140_v7.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ MEMORY
* - Max ATT MTU
* - Concurrent connection peripheral + central + secure links
* - Event Len, HVN queue, Write CMD queue
*/
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000
*
* With our fixed Bluefruit config (1 peripheral link, BANDWIDTH_MAX / MTU 247,
* 0x1000 attr table) sd_ble_enable() reports a requirement well below the old
* 0x20006000 ORIGIN; every byte of gap is unusable RAM. 0x20004000 keeps a
* ~2+ KB margin over the reported base. NRF52Bluetooth::setup() now checks
* Bluefruit.begin() and records a critical error if the SoftDevice ever
* rejects this base (e.g. after an SD/Bluefruit config change) - re-measure
* with CFG_DEBUG=1 (Bluefruit logs "SoftDevice's RAM requires: 0x...")
* before raising bandwidth/MTU/link settings.
*/
RAM (rwx) : ORIGIN = 0x20004000, LENGTH = 0x20040000 - 0x20004000
}

SECTIONS
Expand Down
Loading