Skip to content

boards: free flash in the STM32G431 cansock and stm32l0538-disco:nsh configurations - #22081

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
zyfeier:boards-flash-headroom
Nov 20, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
zyfeier:boards-flash-headroom

Conversation

@zyfeier

@zyfeier zyfeier commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Three small-flash configurations are within a few hundred bytes of
their limit on master, so ordinary changes in core components make the
Linux (arm-stm32l-u-g) CI job fail on unrelated PRs:

configuration flash used on master free
nucleo-g431rb:cansock 128 KB 130600 472
b-g431b-esc1:cansock 128 KB 130600 472
stm32l0538-disco:nsh 64 KB 64760 776

For example, nucleo-g431rb:cansock overflows by 88 bytes in the CI of
an open PR that only changes the scheduler.

This PR disables features these configurations do not need, so each of
them gets about 4 KB of headroom:

  • boards/stm32g4/cansock: disable the dd tool, which the SocketCAN
    demo does not use, and TLS_EMUTLS. NET_STATISTICS and the CAN
    tools (candump, cansend) are kept.
  • boards/stm32l0538-disco/nsh: disable the NSH alias command and
    TLS_EMUTLS, and enable LIBC_ATOMIC_NOINLINE (added in libc/machine: add an option to not inline the atomic functions #22053) so
    that the interrupt-disabling atomic operations are built once instead
    of inlined at every call.

TLS_EMUTLS only gives per-thread copies of __thread variables. None
of these images has any: nm finds no __emutls_v.* symbol, so
disabling it changes no behavior.

Impact

  • Users: dd is no longer in the two cansock configurations, and
    alias is no longer in stm32l0538-disco:nsh. No other command or
    feature changes.
  • Build: none. Hardware: only these three configurations.
  • Documentation, security, compatibility: no impact.

Testing

Host: Ubuntu, Arm GNU Toolchain 13.2.Rel1 (the CI version), master
ed12237. make builds use EXTRAFLAGS="-Wno-cpp -Werror" as in CI.

configuration before after saved free after
nucleo-g431rb:cansock 130600 126836 3764 4236
b-g431b-esc1:cansock 130600 126836 3764 4236
stm32l0538-disco:nsh 64760 61472 3288 4064
$ ./tools/configure.sh nucleo-g431rb:cansock && make
Memory region         Used Size  Region Size  %age Used
           flash:      126836 B       128 KB     96.77%
$ ./tools/configure.sh stm32l0538-disco:nsh && make
Memory region         Used Size  Region Size  %age Used
           flash:       61472 B        64 KB     93.80%

The CMake builds that CI runs also link: nucleo-g431rb:cansock
127040 B, stm32l0538-disco:nsh 61520 B.

make savedefconfig gives no diff for the three configurations, and
tools/checkpatch.sh -c -u -m -g passes.

Not tested on hardware.

nucleo-g431rb:cansock and b-g431b-esc1:cansock use 130600 of the
131072 bytes of flash, and ordinary changes in core components push
them over the limit.

Disable the dd tool, which the SocketCAN demo does not use, and the
per-thread copies of emulated TLS variables, which no code in these
images uses.  This frees about 3.7 KB.  NET_STATISTICS and the CAN
tools are kept.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
The configuration already uses full LTO and uses 64760 of the 65536
bytes of flash, so ordinary changes in core components push it over
the limit.

Disable the NSH alias command and the per-thread copies of emulated
TLS variables, which no code in this image uses.  Also enable
LIBC_ATOMIC_NOINLINE: the atomic operations then disable and restore
the interrupts in one copy of each function instead of an inline
sequence at every call.  Together this frees 3288 bytes.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
@zyfeier
zyfeier marked this pull request as ready for review November 20, 2026 02:18
@github-actions github-actions Bot added Size: XS The size of the change in this PR is very small Board: arm labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown

@xiaoxiang781216
xiaoxiang781216 merged commit ff4d9b2 into apache:master Nov 20, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: arm Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants