From 3d7d211157c8fc624be8fd7436143173c596f200 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 27 Sep 2021 22:53:18 +0200 Subject: [PATCH] cpu/esp: Always create app.elf.bin and partitions.bin Even if programmer is not esptool --- cpu/esp_common/Makefile.include | 42 +++++++++++++++++++++++++++++++++ makefiles/tools/esptool.inc.mk | 33 -------------------------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/cpu/esp_common/Makefile.include b/cpu/esp_common/Makefile.include index 6d34b99845..977738eacc 100644 --- a/cpu/esp_common/Makefile.include +++ b/cpu/esp_common/Makefile.include @@ -105,3 +105,45 @@ PROGRAMMER ?= esptool # Add esptool in the list supported programmers PROGRAMMERS_SUPPORTED += esptool + +# The ELFFILE is defined by default in $(RIOTBASE)/Makefile.include but only +# after this file is included, so we need ELFFILE defined earlier. +# This is used to create new make rules in this file (based on FLASHFILE) +# and can't be deferred. +ELFFILE ?= $(BINDIR)/$(APPLICATION).elf +FLASHFILE ?= $(ELFFILE).bin + +ESPTOOL ?= $(RIOTTOOLS)/esptool/esptool.py + +# This is the binary that ends up programmed in the flash. +$(ELFFILE).bin: $(ELFFILE) + $(Q)$(ESPTOOL) --chip $(FLASH_CHIP) elf2image --flash_mode $(FLASH_MODE) \ + --flash_size $(FLASH_SIZE)MB --flash_freq $(FLASH_FREQ) $(FLASH_OPTS) \ + -o $@ $< + + +# Convert .elf and .csv to .bin files at build time, but make them available for +# tests at flash time. These can't be added to FLASHDEPS because they depend on +# on ELFFILE and would trigger a rebuild with "flash-only". +BUILD_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin +TEST_EXTRA_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin + +# Default partition table with no OTA. Can be replaced with a custom partition +# table setting PARTITION_TABLE_CSV. +PARTITION_TABLE_CSV ?= $(BINDIR)/partitions.csv + +$(BINDIR)/partitions.csv: $(FLASHFILE) + $(Q)printf "\n" > $(BINDIR)/partitions.csv + $(Q)printf "nvs, data, nvs, 0x9000, 0x6000\n" >> $@ + $(Q)printf "phy_init, data, phy, 0xf000, 0x1000\n" >> $@ + $(Q)printf "factory, app, factory, 0x10000, " >> $@ + $(Q)ls -l $< | awk '{ print $$5 }' >> $@ + +$(BINDIR)/partitions.bin: $(PARTITION_TABLE_CSV) + $(Q)python3 $(RIOTTOOLS)/esptool/gen_esp32part.py --verify $< $@ + +# Convert .elf and .csv to .bin files at build time, but make them available for +# tests at flash time. These can't be added to FLASHDEPS because they depend on +# on ELFFILE and would trigger a rebuild with "flash-only". +BUILD_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin +TEST_EXTRA_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin diff --git a/makefiles/tools/esptool.inc.mk b/makefiles/tools/esptool.inc.mk index 566797fc4b..4188590a03 100644 --- a/makefiles/tools/esptool.inc.mk +++ b/makefiles/tools/esptool.inc.mk @@ -9,19 +9,6 @@ BOOTLOADER_BIN = bootloader$(BOOTLOADER_COLOR)$(BOOTLOADER_INFO).bin ESPTOOL ?= $(RIOTTOOLS)/esptool/esptool.py -# The ELFFILE is defined by default in $(RIOTBASE)/Makefile.include but only -# after the $(PROGRAMMER).inc.mk file is included, so we need ELFFILE defined -# earlier. This is used to create new make rules in this file (based on -# FLASHFILE) and can't be deferred. -ELFFILE ?= $(BINDIR)/$(APPLICATION).elf -FLASHFILE ?= $(ELFFILE).bin - -# Convert .elf and .csv to .bin files at build time, but make them available for -# tests at flash time. These can't be added to FLASHDEPS because they depend on -# on ELFFILE and would trigger a rebuild with "flash-only". -BUILD_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin -TEST_EXTRA_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin - # flasher configuration ifneq (,$(filter esp_qemu,$(USEMODULE))) FLASHER = @@ -38,26 +25,6 @@ else FFLAGS += 0x10000 $(FLASHFILE) endif -# This is the binary that ends up programmed in the flash. -$(ELFFILE).bin: $(ELFFILE) - $(Q)$(ESPTOOL) --chip $(FLASH_CHIP) elf2image --flash_mode $(FLASH_MODE) \ - --flash_size $(FLASH_SIZE)MB --flash_freq $(FLASH_FREQ) $(FLASH_OPTS) \ - -o $@ $< - -# Default partition table with no OTA. Can be replaced with a custom partition -# table setting PARTITION_TABLE_CSV. -PARTITION_TABLE_CSV ?= $(BINDIR)/partitions.csv - -$(BINDIR)/partitions.csv: $(FLASHFILE) - $(Q)printf "\n" > $(BINDIR)/partitions.csv - $(Q)printf "nvs, data, nvs, 0x9000, 0x6000\n" >> $@ - $(Q)printf "phy_init, data, phy, 0xf000, 0x1000\n" >> $@ - $(Q)printf "factory, app, factory, 0x10000, " >> $@ - $(Q)ls -l $< | awk '{ print $$5 }' >> $@ - -$(BINDIR)/partitions.bin: $(PARTITION_TABLE_CSV) - $(Q)python3 $(RIOTTOOLS)/esptool/gen_esp32part.py --verify $< $@ - .PHONY: esp-qemu esp-qemu: