Skip to content

Reduce heap usage on ST7789 display targets with reduced-memory mode - #10894

Merged
thebentern merged 1 commit into
developfrom
Reduce-Heap
Jul 6, 2026
Merged

Reduce heap usage on ST7789 display targets with reduced-memory mode#10894
thebentern merged 1 commit into
developfrom
Reduce-Heap

Conversation

@HarukiToreda

@HarukiToreda HarukiToreda commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR enables the meshtastic-st7789 driver's reduced-memory mode on the ST7789-based targets that use it today:

  • heltec-mesh-node-t114
  • heltec-vision-master-t190
  • m5stack-cardputer-adv
  • heltec-mesh-solar-tft

The change is limited to PlatformIO env flags:

  • -DOLEDDISPLAY_REDUCE_MEMORY

Why

Runtime heap usage on larger ST7789 displays is heavily impacted by the driver's display buffering. On the T114, the display path was the main reason heap usage was so high.

These targets all use the same meshtastic-st7789 driver, which already supports a lower-memory mode.

Expected impact

This should reduce runtime heap by removing the extra ST7789 backbuffer used by these targets.

Approximate savings by panel size:

  • 320x240: about 9.6 KB
  • 320x170: about 7.0 KB
  • 240x135: about 4.1 KB

No intended UI or feature changes beyond using less heap.

Testing

Verified locally:

  • platformio run -e heltec-mesh-node-t114

The other targets were updated in the same way because they use the same ST7789 driver path and reduced-memory flag.

Summary by CodeRabbit

  • New Features
    • Enabled lower-memory display handling on several device variants, helping firmware run more efficiently on supported OLED-based builds.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (26)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed SenseCAP Mesh-Tracker-X1 seeed_mesh_tracker_X1 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LILYGO T-Impulse Plus t-impulse-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-08-05. Updated for 79edf6b.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 62240b7d-bdf8-4b2e-8a99-23374e44f0a3

📥 Commits

Reviewing files that changed from the base of the PR and between fe6bf91 and 79edf6b.

📒 Files selected for processing (4)
  • variants/esp32s3/heltec_vision_master_t190/platformio.ini
  • variants/esp32s3/m5stack_cardputer_adv/platformio.ini
  • variants/nrf52840/heltec_mesh_node_t114/platformio.ini
  • variants/nrf52840/heltec_mesh_solar/platformio.ini

📝 Walkthrough

Walkthrough

This PR adds the -DOLEDDISPLAY_REDUCE_MEMORY compiler build flag to four board variant platformio.ini files: heltec_vision_master_t190, m5stack_cardputer_adv, heltec_mesh_node_t114, and heltec_mesh_solar. No other configuration changes are present.

Changes

OLED Memory Reduction Build Flags

Layer / File(s) Summary
Add reduced-memory OLED build flag
variants/esp32s3/heltec_vision_master_t190/platformio.ini, variants/esp32s3/m5stack_cardputer_adv/platformio.ini, variants/nrf52840/heltec_mesh_node_t114/platformio.ini, variants/nrf52840/heltec_mesh_solar/platformio.ini
Each environment's build_flags gains the -DOLEDDISPLAY_REDUCE_MEMORY compiler definition.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

Four little boards, each with a screen,
Now sipping memory, lean and keen,
One flag added, hop by hop,
-DOLEDDISPLAY_REDUCE_MEMORY on top!
🐇✨ Build flags tidy, carrots for me!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: enabling reduced-memory mode to lower heap usage on ST7789 display targets.
Description check ✅ Passed The description covers summary, rationale, impact, and testing, with only the repository attestation checklist left incomplete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@HarukiToreda HarukiToreda self-assigned this Jul 6, 2026
@HarukiToreda HarukiToreda added the cleanup Code cleanup or refactor label Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Firmware Size Report

22 targets | vs develop: 21 increased, 1 decreased, net +387,748 (+378.7 KB)

Target Size vs develop
picow 1,271,976 📈 +27,096 (+26.5 KB)
pico2w 1,246,660 📈 +26,144 (+25.5 KB)
rak11310 831,256 📈 +25,832 (+25.2 KB)
pico 808,504 📈 +25,816 (+25.2 KB)
seeed_xiao_rp2040 806,704 📈 +25,800 (+25.2 KB)
Show 17 more target(s)
Target Size vs develop
pico2 794,776 📈 +25,000 (+24.4 KB)
seeed_xiao_rp2350 792,920 📈 +24,984 (+24.4 KB)
t-deck-tft 3,832,064 📈 +21,392 (+20.9 KB)
heltec-vision-master-e213-inkhud 2,247,392 📈 +20,032 (+19.6 KB)
elecrow-adv-35-tft 3,435,520 📈 +18,896 (+18.5 KB)
seeed-xiao-s3 2,292,416 📈 +16,272 (+15.9 KB)
heltec-ht62-esp32c3-sx1262 2,150,576 📈 +15,584 (+15.2 KB)
heltec-v3 2,279,632 📈 +15,552 (+15.2 KB)
rak3312 2,287,600 📈 +15,360 (+15.0 KB)
rak11200 1,875,728 📈 +15,120 (+14.8 KB)
station-g3 2,281,088 📈 +14,736 (+14.4 KB)
station-g2 2,281,072 📈 +14,720 (+14.4 KB)
t-eth-elite 2,506,064 📈 +14,576 (+14.2 KB)
tlora-c6 2,382,272 📈 +13,968 (+13.6 KB)
heltec-v4 2,291,152 📈 +13,856 (+13.5 KB)
rak3172 182,492 📉 -3,804 (-3.7 KB)
wio-e5 239,444 📈 +816

Updated for a2cdd84

@thebentern
thebentern merged commit 93250d8 into develop Jul 6, 2026
97 of 98 checks passed
thebentern added a commit that referenced this pull request Jul 6, 2026
Only USE_TFTDISPLAY variants (t1, t096, wismeshtap) compile
TFTDisplay.cpp and need the lib's buffer_back; t114 and mesh-solar-tft
render through the meshtastic-st7789 driver, which handles the
reduced-memory configuration fine - as #10894 (merged from develop)
already established by defining the flag there. Remove the -U guard and
the per-variant -D (redundant with the arch-wide define in nrf52_base
on this branch). Both variants verified building.
thebentern added a commit that referenced this pull request Jul 6, 2026
…#10898)

* Right-size nRF52 heap tiers after 2.8.0 heap-exhaustion field reports

Field reports on 2.8.0 show nRF52840 devices at 99% heap (114/115 KB)
within minutes of boot; operator new asserts on OOM, so these devices
are one allocation from a reboot. The 2.8.0 cache sizing ladders gave
nRF52 the largest non-PSRAM tiers on the assumption that a BLE-only
part has a roomy heap - the arena is actually ~125 KB shared with the
FreeRTOS task stacks.

Per-target retiers (nRF52840 unless noted):
- Traffic Management cache 1000 -> 250 entries (10 KB -> 2.5 KB); the
  unclassified fallthrough drops 1000 -> 400 to match the classic-ESP32
  tier (also affects RP2040/RP2350)
- Warm node store 200 -> 100 entries (8 KB -> 4 KB); the non-XXAA
  fallthrough drops 320 -> 100 so an unclassified RAM-constrained part
  can't boot-allocate 12.8 KB
- MESSAGE_HISTORY_LIMIT 20 -> 10 (text pool 4.4 KB -> 2.2 KB), the tier
  classic ESP32 already ships
- MAX_RX_TOPHONE 32 -> 16, shrinking the static packet pool 70 -> 54
  slots (~6.6 KB of .bss returned to the heap arena)
- PacketHistory hash index off arch-wide (1 KB); O(n) over 240 records
  is negligible at LoRa packet rates
- OLEDDISPLAY_REDUCE_MEMORY arch-wide (~1 KB OLED back buffer); the five
  TFT variants -U it because TFTDisplay.cpp needs buffer_back for
  dirty-window diffing
- Drop the stale "for testing" 1024-entry TMM override on T1000-E

Measured on rak4631: heap arena grows 124,572 -> 131,180 B and boot
allocations drop ~15.7 KB, roughly +22 KB free heap on the field-report
device class.

Migration: the nRF52840 warm flash ring replays through place() (LRU),
so the newest 100 identities survive the shrink; the file backend
rejects oversized snapshots cleanly (new test covers this). Native
suites pass (536/536 Docker, 13/13 native-macos warm store); rak4631,
heltec-mesh-node-t114 (TFT) and tracker-t1000-e build green.

* Drop stale OLEDDISPLAY_REDUCE_MEMORY -U on t114 / mesh-solar-tft

Only USE_TFTDISPLAY variants (t1, t096, wismeshtap) compile
TFTDisplay.cpp and need the lib's buffer_back; t114 and mesh-solar-tft
render through the meshtastic-st7789 driver, which handles the
reduced-memory configuration fine - as #10894 (merged from develop)
already established by defining the flag there. Remove the -U guard and
the per-variant -D (redundant with the arch-wide define in nrf52_base
on this branch). Both variants verified building.
@HarukiToreda
HarukiToreda deleted the Reduce-Heap branch July 11, 2026 04:15
Itzdavid01 pushed a commit to Itzdavid01/firmware that referenced this pull request Sep 5, 2026
Itzdavid01 pushed a commit to Itzdavid01/firmware that referenced this pull request Sep 5, 2026
…meshtastic#10898)

* Right-size nRF52 heap tiers after 2.8.0 heap-exhaustion field reports

Field reports on 2.8.0 show nRF52840 devices at 99% heap (114/115 KB)
within minutes of boot; operator new asserts on OOM, so these devices
are one allocation from a reboot. The 2.8.0 cache sizing ladders gave
nRF52 the largest non-PSRAM tiers on the assumption that a BLE-only
part has a roomy heap - the arena is actually ~125 KB shared with the
FreeRTOS task stacks.

Per-target retiers (nRF52840 unless noted):
- Traffic Management cache 1000 -> 250 entries (10 KB -> 2.5 KB); the
  unclassified fallthrough drops 1000 -> 400 to match the classic-ESP32
  tier (also affects RP2040/RP2350)
- Warm node store 200 -> 100 entries (8 KB -> 4 KB); the non-XXAA
  fallthrough drops 320 -> 100 so an unclassified RAM-constrained part
  can't boot-allocate 12.8 KB
- MESSAGE_HISTORY_LIMIT 20 -> 10 (text pool 4.4 KB -> 2.2 KB), the tier
  classic ESP32 already ships
- MAX_RX_TOPHONE 32 -> 16, shrinking the static packet pool 70 -> 54
  slots (~6.6 KB of .bss returned to the heap arena)
- PacketHistory hash index off arch-wide (1 KB); O(n) over 240 records
  is negligible at LoRa packet rates
- OLEDDISPLAY_REDUCE_MEMORY arch-wide (~1 KB OLED back buffer); the five
  TFT variants -U it because TFTDisplay.cpp needs buffer_back for
  dirty-window diffing
- Drop the stale "for testing" 1024-entry TMM override on T1000-E

Measured on rak4631: heap arena grows 124,572 -> 131,180 B and boot
allocations drop ~15.7 KB, roughly +22 KB free heap on the field-report
device class.

Migration: the nRF52840 warm flash ring replays through place() (LRU),
so the newest 100 identities survive the shrink; the file backend
rejects oversized snapshots cleanly (new test covers this). Native
suites pass (536/536 Docker, 13/13 native-macos warm store); rak4631,
heltec-mesh-node-t114 (TFT) and tracker-t1000-e build green.

* Drop stale OLEDDISPLAY_REDUCE_MEMORY -U on t114 / mesh-solar-tft

Only USE_TFTDISPLAY variants (t1, t096, wismeshtap) compile
TFTDisplay.cpp and need the lib's buffer_back; t114 and mesh-solar-tft
render through the meshtastic-st7789 driver, which handles the
reduced-memory configuration fine - as meshtastic#10894 (merged from develop)
already established by defining the flag there. Remove the -U guard and
the per-variant -D (redundant with the arch-wide define in nrf52_base
on this branch). Both variants verified building.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Code cleanup or refactor enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants