Skip to content

Commit 4bb474a

Browse files
committed
fix(promicro): exclude emoji to fit under the warm-store region
nrf52_promicro_diy_tcxo has been failing the nrf52 warm-region guard on develop: the image ends at 0xEA0C0, 192 bytes past the 12 KB WarmNodeStore record-ring reserved at 0xEA000. This variant compiles four radio driver families (SX126x/LLCC68, SX127x/RF95, LR11x0/LR1121, LR2021) so any module can be soldered on, which makes it the largest nrf52 image we ship. Building it with -D EXCLUDE_EMOJI saves 6,808 bytes and puts the image at 0xE8618, 6.6 KB clear of the warm region. EXCLUDE_EMOJI was not previously usable: graphics::emotes[] becomes empty, but the canned-message emote picker never checked for that. Entering the picker clamped emotePickerIndex to numEmotes - 1 (i.e. -1), and selecting read emotes[-1].label into a String - an out-of-bounds read of whatever precedes the array in flash. Guard both entry points instead: refuse to open the picker when there are no emotes, and bounce back to freetext if the picker state is somehow reached anyway. Under whole-image LTO those guards fold to constants, so the picker draw and input paths dead-strip entirely on builds that set EXCLUDE_EMOJI - which is where the savings come from beyond the bitmap data itself. Received messages containing emoji render as text on this variant, and the emote-list key is a no-op. Verified rak4631 (emoji enabled) is unaffected: 0xE46D8, 22 KB clear.
1 parent 1e982fa commit 4bb474a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/modules/CannedMessageModule.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,10 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent *event)
880880
// All hardware keys fall through to here (CardKB, physical, etc.)
881881

882882
if (event->kbchar == INPUT_BROKER_MSG_EMOTE_LIST) {
883-
updateState(CANNED_MESSAGE_RUN_STATE_EMOTE_PICKER);
884-
screen->forceDisplay();
883+
if (graphics::numEmotes > 0) { // no picker on EXCLUDE_EMOJI builds (empty emotes[])
884+
updateState(CANNED_MESSAGE_RUN_STATE_EMOTE_PICKER);
885+
screen->forceDisplay();
886+
}
885887
return true;
886888
}
887889
// Confirm select (Enter)
@@ -965,6 +967,11 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent *event)
965967
int CannedMessageModule::handleEmotePickerInput(const InputEvent *event)
966968
{
967969
int numEmotes = graphics::numEmotes;
970+
if (numEmotes == 0) { // EXCLUDE_EMOJI: emotes[] is empty, any index would read out of bounds
971+
updateState(CANNED_MESSAGE_RUN_STATE_FREETEXT, true);
972+
screen->forceDisplay();
973+
return 1;
974+
}
968975

969976
// Override isDown and isSelect ONLY for emote picker behavior
970977
bool isUp = isUpEvent(event);

variants/nrf52840/diy/nrf52_promicro_diy_tcxo/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ board = promicro-nrf52840
1515
build_flags = ${nrf52840_base.build_flags}
1616
-I variants/nrf52840/diy/nrf52_promicro_diy_tcxo
1717
-D NRF52_PROMICRO_DIY
18+
-D EXCLUDE_EMOJI ; this variant builds 4 radio driver families and is the largest nrf52 image; emote bitmaps don't fit under the 0xEA000 warm-store cap
1819
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/diy/nrf52_promicro_diy_tcxo>
1920
debug_tool = jlink
2021

0 commit comments

Comments
 (0)