allow esptool.py invocation to be set via make vars

This commit replaces the literal calls to `esptool.py` with the
`$(ESPTOOL)` Makefile variable. This allows one to set the esptool
invocation on the Make command line:

    make ESPTOOL="python2 $(which esptool.py)"

(or via the environment, an include file, etc)

Closes #793
This commit is contained in:
Lars Kellogg-Stedman 2018-05-02 09:34:21 -04:00
parent dd0f8689a1
commit 3e35cbcd5b

View File

@ -32,6 +32,7 @@ FLASH_MODE ?= qio
FLASH_SIZE ?= detect FLASH_SIZE ?= detect
CROSS_COMPILE = xtensa-lx106-elf- CROSS_COMPILE = xtensa-lx106-elf-
ESP_SDK = $(shell $(CC) -print-sysroot)/usr ESP_SDK = $(shell $(CC) -print-sysroot)/usr
ESPTOOL = esptool.py
INC += -I. INC += -I.
INC += -I$(TOP) INC += -I$(TOP)
@ -230,18 +231,18 @@ FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
deploy: $(BUILD)/firmware-combined.bin deploy: $(BUILD)/firmware-combined.bin
$(ECHO) "Writing $< to the board" $(ECHO) "Writing $< to the board"
$(Q)esptool.py --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $< $(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $<
erase: erase:
$(ECHO) "Erase flash" $(ECHO) "Erase flash"
$(Q)esptool.py --port $(PORT) --baud $(BAUD) erase_flash $(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) erase_flash
reset: reset:
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT) echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
$(FWBIN): $(BUILD)/firmware.elf $(FWBIN): $(BUILD)/firmware.elf
$(ECHO) "Create $@" $(ECHO) "Create $@"
$(Q)python2 $(shell which esptool.py) elf2image $^ $(Q)$(ESPTOOL) elf2image $^
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@ $(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@