From daa948fe05ee165a00a02f0b529c15601fe5ac5f Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 5 Jun 2024 23:09:09 +1000 Subject: [PATCH] esp8266: Rework board variant support to require mpconfigvariant file. Following how esp32 has been reworked, each variant now has a corresponding `mpconfigvariant_VARIANT.mk` file associated with it. The base variant also has a `mpconfigvariant.mk` file because it has options that none of the other variants use. Signed-off-by: Damien George --- ports/esp8266/Makefile | 15 +++++- .../boards/ESP8266_GENERIC/mpconfigboard.mk | 51 +------------------ .../boards/ESP8266_GENERIC/mpconfigvariant.mk | 12 +++++ .../mpconfigvariant_FLASH_1M.mk | 10 ++++ .../mpconfigvariant_FLASH_512K.mk | 7 +++ .../ESP8266_GENERIC/mpconfigvariant_OTA.mk | 10 ++++ 6 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant.mk create mode 100644 ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_1M.mk create mode 100644 ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_512K.mk create mode 100644 ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_OTA.mk diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 1b9e9623b..cd94a38a7 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -16,6 +16,12 @@ endif $(error Invalid BOARD specified: $(BOARD_DIR)) endif +ifneq ($(BOARD_VARIANT),) +ifeq ($(wildcard $(BOARD_DIR)/mpconfigvariant_$(BOARD_VARIANT).mk),) +$(error Invalid BOARD_VARIANT specified: $(BOARD_VARIANT)) +endif +endif + # If the build directory is not given, make it reflect the board name (and # optionally the board variant). ifneq ($(BOARD_VARIANT),) @@ -26,8 +32,13 @@ endif include ../../py/mkenv.mk -# Optional --include $(BOARD_DIR)/mpconfigboard.mk +# Include board specific .mk file, and optional board variant .mk file. +include $(BOARD_DIR)/mpconfigboard.mk +ifeq ($(BOARD_VARIANT),) +-include $(BOARD_DIR)/mpconfigvariant.mk +else +include $(BOARD_DIR)/mpconfigvariant_$(BOARD_VARIANT).mk +endif # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h diff --git a/ports/esp8266/boards/ESP8266_GENERIC/mpconfigboard.mk b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigboard.mk index 69dbeb5fb..a9d8908c3 100644 --- a/ports/esp8266/boards/ESP8266_GENERIC/mpconfigboard.mk +++ b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigboard.mk @@ -1,50 +1 @@ -ifeq ($(BOARD_VARIANT),) -LD_FILES = boards/esp8266_2MiB.ld - -MICROPY_PY_ESPNOW ?= 1 -MICROPY_PY_BTREE ?= 1 -MICROPY_VFS_FAT ?= 1 -MICROPY_VFS_LFS2 ?= 1 - -# Add asyncio and extra micropython-lib packages (in addition to the port manifest). -FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_2MiB.py - -# Configure mpconfigboard.h. -CFLAGS += -DMICROPY_ESP8266_2M -endif - -ifeq ($(BOARD_VARIANT),FLASH_1M) -LD_FILES = boards/esp8266_1MiB.ld - -MICROPY_PY_ESPNOW ?= 1 -MICROPY_PY_BTREE ?= 1 -MICROPY_VFS_LFS2 ?= 1 - -# Note: Implicitly uses the port manifest. - -# Configure mpconfigboard.h. -CFLAGS += -DMICROPY_ESP8266_1M -endif - -ifeq ($(BOARD_VARIANT),OTA) -LD_FILES = boards/esp8266_ota.ld - -MICROPY_PY_ESPNOW ?= 1 -MICROPY_PY_BTREE ?= 1 -MICROPY_VFS_LFS2 ?= 1 - -# Note: Implicitly uses the port manifest. - -# Configure mpconfigboard.h. -CFLAGS += -DMICROPY_ESP8266_1M -endif - -ifeq ($(BOARD_VARIANT),FLASH_512K) -LD_FILES = boards/esp8266_512kiB.ld - -# Note: Use the minimal manifest.py. -FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_512kiB.py - -# Configure mpconfigboard.h. -CFLAGS += -DMICROPY_ESP8266_512K -endif +# There are no common .mk settings among the variants, so this file is empty. diff --git a/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant.mk b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant.mk new file mode 100644 index 000000000..926fc15da --- /dev/null +++ b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant.mk @@ -0,0 +1,12 @@ +LD_FILES = boards/esp8266_2MiB.ld + +MICROPY_PY_ESPNOW ?= 1 +MICROPY_PY_BTREE ?= 1 +MICROPY_VFS_FAT ?= 1 +MICROPY_VFS_LFS2 ?= 1 + +# Add asyncio and extra micropython-lib packages (in addition to the port manifest). +FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_2MiB.py + +# Configure mpconfigboard.h. +CFLAGS += -DMICROPY_ESP8266_2M diff --git a/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_1M.mk b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_1M.mk new file mode 100644 index 000000000..6baad1147 --- /dev/null +++ b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_1M.mk @@ -0,0 +1,10 @@ +LD_FILES = boards/esp8266_1MiB.ld + +MICROPY_PY_ESPNOW ?= 1 +MICROPY_PY_BTREE ?= 1 +MICROPY_VFS_LFS2 ?= 1 + +# Note: Implicitly uses the port manifest. + +# Configure mpconfigboard.h. +CFLAGS += -DMICROPY_ESP8266_1M diff --git a/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_512K.mk b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_512K.mk new file mode 100644 index 000000000..bbbdbb909 --- /dev/null +++ b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_512K.mk @@ -0,0 +1,7 @@ +LD_FILES = boards/esp8266_512kiB.ld + +# Note: Use the minimal manifest.py. +FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_512kiB.py + +# Configure mpconfigboard.h. +CFLAGS += -DMICROPY_ESP8266_512K diff --git a/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_OTA.mk b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_OTA.mk new file mode 100644 index 000000000..759eab3dc --- /dev/null +++ b/ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_OTA.mk @@ -0,0 +1,10 @@ +LD_FILES = boards/esp8266_ota.ld + +MICROPY_PY_ESPNOW ?= 1 +MICROPY_PY_BTREE ?= 1 +MICROPY_VFS_LFS2 ?= 1 + +# Note: Implicitly uses the port manifest. + +# Configure mpconfigboard.h. +CFLAGS += -DMICROPY_ESP8266_1M