2016-08-17 15:08:22 +00:00
|
|
|
# Component support for esptool.py. Doesn't do much by itself,
|
|
|
|
# components have their own flash targets that can use these variables.
|
|
|
|
ESPPORT ?= $(CONFIG_ESPTOOLPY_PORT)
|
|
|
|
ESPBAUD ?= $(CONFIG_ESPTOOLPY_BAUD)
|
2016-09-01 07:47:09 +00:00
|
|
|
ESPFLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE)
|
2016-09-02 04:29:01 +00:00
|
|
|
ESPFLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ)
|
2016-10-18 11:03:59 +00:00
|
|
|
ESPFLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
2016-08-17 15:08:22 +00:00
|
|
|
|
|
|
|
PYTHON ?= $(call dequote,$(CONFIG_PYTHON))
|
|
|
|
|
|
|
|
# two commands that can be used from other components
|
|
|
|
# to invoke esptool.py (with or without serial port args)
|
|
|
|
#
|
2016-09-12 07:48:40 +00:00
|
|
|
ESPTOOLPY_SRC := $(COMPONENT_PATH)/esptool/esptool.py
|
|
|
|
ESPTOOLPY := $(PYTHON) $(ESPTOOLPY_SRC) --chip esp32
|
2016-12-20 07:02:47 +00:00
|
|
|
ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER)
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-10-31 23:50:16 +00:00
|
|
|
# Supporting esptool command line tools
|
|
|
|
ESPEFUSEPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espefuse.py
|
|
|
|
ESPSECUREPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espsecure.py
|
2016-11-03 06:33:30 +00:00
|
|
|
export ESPSECUREPY # is used in bootloader_support component
|
2016-10-31 23:50:16 +00:00
|
|
|
|
2016-10-18 11:03:59 +00:00
|
|
|
ESPTOOL_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size $(ESPFLASHSIZE)
|
2016-12-20 07:02:47 +00:00
|
|
|
ifdef CONFIG_ESPTOOLPY_FLASHSIZE_DETECT
|
|
|
|
ESPTOOL_WRITE_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size detect
|
|
|
|
else
|
|
|
|
ESPTOOL_WRITE_FLASH_OPTIONS := $(ESPTOOL_FLASH_OPTIONS)
|
|
|
|
endif
|
2016-10-18 11:03:59 +00:00
|
|
|
|
2016-10-31 23:50:16 +00:00
|
|
|
ESPTOOL_ELF2IMAGE_OPTIONS :=
|
|
|
|
|
2017-01-10 03:04:54 +00:00
|
|
|
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS)
|
2016-08-22 10:43:47 +00:00
|
|
|
|
2016-08-18 09:11:27 +00:00
|
|
|
ESPTOOL_ALL_FLASH_ARGS += $(CONFIG_APP_OFFSET) $(APP_BIN)
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-12-19 02:06:21 +00:00
|
|
|
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
2016-11-03 06:33:30 +00:00
|
|
|
ifndef IS_BOOTLOADER_BUILD
|
2016-12-19 02:06:21 +00:00
|
|
|
# for locally signed secure boot image, add a signing step to get from unsigned app to signed app
|
2016-11-07 04:45:57 +00:00
|
|
|
APP_BIN_UNSIGNED := $(APP_BIN:.bin=-unsigned.bin)
|
|
|
|
|
2016-12-19 02:06:21 +00:00
|
|
|
$(APP_BIN): $(APP_BIN_UNSIGNED) $(SECURE_BOOT_SIGNING_KEY) $(SDKCONFIG_MAKEFILE)
|
2016-11-25 03:13:05 +00:00
|
|
|
$(ESPSECUREPY) sign_data --keyfile $(SECURE_BOOT_SIGNING_KEY) -o $@ $<
|
2016-11-03 06:33:30 +00:00
|
|
|
endif
|
|
|
|
endif
|
2016-11-07 04:45:57 +00:00
|
|
|
# non-secure boot (or bootloader), both these files are the same
|
|
|
|
APP_BIN_UNSIGNED ?= $(APP_BIN)
|
|
|
|
|
|
|
|
$(APP_BIN_UNSIGNED): $(APP_ELF) $(ESPTOOLPY_SRC)
|
2016-11-14 03:48:10 +00:00
|
|
|
$(ESPTOOLPY) elf2image $(ESPTOOL_FLASH_OPTIONS) $(ESPTOOL_ELF2IMAGE_OPTIONS) -o $@ $<
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-12-22 05:32:19 +00:00
|
|
|
flash: all_binaries $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
2016-10-03 23:12:17 +00:00
|
|
|
@echo "Flashing binaries to serial port $(ESPPORT) (app at offset $(CONFIG_APP_OFFSET))..."
|
2016-11-25 03:09:26 +00:00
|
|
|
ifdef CONFIG_SECURE_BOOT_ENABLED
|
2016-10-31 23:50:16 +00:00
|
|
|
@echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)"
|
|
|
|
endif
|
2016-11-11 01:29:38 +00:00
|
|
|
$(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-12-22 05:32:19 +00:00
|
|
|
app-flash: $(APP_BIN) $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
2016-10-03 23:12:17 +00:00
|
|
|
@echo "Flashing app to serial port $(ESPPORT), offset $(CONFIG_APP_OFFSET)..."
|
2016-11-11 01:29:38 +00:00
|
|
|
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
|
2016-09-12 07:48:40 +00:00
|
|
|
|
2016-11-16 00:12:48 +00:00
|
|
|
# Submodules normally added in component.mk, but can be added
|
|
|
|
# at the project level as long as qualified path
|
|
|
|
COMPONENT_SUBMODULES += $(COMPONENT_PATH)/esptool
|
2016-12-19 23:00:04 +00:00
|
|
|
|
|
|
|
erase_flash:
|
|
|
|
@echo "Erasing entire flash..."
|
|
|
|
$(ESPTOOLPY_SERIAL) erase_flash
|
2016-12-22 05:32:19 +00:00
|
|
|
|
2016-12-30 01:19:02 +00:00
|
|
|
MONITORBAUD ?= $(CONFIG_MONITOR_BAUD)
|
|
|
|
|
|
|
|
# note: if you want to run miniterm from command line, can simply run
|
|
|
|
# miniterm.py on the console. The '$(PYTHON) -m serial.tools.miniterm'
|
|
|
|
# is to allow for the $(PYTHON) variable overriding the python path.
|
|
|
|
monitor: $(call prereq_if_explicit,%flash)
|
|
|
|
$(PYTHON) -m serial.tools.miniterm --rts 0 --dtr 0 --raw $(ESPPORT) $(MONITORBAUD)
|
|
|
|
|
2016-12-22 05:32:19 +00:00
|
|
|
.PHONY: erase_flash
|