Skip to content

Conversation

@CapnBry
Copy link
Member

@CapnBry CapnBry commented Dec 19, 2025

Many changes to shrink the firmware binary to allow ESP8285-based receivers to web flash again. WARNING: Change from SPIFFS to LittleFS means any custom hardware.json / options.json will be lost.

Porblem

Users who have flashed with 4.0.0-RC1 are unable to flash new binaries to their devices. Failing with "Not enough space". This is mostly LBT users as their binary is slightly larger than the ISM.

Update: 'firmware.bin' size 424901
Free space = 409600
ERROR[4]: Not Enough Space
write failed to write 154
write failed to write 536
write failed to write 536
write failed to write 536
write failed to write 536
write failed to write 536
write failed to write 536
write failed to write 536

Ensmallen (verb) To Make Smaller

  • Convert from SPIFFS to LittleFS. Saves a couple KB but uses more RAM. Users with custom hardware.json or options.json will lose them on update as there is no way to in-place convert the filesystem. We needed to do this anyway, I was tired of the deprecated warnings on every build.
  • Use linear interpolation for Barometer's altitude calculation (esp82xx only), allows removing pow() and exp() from the source for a few KB. Note that 6 points are used for interpolating the pressure -> altitude conversion at 1000m meter intervals up to 5000m, after which the error will grow exponentially. Error within the range is at most ~2.5% (500m will read 488m).
  • Minor AsyncWebServer handler binding saves a couple hundred bytes or so.
  • Remove internal assertion code in the platform library with -DNDEBUG. Saves a couple KB flash and minor RAM.
  • Remove LWIP_FEATURES. This removes IP fragmentation and reassembly which may be a problem but wifi still seems to work along with firmware flashing so maybe we don't need it? Also removed are NAT/forwarding, 169.254.x.x IP auto-assign, and TCP SACK-OUT. MTU remains the same at 536 bytes. Saves quite a bit of flash and RAM.
  • Remove float support in printf/scanf. We don't use these anyway but the linker was being forced to include them. Saves many KB.
  • Airport buffers on the RX are now only allocated if using Airport. I needed to get some RAM back thanks to LittleFS needing more, so this was low hanging fruit. Saves 150 bytes RAM but adds a few tens of bytes of code.
// Baseline
RAM:   [======    ]  60.8% (used 49828 bytes from 81920 bytes)
Flash: [======    ]  57.5% (used 569928 bytes from 991216 bytes)
576784 bytes, now 420553 bytes
// branch
RAM:   [======    ]  60.6% (used 49684 bytes from 81920 bytes)
Flash: [=====     ]  53.6% (used 531336 bytes from 991216 bytes)
538223 bytes, now 392844 bytes

Overall size decreased by 27709 compressed bytes.

Copy link
Collaborator

@pkendall64 pkendall64 left a comment

Choose a reason for hiding this comment

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

We should rename the the src/elrs.flash.1m64.ld file as it's not 64k for the FS, it's 32k. Maybe just call it src/elrs.flash.ld.

Everything else looks sensible. Will approve after testing.

@CapnBry
Copy link
Member Author

CapnBry commented Dec 20, 2025

Yeah good idea. I went with elrs.flash.1m.ld since it is only used for the 1MB esp82xx chips and avoid confusion with it possibly being used for ESP32.

Also tested on a RadioMaster ER8GV to verify the VSpd/BaroAlt looked good (ESP32 SX1280)

@pkendall64
Copy link
Collaborator

@CapnBry I added another commit that changes the way we use ArduinoJson in devWiFi.cpp so we save another 1kB.

Copy link
Collaborator

@pkendall64 pkendall64 left a comment

Choose a reason for hiding this comment

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

Tested on 8285 and ESP32. All looks good here.

@pkendall64 pkendall64 merged commit 8f80eef into ExpressLRS:master Dec 22, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants