Freeing up Flash storage on ESP8266 board build

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
gregspam
Posts: 2
Joined: Thu Aug 27, 2020 4:20 pm

Freeing up Flash storage on ESP8266 board build

Post by gregspam » Fri Aug 28, 2020 12:28 pm

Hi,

I'm in the process of squeezing out as much free flash space as possible on an ESP8266 for my frozen modules. This is what my current board definition looks like:

Code: Select all

boards/GENERIC_KOOJI_1M/manifest.py
::::::::::::::
include("$(PORT_DIR)/boards/manifest.py")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
::::::::::::::
boards/GENERIC_KOOJI_1M/mpconfigboard.h
::::::::::::::
#define MICROPY_HW_BOARD_NAME "ESP module"
#define MICROPY_HW_MCU_NAME "ESP8266"

#define MICROPY_PERSISTENT_CODE_LOAD    (1)
#define MICROPY_EMIT_XTENSA             (1)
#define MICROPY_EMIT_INLINE_XTENSA      (1)

#define MICROPY_DEBUG_PRINTERS          (1)
#define MICROPY_ERROR_REPORTING         (MICROPY_ERROR_REPORTING_NORMAL)

#define MICROPY_READER_VFS              (MICROPY_VFS)
#define MICROPY_VFS                     (1)

#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS  (1)
#define MICROPY_PY_IO_FILEIO            (1)
#define MICROPY_PY_SYS_STDIO_BUFFER     (1)
#define MICROPY_PY_UASYNCIO             (1)
#define MICROPY_PY_URE_SUB              (1)
#define MICROPY_PY_UCRYPTOLIB           (1)
#define MICROPY_PY_FRAMEBUF             (1)
::::::::::::::
boards/GENERIC_KOOJI_1M/mpconfigboard.mk
::::::::::::::
LD_FILES = boards/esp8266_1m.ld

MICROPY_PY_BTREE ?= 1
MICROPY_VFS_FAT ?= 1
MICROPY_VFS_LFS2 ?= 1

FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py
I've commented out most of the frozen modules I don't need in the overall manifest:

Code: Select all

::::::::::::::
boards/manifest.py 
::::::::::::::
freeze("$(PORT_DIR)/modules")
#freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
#freeze("$(MPY_DIR)/drivers/dht", "dht.py")
#freeze("$(MPY_DIR)/drivers/onewire")
#include("$(MPY_DIR)/extmod/webrepl/manifest.py")
This gives me a fully working build, but with about 7k space missing to add the totality of my frozen modules. What can I remove from here? I thought I could remove btree, but doing this resulted in the filesystem not working (could write files but they were empty) so I guess it is needed for that. I don't think I need SSL/TLS but haven't worked out how to successfully remove that from the build. Any suggestions on what I might be able to cull? My project uses uasyncio, mqtt_as and the machine.Pin and their dependencies, that's about it.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Freeing up Flash storage on ESP8266 board build

Post by Roberthh » Fri Aug 28, 2020 12:38 pm

You can safely set BTREE to 0, which I do by default. It is not related to the file operations. If you have experienced that, there must be a different reason for that.

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Freeing up Flash storage on ESP8266 board build

Post by rcolistete » Fri Aug 28, 2020 9:20 pm

See this commit, "ESP8266 1MB made compatible with ulab module", where 'ports/esp8266/boards/esp8266_1m.ld' is changed, so
- firmware (irom0) space is increased to 618k (was 572k);
- filesystem is reduced to 350k (was 396k).
You can obviously reduce the file system with diferent values.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

Post Reply