Docs: nRF52 sleep fixes measured — CC310 IRQ is the 2.6 mA one, DC/DC and nfcal below resolution

Changelog: -
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-26 11:35:35 +01:00
1 parent 5c73a3b582
commit 137b9a9f05
2 files changed
+84 -31

No files matched your search

+81 -29
View File
@@ -12,7 +12,8 @@ figures are.
|---|---|---| |---|---|---|
| **GPS running continuously** | **46.0 mA** (spread 43.7-47.5) | `gps duty` recovers 42-45 of it | | **GPS running continuously** | **46.0 mA** (spread 43.7-47.5) | `gps duty` recovers 42-45 of it |
| BLE advertising + Bluefruit's blinking LED | see below | defaults changed, LED off, 1 s interval | | BLE advertising + Bluefruit's blinking LED | see below | defaults changed, LED off, 1 s interval |
| `powersaving on` (MCU light sleep) | **~1 mA, not separable from zero** | keep it on (free), but it is not a lever | | `powersaving on` (MCU light sleep) | **~1 mA** with USB, **2.7 mA** without (XIAO, 11/2026) | keep it on |
| CC310 IRQ cleared before sleep (nRF52) | **2.6 mA** after every boot | fixed in firmware, see below |
| RX duty cycle (`set radio.rxps`, from EasySkyMesh) | **~2.3 mA** at `max` (XIAO, 12. 11. 2026) | **no** on a live node: -16 % received and a TX stall on mast-three, see below | | RX duty cycle (`set radio.rxps`, from EasySkyMesh) | **~2.3 mA** at `max` (XIAO, 12. 11. 2026) | **no** on a live node: -16 % received and a TX stall on mast-three, see below |
| `radio.rxgain off` | ~0.7 mA | **no** — 1-3 dB of sensitivity is what a mast node is for | | `radio.rxgain off` | ~0.7 mA | **no** — 1-3 dB of sensitivity is what a mast node is for |
| FEM LNA control | n/a | SenseCap has no FEM, only an RXEN switch | | FEM LNA control | n/a | SenseCap has no FEM, only an RXEN switch |
@@ -218,37 +219,88 @@ then shows `RESETREAS=0x00020000`, bit 17, wake from LPCOMP); with a cutoff
set, lowering the supply below it must switch the node off within ~3 minutes set, lowering the supply below it must switch the node off within ~3 minutes
and `get pwr` after the wake must say `last off: Low Voltage`. and `get pwr` after the wake must say `last off: Low Voltage`.
## nRF52 sleep & peripheral fixes (bench verification pending) ## nRF52 sleep & peripheral fixes
Audit of the nRF52840 firmware and Adafruit core identified several sources of An audit of the nRF52840 firmware and the Adafruit core found several sources of
unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): idle draw that apply to all nRF52 boards, not only SenseCAP Solar. They were
measured on 25./26. 11. 2026 on XIAO x4 (nRF52840 + Wio-SX1262, repeater build,
bench preset). Setup: no USB host, fed at 5 V through an INA226 read every
~1 s. Each cell was 10 min (20 min for rxps), 38 cells over two rounds. Every
knob was switched at runtime between two baseline cells. The baseline
repeatability was **0.05 mA**, so an effect counts only above 0.1 mA and with
the same sign in both rounds. The 5 V pin is VBUS, so USBD and HFXO stay up;
read the absolute numbers as this rig and the deltas as the result.
- **`CRYPTOCELL_IRQn` sleep insomnia**: `USE_CC310_HW_CRYPTO=1` runs CC310 in **The one that matters: `CRYPTOCELL_IRQn` sleep insomnia (+2.6 mA).**
polling mode with `CRYPTOCELL_IRQn` disabled in NVIC; completed operations `USE_CC310_HW_CRYPTO=1` runs CC310 in polling mode with `CRYPTOCELL_IRQn`
leave it pending and immediately wake `sd_app_evt_wait()`/`__WFE()`. disabled in NVIC. A completed operation leaves the IRQ pending, and a pending
`NRF52Board::sleep()` now clears `CRYPTOCELL_IRQn` before sleeping, matching IRQ ends `sd_app_evt_wait()`/`__WFE()` immediately. `NRF52Board::sleep()` now
Adafruit core's `wiring.c`. clears it before sleeping, as the Adafruit core's `wiring.c` does. Without the
- **DC/DC regulator after SoftDevice start**: `NRF52BoardDCDC::begin()` runs clear, a node comes out of every boot stuck at **14.1 mA instead of 11.5**:
before `Bluefruit.begin()`, which enables SoftDevice S140 (defaulting
`NRF_POWER` to LDO). `NRF52BoardDCDC::onBootComplete()` now re-enables DC/DC | boot with | before first BLE connection | after it |
via `sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)` once SoftDevice is active. |---|---|---|
- **Avoid `NRF_SPIM3` (Nordic Errata 195)**: `[nrf52_base]` now sets | both fixes | 11.51 / 11.51 mA | 11.48 / 11.49 mA |
`-D SPI_32MHZ_INTERFACE=1`, moving the primary `SPI` bus (used by SX1262 at | no CC clear | **14.13 / 14.15 mA** | 11.38 / 11.52 mA |
2 MHz) from `NRF_SPIM3` to `NRF_SPIM2`. Adafruit `SPIClass::endTransaction()` | no CC clear, no late DC/DC (= old main) | **14.04 / 14.14 mA** | 11.50 / 11.55 mA |
disables `SPIM3` without the Errata 195 workaround, leaving ~1.2-2 mA idle | no late DC/DC | 11.43 / 11.53 mA | 11.51 / 11.53 mA |
draw after the first SPI transaction.
- **Disconnect GPS UART pins while GPS is off**: `NmeaGpsDriver::stopHardware()` Values are round 1 / round 2. In the stuck state the core wakes
now resets the UART TX/RX pins via `nrf_gpio_cfg_default()` after `Uart::end()`, ~15 000 times a second, against ~990 for the 1024 Hz tick, and it is awake
preventing back-powering of the unpowered GPS receiver through GPIO/ESD paths. for 80 % of the time. It is not an occasional spike either: 98–100 % of the
- **Disable unused I2C bus & lower noise-floor calibration rate**: on nRF52, samples sit above 13 mA. Received LoRa packets do not end it (5 per window). The
`EnvironmentSensorManager::begin()` calls `Wire.end()` when the I2C bus scan first BLE connection does; the mechanism is not traced. A mast node that nobody
finds zero devices (re-enabling temporarily for the `i2c` CLI command). connects to over BLE stays in it. Toggling the clear at runtime
`NOISE_FLOOR_CALIB_INTERVAL` is raised from 2 s to 10 s to cut idle SPI on an already clean node changes nothing (+0.01 / +0.02 mA), because the state
wake-ups 5x. is decided at boot.
**Measured to make no difference, kept anyway** (each below 0.1 mA):
- **DC/DC re-enabled after SoftDevice start** (`onBootComplete()`):
+0.02 / −0.10 mA at runtime, and no difference as a boot flag. The premise
that S140 puts `NRF_POWER` back to LDO did not hold on this board.
`DCDCEN` read 1 after every boot, with or without the late enable. The
late enable is kept as a harmless safeguard.
- **Noise-floor calibration every 10 s instead of 2 s**
(`NOISE_FLOOR_CALIB_INTERVAL`): +0.08 mA, one pair.
**Not measured** (compile-time or other hardware):
- **Avoid `NRF_SPIM3` (Nordic Errata 195)**: `[nrf52_base]` sets
`-D SPI_32MHZ_INTERFACE=1`, which moves the SX1262 `SPI` bus from `NRF_SPIM3`
to `NRF_SPIM2`. `SPIClass::endTransaction()` disables `SPIM3` without the
errata workaround, which is worth ~1.2–2 mA idle per the errata. A clean
baseline of 11.5 mA on this board leaves little room for that.
- **GPS UART pins disconnected while the GPS is off**:
`NmeaGpsDriver::stopHardware()` resets TX/RX via `nrf_gpio_cfg_default()`
after `Uart::end()`, so the unpowered receiver is not back-powered.
- **Unused I2C bus switched off**: `EnvironmentSensorManager::begin()` calls
`Wire.end()` when the bus scan finds no device, and enables it again for the
`i2c` CLI command.
- **SenseCAP Solar battery divider (`VBAT_ENABLE`)**: held `HIGH` (off) at boot - **SenseCAP Solar battery divider (`VBAT_ENABLE`)**: held `HIGH` (off) at boot
and restored to `HIGH` immediately after `getBattMilliVolts()` instead of and set back to `HIGH` right after `getBattMilliVolts()`, instead of staying
staying continuously `LOW`. (`initiateShutdown()` still drives it `LOW` when `LOW`. `initiateShutdown()` still drives it `LOW` when it arms the LPCOMP
arming LPCOMP wake.) wake. Open question: with the divider off, the ADC pin may sit near VDD +
0.3 V on a full cell. This is yet to be checked with a meter on the board.
**Runtime knobs from the same night**, for comparison (paired deltas):
| knob | round 1 | round 2 | reception (x1 witness) |
|---|---|---|---|
| `set radio.rxps max` | −2.47 mA | −2.33 mA | 20/21 |
| `set radio.rxps balanced` | −1.98 mA | −1.88 mA | 20/21 |
| `set radio.rxgain off` | −0.49 mA | −0.45 mA | 10/12 |
| `powersaving off` | +2.66 mA | (one pair) | 5/6 |
| baseline | | | 83/90 |
The x1 witness sends zero-hop adverts every ~130 s at 2 dBm. Reception counts
are approximate at cell edges, and no knob showed a gross loss. The bench
signal is strong, so this does not test sensitivity, and the rxps failure on
the live mesh (see above) still stands. `powersaving` is worth 2.7 mA here
without USB, much more than the ~1 mA measured with USB attached (USB keeps
HFCLK running).
Tools: `tools/power_ab.py --ina <url>` (INA226 of a solar controller as the
meter, raw samples saved), firmware bench knobs and the night driver are kept with
the run log, outside the repository.
## Measuring this yourself — two traps ## Measuring this yourself — two traps
+3 -2
View File
@@ -308,8 +308,9 @@ void NRF52BoardDCDC::begin() {
void NRF52BoardDCDC::onBootComplete() { void NRF52BoardDCDC::onBootComplete() {
NRF52Board::onBootComplete(); NRF52Board::onBootComplete();
// SoftDevice (Bluefruit.begin()) starts after board.begin() and defaults // SoftDevice (Bluefruit.begin()) starts after board.begin(). On XIAO x4
// NRF_POWER to LDO mode; re-enable DC/DC once SoftDevice owns NRF_POWER. // (11/2026) DCDCEN read 1 after boot with or without this call, so it is a
// safeguard in case a SoftDevice/board combination resets NRF_POWER to LDO.
enableNrf52Dcdc(); enableNrf52Dcdc();
} }