Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/esp*: use FLASHFILE for esp32 and esp8266 boards #11648

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,22 @@ 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
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
Expand All @@ -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
Expand All @@ -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
15 changes: 9 additions & 6 deletions cpu/esp8266/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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