diff --git a/cpu/esp32/Makefile.include b/cpu/esp32/Makefile.include index 68471ab5d971..b554ba56e746 100644 --- a/cpu/esp32/Makefile.include +++ b/cpu/esp32/Makefile.include @@ -140,6 +140,9 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.nanofmt.ld LINKFLAGS += -nostdlib -lgcc -u putchar -Wl,-gc-sections LINKFLAGS += -Wl,--warn-unresolved-symbols +# The ELFFILE is the base one used for flashing +FLASHFILE ?= $(ELFFILE) + # configure preflasher to convert .elf to .bin before flashing FLASH_MODE ?= dout # FIX configuration, DO NOT CHANGE FLASH_FREQ = 40m # FIX configuration, DO NOT CHANGE @@ -147,12 +150,12 @@ FLASH_SIZE ?= 2MB PREFLASHER = $(ESPTOOL) PREFFLAGS = --chip esp32 elf2image PREFFLAGS += -fm $(FLASH_MODE) -fs $(FLASH_SIZE) -ff $(FLASH_FREQ) -PREFFLAGS += -o $(ELFFILE).bin $(ELFFILE); +PREFFLAGS += -o $(FLASHFILE).bin $(FLASHFILE); PREFFLAGS += echo "" > $(BINDIR)/partitions.csv; PREFFLAGS += echo "nvs, data, nvs, 0x9000, 0x6000" >> $(BINDIR)/partitions.csv; PREFFLAGS += echo "phy_init, data, phy, 0xf000, 0x1000" >> $(BINDIR)/partitions.csv; PREFFLAGS += echo -n "factory, app, factory, 0x10000, " >> $(BINDIR)/partitions.csv; -PREFFLAGS += ls -l $(ELFFILE).bin | awk '{ print $$5 }' >> $(BINDIR)/partitions.csv; +PREFFLAGS += ls -l $(FLASHFILE).bin | awk '{ print $$5 }' >> $(BINDIR)/partitions.csv; PREFFLAGS += python $(RIOTCPU)/$(CPU)/gen_esp32part.py --disable-sha256sum PREFFLAGS += --verify $(BINDIR)/partitions.csv $(BINDIR)/partitions.bin @@ -167,7 +170,7 @@ ifeq ($(QEMU), 1) FFLAGS += head -c $$((0x8000)) | FFLAGS += cat - $(BINDIR)/partitions.bin tmp.bin | FFLAGS += head -c $$((0x10000)) | - FFLAGS += cat - $(ELFFILE).bin tmp.bin | + FFLAGS += cat - $(FLASHFILE).bin tmp.bin | FFLAGS += head -c $$((0x400000)) > $(BINDIR)/esp32flash.bin && rm tmp.bin && FFLAGS += cp $(RIOTCPU)/$(CPU)/bin/rom_0x3ff90000_0x00010000.bin $(BINDIR)/rom1.bin && FFLAGS += cp $(RIOTCPU)/$(CPU)/bin/rom_0x40000000_0x000c2000.bin $(BINDIR)/rom.bin @@ -179,5 +182,5 @@ else FFLAGS += -z -fm $(FLASH_MODE) -fs detect -ff $(FLASH_FREQ) FFLAGS += 0x1000 $(RIOTCPU)/$(CPU)/bin/bootloader.bin FFLAGS += 0x8000 $(BINDIR)/partitions.bin - FFLAGS += 0x10000 $(ELFFILE).bin + FFLAGS += 0x10000 $(FLASHFILE).bin endif diff --git a/cpu/esp8266/Makefile.include b/cpu/esp8266/Makefile.include index 1a57d3f71c25..f60655f46245 100644 --- a/cpu/esp8266/Makefile.include +++ b/cpu/esp8266/Makefile.include @@ -128,24 +128,27 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/eagle.rom.addr.v6.ld LINKFLAGS += -nostdlib -lgcc -u ets_run -Wl,-gc-sections # -Wl,--print-gc-sections LINKFLAGS += -Wl,--warn-unresolved-symbols +# The ELFFILE is the base one used for flashing +FLASHFILE ?= $(ELFFILE) + # configure preflasher to convert .elf to .bin before flashing FLASH_SIZE = -fs 8m PREFLASHER ?= esptool.py -PREFFLAGS ?= elf2image $(FLASH_SIZE) $(ELFFILE) +PREFFLAGS ?= elf2image $(FLASH_SIZE) $(FLASHFILE) FLASHDEPS ?= preflash # flasher configuration ifeq ($(QEMU), 1) FLASHER = cat - FFLAGS += $(ELFFILE)-0x00000.bin /dev/zero | head -c $$((0x10000)) | cat - - FFLAGS += $(ELFFILE)-0x10000.bin /dev/zero | head -c $$((0xfc000)) | cat - - FFLAGS += $(RIOTCPU)/$(CPU)/bin/esp_init_data_default.bin > $(ELFFILE).bin + FFLAGS += $(FLASHFILE)-0x00000.bin /dev/zero | head -c $$((0x10000)) | cat - + FFLAGS += $(FLASHFILE)-0x10000.bin /dev/zero | head -c $$((0xfc000)) | cat - + FFLAGS += $(RIOTCPU)/$(CPU)/bin/esp_init_data_default.bin > $(FLASHFILE).bin else FLASH_MODE ?= dout export PROGRAMMER_SPEED ?= 460800 FLASHER = esptool.py FFLAGS += -p $(PORT) -b $(PROGRAMMER_SPEED) write_flash FFLAGS += -fm $(FLASH_MODE) - FFLAGS += 0 $(ELFFILE)-0x00000.bin - FFLAGS += 0x10000 $(ELFFILE)-0x10000.bin; esptool.py -p $(PORT) run + FFLAGS += 0 $(FLASHFILE)-0x00000.bin + FFLAGS += 0x10000 $(FLASHFILE)-0x10000.bin; esptool.py -p $(PORT) run endif