PlatformIO Community

Less voluminous AsyncTCP servers on ESP8266

May be someone here has any idea on this: I am running my own firmware on smart sockets driven by ESP8266 (ESP8285, actually). This firmware is using the Fauxmo library to bring Alexa compatibility, a telnet server to enable remote logging, a Modbus server and finally a web server for configuration of the socket over its own WiFi in config mode.

All these servers are built on the AsyncTCP stack. Over time the used libraries have grown and grown, and now I have a binary file to be flashed that will occupy >50% of the device’s flash - too big to be sent OTA any more. The user code seems to use no more than 60kB in total, so the remainder obviously is sitting in the core libraries.

Is there any way to reduce the size of the underlying AsyncTCP, ESP8266WiFi etc. codes?


Okay, let me try another approach: is there a way to use objdump or a similar tool on the generated firmware.elf file? With it I could at least see the sizes of the components.

I tried the Ubuntu objdump, but it seems to be slightly confused when confronted with an ESP8266 firmware.elf:

The compiler flags are already with -Os, so no (meaningful) magical switches to press anymore in the compiler.

Throw your .elf file in the tool to get some graphical idea on what memory is eating up what.

The best amount of code to solve a problem is no code. If you lose your dependency on big libraries, or reduce their featuresets (some have #ifdef..s), the code will shrink.


I was looking for the spot where Platformio is collecting compiler flags and options to build a library and was not successful yet. The AsyncWebServer lib once was notorious to spend a full 100k on the regex functions for path names, these are activated by some -DASYNCWEBSERVER_REGEX flag. I wanted to make sure this is not set when the lib is built.

In the CLI, do

pio run -t clean
pio run -v -j1 > compile.log 2>&1

and all compiler commands will be saved in compile.log after it’s done.

(Would also be in the GUI at project tasks → Clean + Advanced → Verbose Build, but does a parallel build and doesn’t save to file, so harder to look at)

Thanks again. The output is overwhelming, but helpful. I did not find the said flag, though. Seems I will need to go hunting for features I do not need (“SPIFFS Editor”? WTF?) in the hope to be able to disable those with flags.
The “ESP Async Web Server” lib is a core lib. I will need to have a local copy first.