diff options
author | Damien George <damien.p.george@gmail.com> | 2016-05-11 16:57:29 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-06-29 13:59:19 +0100 |
commit | db80c0ed4678f4bacc6c7c9b67cbf26846fc21be (patch) | |
tree | e791f46f5b23eba79ff6e1eaa4a6383264faddd4 /esp8266 | |
parent | b9e3fde21a1de61c69e283ab7d756297655a2496 (diff) | |
download | micropython-db80c0ed4678f4bacc6c7c9b67cbf26846fc21be.tar.gz micropython-db80c0ed4678f4bacc6c7c9b67cbf26846fc21be.zip |
esp8266: Enable frozen bytecode, with scripts in modules/ subdir.
To start with, the critical scripts _boot.py and flashbdev.py are frozen
to improve performance and reduce RAM consumption.
Saves about 1000 bytes of heap RAM for a bare boot with filesystem.
Diffstat (limited to 'esp8266')
-rw-r--r-- | esp8266/Makefile | 18 | ||||
-rw-r--r-- | esp8266/modules/_boot.py (renamed from esp8266/scripts/_boot.py) | 0 | ||||
-rw-r--r-- | esp8266/modules/flashbdev.py (renamed from esp8266/scripts/flashbdev.py) | 0 | ||||
-rw-r--r-- | esp8266/mpconfigport.h | 2 |
4 files changed, 20 insertions, 0 deletions
diff --git a/esp8266/Makefile b/esp8266/Makefile index 946440bee9..00826cfe46 100644 --- a/esp8266/Makefile +++ b/esp8266/Makefile @@ -8,9 +8,12 @@ MICROPY_PY_USSL = 1 # include py core make definitions include ../py/py.mk +MPY_CROSS = ../mpy-cross/mpy-cross +MPY_TOOL = ../tools/mpy-tool.py MAKE_FROZEN = ../tools/make-frozen.py SCRIPTDIR = scripts +FROZEN_MPY_DIR = modules PORT ?= /dev/ttyACM0 BAUD ?= 115200 CROSS_COMPILE = xtensa-lx106-elf- @@ -131,6 +134,9 @@ DRIVERS_SRC_C = $(addprefix drivers/,\ SRC_S = \ gchelper.s \ +FROZEN_MPY_PY_FILES := $(shell find $(FROZEN_MPY_DIR)/ -type f -name '*.py') +FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy)) + OBJ = OBJ += $(PY_O) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) @@ -139,6 +145,7 @@ OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) +OBJ += $(BUILD)/$(BUILD)/frozen_mpy.o #OBJ += $(BUILD)/pins_$(BOARD).o # List of sources for qstr extraction @@ -163,6 +170,17 @@ $(BUILD)/frozen.c: $(wildcard $(SCRIPTDIR)/*) $(CONFVARS_FILE) $(ECHO) "Generating $@" $(Q)$(MAKE_FROZEN) $(SCRIPTDIR) > $@ +# to build .mpy files from .py files +$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py + @$(ECHO) "MPY $<" + $(Q)$(MKDIR) -p $(dir $@) + $(Q)$(MPY_CROSS) -o $@ -s $(^:$(FROZEN_MPY_DIR)/%=%) $^ + +# to build frozen_mpy.c from all .mpy files +$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h + @$(ECHO) "Creating $@" + $(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@ + .PHONY: deploy deploy: $(BUILD)/firmware-combined.bin diff --git a/esp8266/scripts/_boot.py b/esp8266/modules/_boot.py index c950de6758..c950de6758 100644 --- a/esp8266/scripts/_boot.py +++ b/esp8266/modules/_boot.py diff --git a/esp8266/scripts/flashbdev.py b/esp8266/modules/flashbdev.py index 07ed966020..07ed966020 100644 --- a/esp8266/scripts/flashbdev.py +++ b/esp8266/modules/flashbdev.py diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h index 544edc408f..90dbc00098 100644 --- a/esp8266/mpconfigport.h +++ b/esp8266/mpconfigport.h @@ -74,7 +74,9 @@ #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) #define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_MODULE_FROZEN_STR (1) +#define MICROPY_MODULE_FROZEN_MPY (1) #define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str32 +#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool #define MICROPY_FATFS_ENABLE_LFN (1) #define MICROPY_FATFS_RPATH (2) |