Fix peripheral power shutdown and auto-detect Station G3 radio slots

This commit is contained in:
mikecarper committed 2026-10-15 22:30:37 -07:00
1 parent c6e43c5530
commit 8eced48d34
103 files changed
+4900 -194

No files matched your search

+43
View File
@@ -1791,6 +1791,37 @@ Station G2/G3 targets default to `off`.
---
#### Select the Station G3 physical radio slot
```text
get radio.slot
set radio.slot auto
set radio.slot 1
set radio.slot 2
reboot
```
Station G3 SX1262 builds support both physical RF sockets in the same image.
The default, `auto`, probes both sockets at boot without transmitting. If both
work, it prefers the last successfully used socket; on a fresh installation,
it prefers socket 1. A forced `1` or `2` never silently uses the other socket.
`get radio.slot` reports the saved selection, active socket, detected sockets,
and whether a reboot is needed. Changes are saved immediately but applied only
after reboot, never during a transmission. The selector does not change keys,
node settings, or the time-shared `radio2` profile. The legacy `_r2` build name
means physical socket 2, not a motherboard revision; both build names now
support this selector.
If no usable socket is found, startup waits with both LNAs disabled instead of
reboot-looping. A limited USB recovery console accepts `!g3 get radio.slot`,
`!g3 set radio.slot auto|1|2`, `!g3 reboot`, and `!g3 help`. The `!g3` prefix is
required in this recovery console; it is not the normal running CLI. KISS
firmware uses binary slot commands during normal operation, documented in the
[KISS protocol](kiss_modem_protocol.md).
---
### System
#### View or change this node's name
@@ -2516,6 +2547,18 @@ inactive and no work is pending. Compiling those transports into Full does not
itself prevent sleep. Turning off BLE advertising alone leaves its controller
running and therefore retains idle behavior rather than manual light sleep.
An active radio2 requires continuous software scanning. With power saving on,
ESP32 Companion, Repeater, Room and Sensor builds do not insert the ordinary
1 ms idle delay while dual-radio scanning is active. This avoids delaying
sub-millisecond scan visits; it does not make active dual-radio scanning a sleep mode.
The verified Meshnology W12 layout enables the LR2021 radio's DC-DC regulator
after LoRa and Morse receive initialization, including recovery. This setting
is independent of `powersaving` and does not remove radio features. Other
LR2021 layouts retain their existing regulator behavior unless their recipe
explicitly enables `LR2021_USE_DCDC` after confirming the required inductor;
the X1 is not opted in without that hardware confirmation.
---
#### View or set the reboot interval (Repeater and room server)
+22
View File
@@ -155,6 +155,8 @@ MeshCore-specific functionality uses the standard KISS SetHardware command. The
| GetTempRadio2 | `0x1E` | - |
| SetRadio2Ext | `0x1F` | Radio2 parameters + protocol (14) |
| GetRadio2Ext | `0x20` | - |
| GetRadioSlot | `0x22` | - (Station G3 only) |
| SetRadioSlot | `0x23` | Mode (1): 0=auto, 1=slot 1, 2=slot 2 (Station G3 only) |
### Response Sub-commands (TNC to Host)
@@ -187,6 +189,7 @@ Response codes use the high-bit convention: `response = command | 0x80`. Generic
| Radio2 | `0x9C` | Saved radio2 parameters (13) |
| TempRadio2 | `0x9E` | Active temporary radio2 + remaining minutes (15) |
| Radio2Ext | `0xA0` | Saved radio2 parameters + protocol (14) |
| RadioSlot | `0xA2` | Saved mode, active slot, detected mask, reboot needed (4 bytes) |
| OK | `0xF0` | - |
| Error | `0xF1` | Error code (1) |
| TxDone | `0xF8` | Result (1): 0x00=failed, 0x01=success |
@@ -203,6 +206,25 @@ Response codes use the high-bit convention: `response = command | 0x80`. Generic
| UnknownCmd | `0x05` | Unknown sub-command |
| EncryptFailed | `0x06` | Encryption failed |
| TxBusy | `0x07` | Radio TX busy, or host output queue full |
| SaveFailed | `0x08` | Setting could not be saved; running slot unchanged |
### Station G3 physical radio slot
`GetRadioSlot` takes no data and replies with four bytes: saved mode (`0` auto,
`1` or `2` forced socket), active socket (`0` unavailable, `1` or `2`), detected
socket mask (bit 0 = socket 1, bit 1 = socket 2), and reboot-needed flag (`0` or
`1`). This selects the physical SX1262 daughterboard socket, not the logical
`radio2` PHY profile. Other boards return `UnknownCmd`.
`SetRadioSlot` requires exactly one mode byte (`0`–`2`). An `OK` means the mode
was saved; the running socket stays unchanged until a separate `Reboot` command
or power cycle. Radio settings and identity are untouched. A failed save returns
`SaveFailed`, with no change to the running socket.
If no usable socket is found during boot, the normal KISS modem has not started.
Use the separate USB recovery console: `!g3 get radio.slot`,
`!g3 set radio.slot auto`, then `!g3 reboot`. Recovery accepts only these
prefixed management commands (and `!g3 help`), never KISS packet payloads.
### Unsolicited Events
+40
View File
@@ -71,6 +71,46 @@ Notes:
## Technical Details
### RAK peripheral shutdown
Explicit power-off and timed deep sleep on RAK4631 and RAK3401 stop peripheral
owners before switching off the shared `3V3_S` supply. On RAK4631, Ethernet
must quiesce first; if its worker cannot stop within the bounded shutdown
interval, keep its rail and bus intact instead of removing power during an SPI
operation. Detected external-storage holds also retain the supply, including
after an unresolved flash-operation timeout. Before storage discovery and
configuration finish, rail removal is refused. Shutdown does not probe again,
cancel a staged update, or float a storage owner's select pin.
This does not change ordinary interrupt-idle sleep, boot/low-voltage
protection, or the configured WisBlock GPS/shared-rail policy during normal
operation.
The [RAK19007 power schematic](https://images.docs.rakwireless.com/wisblock/rak19007/datasheet/power-schematic.png)
and [RAK13800 connector schematic](https://images.docs.rakwireless.com/wisblock/rak13800/datasheet/image-20211116120503808.png)
show that IO2 switches `3V3_S`, not the separate upstream PoE `VCC_IN` supply.
Merely compiling Ethernet support therefore does not require this rail to
stay on after terminal shutdown. The RAK4631 radio-enable GPIO controls the
RF-switch supply, not the SX1262 core supply.
RAK3401's external RAK13302 radio and RAK13800 Ethernet use the same IO slot,
SPI signals, select pin and IO3 control. Their simultaneous operation is not
supported; Ethernet owner registration on RAK3401 is rejected rather than
allowing those electrically conflicting controls to run together.
Software shutdown cannot remove every hardware leakage path. The baseboard
has I2C pull-ups to unswitched VDD. RAK13302 VD's boost enable follows IO2, but
the legacy VC default resistor configuration connects it directly to VBAT;
that boost cannot be switched off by firmware alone.
### XIAO battery-divider safety
XIAO and XIAO-based Ikoka startup preload `READ_BAT_ENABLE` LOW before enabling
its output. XIAO protective and user shutdown also keep it LOW. Seeed warns
that HIGH can overvoltage the ADC input during charging, so this is not a
safe pin to switch HIGH as a power optimization. The schematic's 1 MOhm +
510 kOhm divider draws about 3 microamps at 4.2 V, not 3 milliamps. Charging
current settings are unchanged. See [Seeed's battery guidance](https://wiki.seeedstudio.com/XIAO_BLE/#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging).
### Architecture
The power management functionality is integrated into the `NRF52Board` base class in `src/helpers/NRF52Board.cpp`. Board variants provide hardware-specific configuration via a `PowerMgtConfig` struct and override `initiateShutdown(uint8_t reason)` to perform board-specific power-down work and conditionally enable voltage wake (LPCOMP + VBUS).