Skip to content

Optimization flags for all NRF52 targets to reduce code size#8854

Merged
thebentern merged 6 commits into
meshtastic:developfrom
Meshlink-Team:reduce-size-flash-nrf52
Dec 4, 2025
Merged

Optimization flags for all NRF52 targets to reduce code size#8854
thebentern merged 6 commits into
meshtastic:developfrom
Meshlink-Team:reduce-size-flash-nrf52

Conversation

@Donix212

@Donix212 Donix212 commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

The PL #8825 provided significant size reduction for rak4631 target. The same concept was applied here to achieve size reduction for all NRF52 targets.

Screenshot 2025-12-03 at 22 24 22

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • meshlink
    • nrf52_promicro_tcxo

@CLAassistant

CLAassistant commented Dec 3, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ macvenez
❌ Donato Santoro


Donato Santoro seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR applies optimization flags to all NRF52 targets to reduce code size, extending the approach from PR #8825 (originally for rak4631) to the entire NRF52 family.

Key changes:

  • Changed build_type from debug to release in the base nrf52.ini configuration
  • Added -Os (optimize for size) flag and removed debug symbols via build_unflags at the nrf52_base level
  • Consolidated meshlink_eink variant into the main meshlink configuration using conditional -D USE_EINK flags
  • Added RADIOLIB exclusion flags to multiple targets for additional size reduction

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
variants/nrf52840/nrf52.ini Central configuration changes: added release build type, -Os flag, and removed debug flags; applies to all NRF52 targets
variants/nrf52840/rak4631/platformio.ini Removed duplicate optimization flags now inherited from parent; contains indentation issue on line 15
variants/nrf52840/meshlink/platformio.ini Added RADIOLIB exclusion flags and consolidated meshlink_eink configuration into this file
variants/nrf52840/meshlink_eink/variant.h Deleted - consolidated into shared meshlink variant
variants/nrf52840/meshlink_eink/variant.cpp Deleted - consolidated into shared meshlink variant
variants/nrf52840/meshlink_eink/platformio.ini Deleted - configuration moved to meshlink/platformio.ini
variants/nrf52840/diy/nrf52_promicro_diy_tcxo/platformio.ini Added RADIOLIB exclusion flags for size reduction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread variants/nrf52840/rak4631/platformio.ini Outdated
@thebentern

Copy link
Copy Markdown
Contributor

@Donix212 why was the meshlink eink environment removed?

@macvenez

macvenez commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

@Donix212 why was the meshlink eink environment removed?

We moved it inside the same "Meshlink" folder but with its own eink variant, just as done on nrf52_promicro

@thebentern thebentern added the enhancement New feature or request label Dec 4, 2025
@thebentern thebentern merged commit 2f4eb25 into meshtastic:develop Dec 4, 2025
77 of 78 checks passed
@macvenez

macvenez commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

Hi @thebentern @NomDeTom I've just seen that on NRF52 schematic PDF file one can also use sx1276 but it's "non-preferred" while in variants/nrf52840/diy/nrf52_promicro_diy_tcxo/platformio.ini file we put -DRADIOLIB_EXCLUDE_SX127X=1 is it better to remove this line as someone might still use SX127x?

@NomDeTom

NomDeTom commented Dec 5, 2025

Copy link
Copy Markdown
Collaborator

Hi @thebentern @NomDeTom I've just seen that on NRF52 schematic PDF file one can also use sx1276 but it's "non-preferred" while in variants/nrf52840/diy/nrf52_promicro_diy_tcxo/platformio.ini file we put -DRADIOLIB_EXCLUDE_SX127X=1 is it better to remove this line as someone might still use SX127x?

Huh, I hadn't noticed this one. I'll do a pr to fix that in a bit.

@NomDeTom NomDeTom mentioned this pull request Dec 6, 2025
8 tasks
@NomDeTom

NomDeTom commented Dec 6, 2025

Copy link
Copy Markdown
Collaborator

@macvenez #8873

edit: and thanks for pointing this out, before the mob of RMF95 users came at me with pitchforks and flashlights.

@macvenez

macvenez commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

@NomDeTom
I don't want to be tedious but could we have left the macro for excluding sx128x? There seems to be no hint on using sx128x on the schematic pdf
Thanks!

@NomDeTom

NomDeTom commented Dec 6, 2025

Copy link
Copy Markdown
Collaborator

@macvenez I think we'll leave it - promicro is a DIY target, so someone may want it. Unless you have a compelling reason to remove it?

@Donix212 Donix212 deleted the reduce-size-flash-nrf52 branch December 6, 2025 17:14
duraseb pushed a commit to duraseb/meshtastic_firmware that referenced this pull request Dec 8, 2025
…tic#8854)

* changes of variants/nrf52840/nrf52.ini and variants/nrf52840/rak4631/platformio.ini

* try for nrf52 size reduction, faketec exclude unused radios and meshlink refactor

* can't exclude LR11X0 as in schematic there's option for LR1121

* remove -Map flag and -Wl

* removed spaces causing error

---------

Co-authored-by: macvenez <macvenez@gmail.com>
jeek pushed a commit to jeek/Meshtastic-Exploiteers-Hacker-Pager that referenced this pull request Jun 30, 2026
…tic#8854)

* changes of variants/nrf52840/nrf52.ini and variants/nrf52840/rak4631/platformio.ini

* try for nrf52 size reduction, faketec exclude unused radios and meshlink refactor

* can't exclude LR11X0 as in schematic there's option for LR1121

* remove -Map flag and -Wl

* removed spaces causing error

---------

Co-authored-by: macvenez <macvenez@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants