2021-05-06 03:00:04 +02:00
|
|
|
# ESP-IDF uses dio as flash mode for esptool.py when qout or qio mode are
|
|
|
|
# configured to always boot in dual SPI mode
|
|
|
|
ifneq (,$(filter qout qio,$(FLASH_MODE)))
|
|
|
|
FLASH_MODE = dio
|
2022-02-01 22:15:47 +01:00
|
|
|
endif
|
2020-12-01 10:22:26 +01:00
|
|
|
|
2022-03-04 08:34:19 +01:00
|
|
|
ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool.py
|
2020-12-01 10:22:26 +01:00
|
|
|
|
|
|
|
# flasher configuration
|
|
|
|
ifneq (,$(filter esp_qemu,$(USEMODULE)))
|
2021-02-23 10:53:49 +01:00
|
|
|
FLASHER =
|
|
|
|
FFLAGS =
|
|
|
|
FLASHDEPS += esp-qemu
|
2020-12-01 10:22:26 +01:00
|
|
|
else
|
|
|
|
PROGRAMMER_SPEED ?= 460800
|
|
|
|
FLASHER = $(ESPTOOL)
|
|
|
|
FFLAGS += --chip $(FLASH_CHIP) --port $(PROG_DEV) --baud $(PROGRAMMER_SPEED)
|
|
|
|
FFLAGS += --before default_reset write_flash -z
|
|
|
|
FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ)
|
2022-03-09 13:31:42 +01:00
|
|
|
FFLAGS += --flash_size detect
|
2022-02-01 22:15:47 +01:00
|
|
|
FFLAGS += $(BOOTLOADER_POS) $(BOOTLOADER_BIN)
|
2020-12-01 10:22:26 +01:00
|
|
|
FFLAGS += 0x8000 $(BINDIR)/partitions.bin
|
2022-12-27 01:55:28 +01:00
|
|
|
FFLAGS += $(FLASHFILE_POS) $(FLASHFILE)
|
2020-12-01 10:22:26 +01:00
|
|
|
endif
|
|
|
|
|
2021-04-11 02:37:56 +02:00
|
|
|
.PHONY: esp-qemu
|
2021-02-23 10:53:49 +01:00
|
|
|
|
2022-12-31 13:09:37 +01:00
|
|
|
esp-qemu: $(FLASHFILE)
|
2022-06-23 07:28:49 +02:00
|
|
|
ifeq (esp32,$(CPU))
|
2022-03-02 15:13:05 +01:00
|
|
|
$(Q)echo \
|
|
|
|
"--flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) " \
|
|
|
|
"--flash_size $(FLASH_SIZE)MB" \
|
2022-03-09 13:31:42 +01:00
|
|
|
"$(BOOTLOADER_POS) $(BOOTLOADER_BIN)" \
|
2022-03-02 15:13:05 +01:00
|
|
|
"0x8000 $(BINDIR)/partitions.bin" \
|
2022-12-27 01:55:28 +01:00
|
|
|
"$(FLASHFILE_POS) $(FLASHFILE)" > $(BINDIR)/qemu_flash_args
|
2022-03-02 15:13:05 +01:00
|
|
|
$(Q)$(ESPTOOL) \
|
2022-06-23 07:28:49 +02:00
|
|
|
--chip $(CPU_FAM) merge_bin \
|
2022-03-02 15:13:05 +01:00
|
|
|
--fill-flash-size 4MB \
|
|
|
|
-o $(BINDIR)/qemu_flash_image.bin @$(BINDIR)/qemu_flash_args
|
|
|
|
$(Q)cp $(RIOTCPU)/$(CPU)/bin/rom_0x3ff90000_0x00010000.bin $(BINDIR)/rom1.bin
|
|
|
|
$(Q)cp $(RIOTCPU)/$(CPU)/bin/rom_0x40000000_0x000c2000.bin $(BINDIR)/rom.bin
|
|
|
|
else
|
2021-02-23 10:53:49 +01:00
|
|
|
$(Q)dd if=/dev/zero bs=1M count=$(FLASH_SIZE) | \
|
|
|
|
tr "\\000" "\\377" > tmp.bin && cat tmp.bin | \
|
|
|
|
head -c $$(($(BOOTLOADER_POS))) | \
|
2022-02-01 22:15:47 +01:00
|
|
|
cat - $(BOOTLOADER_BIN) tmp.bin | \
|
2021-02-23 10:53:49 +01:00
|
|
|
head -c $$((0x8000)) | \
|
|
|
|
cat - $(BINDIR)/partitions.bin tmp.bin | \
|
2022-12-27 01:55:28 +01:00
|
|
|
head -c $$(($(FLASHFILE_POS))) | \
|
2021-04-11 02:37:56 +02:00
|
|
|
cat - $(FLASHFILE) tmp.bin | \
|
2021-02-23 10:53:49 +01:00
|
|
|
head -c $(FLASH_SIZE)MB > $(BINDIR)/$(CPU)flash.bin && rm tmp.bin
|
|
|
|
endif
|
|
|
|
|
2020-12-01 10:22:26 +01:00
|
|
|
# reset tool configuration
|
2022-03-04 08:34:19 +01:00
|
|
|
RESET ?= $(RIOTTOOLS)/esptools/espreset.py
|
2020-12-01 10:22:26 +01:00
|
|
|
RESET_FLAGS ?= --port $(PROG_DEV)
|