Fix nRF52 remote CLI stack overflows - #3101
Open
mikecarper wants to merge 1 commit into
Open
Conversation
mikecarper
marked this pull request as ready for review
August 2, 2026 19:05
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.
This is the follow-up I mentioned in PR #2824.
That PR moved nRF52 crypto onto the CC310 and recovered useful headroom in the 4 KiB Arduino loop stack. A large remote CLI command could still overflow it, though, because the command ran underneath the full packet receive/decrypt call chain. I was able to reproduce that while setting up a large region map with the additional cli options I've added.
This change copies an authenticated remote CLI command into a one-entry mailbox and processes it after
Mesh::loop()returns. Advertisement signing is deferred to the following stack boundary as well, so it does not sit on top of either the receive path or the CLI handler. If another command arrives before the pending one is drained, it gets a clear busy response.As a second layer of protection, nRF52 builds now give only the Arduino
looptask an 8 KiB stack instead of the framework's 4 KiB default. Other FreeRTOS tasks keep their requested stack sizes. Serial and Ethernet CLI handling also live in a non-inlined helper so their reply buffers are gone before the mesh loop runs. We can skip this if we want to keep it at 4kb.I added unit coverage for copying, clearing, rejecting concurrent commands, and rejecting oversized commands.
Tested with:
pio test -e native -f test_deferred_cli_commandpio run -e RAK_4631_repeater -e Xiao_nrf52_repeater -e heltec_v4_repeaterThe RAK4631 and XIAO ELF files also contain the
xTaskCreatewrapper used to resize the nRF52 loop task.