Skip to content

Build LilyGo T-Lora V2.1 1.6 with -Os again instead of -O0 - #3685

Open
marcelverdult wants to merge 1 commit into
meshcore-dev:devfrom
marcelverdult:upstream-pr/tlora-v2-1-optimization
Open

marcelverdult wants to merge 1 commit into
meshcore-dev:devfrom
marcelverdult:upstream-pr/tlora-v2-1-optimization

Conversation

@marcelverdult

Copy link
Copy Markdown
Contributor

[LilyGo_TLora_V2_1_1_6] in variants/lilygo_tlora_v2_1/platformio.ini has

build_unflags = -Os
build_flags =
  ...
  -Os -ffunction-sections -fdata-sections  ; Optimize for size

PlatformIO applies build_unflags after merging all build flags, so it removes every -Os: the one the Arduino ESP32 framework passes and the one the variant adds itself. No other -O is left, so all 9 LilyGo_TLora_V2_1_1_6_* environments are compiled at GCC's default -O0. The lines came with #62 ("Configure build environment for optimizing firmware size"); the effect is the opposite.

The framework already passes -Os -ffunction-sections -fdata-sections, as for every other ESP32 board, so this removes both lines.

Evidence

On dev 46216b2, before and after this change, PlatformIO 6.2.0:

  • compile_commands.json of all 9 environments: before, none of the 269 to 305 translation units per environment has an -O option; after, every one has -Os.
  • DW_AT_producer of src/Mesh.cpp.o (_repeater): before GNU C++11 8.4.0 -mlongcalls -ggdb -std=gnu++11 ..., after GNU C++11 8.4.0 -mlongcalls -ggdb -Os -std=gnu++11 ....
  • All 9 environments build. Flash as printed by pio run, app partition min_spiffs.csv (1966080 bytes):
Environment Flash before Flash after Static RAM
companion_radio_ble 1916869 (97.5 %) 1479185 (75.2 %) -48
companion_radio_usb 992109 641081 -48
companion_radio_wifi 1520009 1133309 -64
kiss_modem 861157 580953 -48
repeater 1663953 1205433 -52
repeater_bridge_espnow 1677837 1216121 -52
repeater_bridge_rs232 1669305 1207785 -52
room_server 1642233 1200813 -52
terminal_chat 904873 601761 -48
  • Heltec_v3_repeater and Tbeam_SX1276_repeater, as a control, are unchanged.

Stack. #62 also raised ARDUINO_LOOP_STACK_SIZE to 16384 after crashes while signing. That stays. With -Os the ed25519 frames shrink a lot (-fstack-usage with the same compile lines: fe_mul 3632 -> 192 bytes, fe_sq 2144 -> 144), so stack headroom only grows. Whether the crashes back then came from -O0 I have not verified.

Not tested on hardware. I do not have a T-Lora V2.1 1.6. This changes the generated code of the whole firmware for these environments, so a boot, advert, receive and send check by someone with the board would be welcome.

Related. #2614 and #1648 change the same file further down (build_flags of single environments); no textual conflict with these two lines.

The variant set `build_unflags = -Os` and added `-Os -ffunction-sections
-fdata-sections` to `build_flags`. PlatformIO applies build_unflags after
merging build_flags, so it removes every -Os, the framework one and the
variant one alike. Every translation unit of the 9
LilyGo_TLora_V2_1_1_6_* envs (269 to 305 per env) was compiled without
any -O option, i.e. at GCC's default -O0 (checked in
compile_commands.json and in DW_AT_producer).

The Arduino ESP32 framework already passes -Os -ffunction-sections
-fdata-sections, like for every other ESP32 board, so both lines go.

Measured on upstream/dev 46216b2, all 9 envs build:
flash -280 KB to -462 KB per env (-23 % to -35 %),
companion_radio_ble 97.5 % -> 75.2 % of the app partition,
static RAM -48 to -64 bytes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant