Squeezing Tasmota into 512KB ESP8266 (ESP-12) module

Tasmota is a custom firmware for ESP8266/ESP32 devices, used mostly as a replacement for the stock firmware in a huge amount of Internet connected home gadgets. It makes it very easy to connect them with automation software like HomeAssistant, openHAB or Domoticz.

It comes with support for a great number of peripherals but this comes at a price: size. I still have some of the ESP-12 modules with only 512KB (4Mbit) of Flash. Tasmota comes in multiple flavors depending on what you need:

  • Recommended binary with most drivers ~587k
  • Localized versions of the recommended binary which have similar size
  • HW specific ones like KNX, Sonoff Zigbee Bridge or IR support
  • Minimal which is only ~379k in size but should not be used by itself as it's basically a bootstrap for OTA
  • Lite which just has some basic drivers and sensors support in ~477k

The Lite version sounded like a perfect fit (quite literally) so I flashed a module with it and everything seemed fine. Until I tried to save the configuration. It seemed that every time it restarted, the default configuration was loaded instead of one I set. Looking at logs confirmed it:

load 0x4010f000, len 3456, room 16
tail 0
chksum 0x84
csum 0x84
v372a3ec2
~ld
   00:00:00 CFG: Use defaults
00:00:00 Project tasmota Tasmota Version 8.2.0(lite)-STAGE

Searching the Tasmota GitHub issues, I found I wasn't the only one. It seems that the binaries are linked for a bigger flash and I assume that the config area is outside of the actual flash therefore any write there would immediately get lost.

Following advice of Adrian Scillato I decided on building my own binary that would fit in the 512KB that I have. Here are the steps if you want to build your own:

  1. Prepare the Tasmota compiling tools. Doesn't matter which one as long as you're able to edit the source code
  2. Download the custom config into the /tasmota directory inside of Tasmota sources. This basically disables everything except light/dimmer, web UI and HomeAssistant support. Should use only ~87% of the flash, leaving the rest for config
  3. Update the platformio.ini file to use the smaller flash:
[common]
board                       = esp01
board_build.ldscript        = eagle.flash.512k.ld
  1. Compile the binary and flash it to the device

In case you don't want to go through building your own binary, here's my ultralite build of Tasmota 9.2.0: tasmota-9.2.0-ultralite.bin. I would still advise you to compile your own as it's not very secure to trust unknown binaries ;)

Following an ask by Michelle, I also made a build that includes the timers: tasmota-9.2.0-ultralite+timers.bin :)