Repository navigation
Fix(ble): restore BLE bring-up on boards without the SDR bank - #3080
Merged
Merged
Conversation
1.17 raised RADIO_BLE_MIN_DMA_BLOCK from 15 kB to 48 kB, a value measured on Cardputer where the SDR feature reserves a 64 KiB SRAM bank out of the heap and the new hand-off releases it when a radio needs it. 'restrict SDR' made the bank (and the hand-off) Cardputer-only, leaving every other board with a 48 kB contiguous-DMA requirement that no mechanism can satisfy; BLE fails right after boot on T-Embed etc. even with WiFi off (see BruceDevices#3078). Keep the 48 kB gate only where the bank is reserved (same #if guard as the hand-off itself) and fall back to the pre-1.17 gate elsewhere.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Confirmed on LilyGO T-Embed CC1101 Plus (nRF24 menu present), built from tag
Fixes #3078 for this board. |
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.
Target: BruceDevices/firmware (post-1.17)
Scope: 1 file changed, ~10 lines (
src/core/radio_mem.h)Related: #3078 (T-Embed CC1101 Plus: all BLE features fail right after boot)
Summary
Since 1.17, every BLE feature (BLE Suite, BLE Scan, BLE Spam, Ducky BLE)
fails immediately after boot on boards other than Cardputer with:
even when WiFi is off. The error text is misleading: the gate is not about
WiFi being active, it is
radioHasMemForBle()insrc/core/radio_mem.h,which requires the largest contiguous DMA-capable internal RAM block
to be at least
RADIO_BLE_MIN_DMA_BLOCKbefore the BLE stack is touched.Root cause
Two 1.17 changes interact:
Commit
ec014ad1("fix ble cardputer") raisedRADIO_BLE_MIN_DMA_BLOCKfrom 15 kB to 48 kB. That number was measured on Cardputer ADV,
where the new SDR feature reserves a 64 KiB SRAM bank out of the heap at
boot ("restrict SDR"), leaving only ~15.8 kB contiguous at the menu. The
same commit added an SDR bank hand-off (
sdrBankReleaseForRadio())that returns those 64 KiB to the heap when the radio needs them — this
is what makes a 48 kB gate reachable on Cardputer.
Commit
3e9bc11f("restrict SDR") added-D BRUCE_NO_SDR_JAMMER=1tothe global
build_flagsinplatformio.ini, so the SDR bank (andtherefore the hand-off) only exists on the Cardputer env, whose ini
removes the define via
build_unflags. On every other board(T-Embed, T-Deck, T-Stick, ...) the hand-off functions compile to no-ops.
Net effect: all non-Cardputer boards now require a 48 kB contiguous DMA
block with no mechanism to ever satisfy it, where 1.16 required 15 kB
(the value BLE shipped with and worked with everywhere). On T-Embed the
menu heap never reaches 48 kB contiguous, so BLE is dead from boot —
matching #3078.
Serial confirmation on an affected board (1.17):
Fix
Make the BLE gate conditional on whether the SDR bank is actually
reserved out of the heap — the only configuration the 48 kB number was
calibrated for, and the only one where the hand-off can satisfy it:
#ifguard is deliberately identical to the guard that makessdrBankReleaseForRadio()real (a few lines below), so the thresholdand the hand-off can never disagree.
hand-off.
Wi-Fi threshold, which was never raised).
RADIO_WIFI_MIN_DMA_BLOCKunchanged).Why this is safe
boards; the failure mode it re-introduces (BLE init aborting cleanly
with an error instead of a half-initialized controller crash) is kept.
the boards the 48 kB gate was designed for.
BLE_Suite.cpp,ble_common.cpp,ble_spam.cpp,ducky_typer.cpp) go throughradioHasMemForBle(),so one constant fixes all of them.
Test plan
pio run -e lilygo-t-embed-cc1101(and one more non-Cardputer S3 env,e.g.
lilygo-t-deck) — build must succeed (threshold is a compile-timeconstant, no runtime code change for these boards).
(
minimum 15360 needed) and no[RAM] Still only ...line at boot."Low RAM: free WiFi/SD first" until reboot (unchanged).
env_light): BLE behaves as in 1.16.Commit message suggestion