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 similarity index 100% rename from esp8266/scripts/_boot.py rename to esp8266/modules/_boot.py diff --git a/esp8266/scripts/flashbdev.py b/esp8266/modules/flashbdev.py similarity index 100% rename from esp8266/scripts/flashbdev.py rename to 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)