fix(nrf52): fix poweroff CLI command for T114 and RAK4631#2701
Open
jirogit wants to merge 3 commits into
Open
Conversation
…MOFF T114Board::powerOff() was calling sd_power_system_off() directly with no error handling. If the SoftDevice returns NRF_ERROR_BUSY or any other error, execution silently returned and the device kept running. Delegating to initiateShutdown(SHUTDOWN_REASON_USER) fixes this by: - powering down the SX1262 (SX126X_POWER_EN LOW) before SYSTEMOFF, preventing immediate GPIO wakeup via DIO1 - going through enterSystemOff() which handles SD errors and falls back to NRF_POWER->SYSTEMOFF then NVIC_SystemReset()
RAK4631Board had no powerOff() override, so the CLI poweroff command called the base class no-op and the device kept running. Add powerOff() following the R1NeoBoard pattern: delegate to initiateShutdown(SHUTDOWN_REASON_USER) which powers down the SX1262, then goes through enterSystemOff() with proper error handling and fallback to NRF_POWER->SYSTEMOFF.
RAK4631 has no buttons. After SX1262 is powered down, DIO1 (P_LORA_DIO_1) is the only GPIO with SENSE configured (set by RadioLib's attachInterrupt). The floating pin can trigger an immediate GPIO wakeup from SYSTEMOFF. Clear the SENSE configuration with nrf_gpio_cfg_default() before entering SYSTEMOFF to prevent this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
T114 and RAK4631 repeater did not shutdown by command.
T114
T114Board::powerOff()calledsd_power_system_off()directly with no error handling. If the SoftDevice returns an error, execution silently returned and the device kept running.Additionally, the SX1262 was left powered (
SX126X_POWER_ENHIGH), leaving DIO1 SENSE active and risking an immediate GPIO wakeup from SYSTEMOFF.RAK4631
RAK4631Boardhad nopowerOff()override at all. The CLIpoweroffcommand called the base class no-op (MainBoard::powerOff()) and the device kept running.Additionally, RAK4631 has no user buttons. After SX1262 is powered down, DIO1 (
P_LORA_DIO_1= pin 47) is the only GPIO with SENSE configured (set by RadioLib'sattachInterrupt()). The floating pin triggers an immediate GPIO wakeup from SYSTEMOFF, so the device restarts instead of staying off.Fix
T114
Delegate
powerOff()toinitiateShutdown(SHUTDOWN_REASON_USER), following the pattern used by R1NeoBoard and others withNRF52_POWER_MANAGEMENT. This powers down the SX1262 before SYSTEMOFF and goes throughenterSystemOff()with proper error handling and fallback toNRF_POWER->SYSTEMOFF.RAK4631
powerOff()override delegating toinitiateShutdown(SHUTDOWN_REASON_USER)initiateShutdown(), callnrf_gpio_cfg_default(P_LORA_DIO_1)immediately after powering down the SX1262 to clear the SENSE configuration and prevent immediate GPIO wakeup from SYSTEMOFFTest
poweroffCLI stopped ✅poweroffCLI stopped ✅