e97f72ea24
# Conflicts: # .gitlab-ci.yml # components/bootloader/project_include.cmake # components/bootloader_support/include/bootloader_common.h # components/bootloader_support/src/bootloader_common.c # components/bt/Kconfig # components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h # components/bt/bluedroid/stack/btm/btm_ble_gap.c # components/bt/bluedroid/stack/btm/btm_devctl.c # components/bt/bluedroid/stack/include/stack/hcidefs.h # components/bt/bluedroid/stack/smp/smp_act.c # components/bt/bt.c # components/bt/lib # components/driver/Kconfig # components/driver/include/driver/rmt.h # components/driver/test/test_spi_master.c # components/driver/uart.c # components/esp32/CMakeLists.txt # components/esp32/Kconfig # components/esp32/ld/esp32.project.ld.in # components/esp32/ld/esp32.spiram.rom-functions-dram.ld # components/esp32/ld/esp32.spiram.rom-functions-iram.ld # components/esp32/lib # components/esp32/spiram.c # components/esp32/spiram_psram.c # components/esp32/test/test_wifi.c # components/esp32/wifi_init.c # components/esp_http_server/include/esp_http_server.h # components/esp_http_server/src/esp_httpd_priv.h # components/esp_http_server/src/httpd_parse.c # components/esp_http_server/src/httpd_sess.c # components/esp_http_server/src/httpd_txrx.c # components/esp_http_server/src/httpd_uri.c # components/esp_http_server/test/test_http_server.c # components/esp_https_ota/src/esp_https_ota.c # components/ethernet/emac_main.c # components/freemodbus/Kconfig # components/idf_test/include/idf_performance.h # components/idf_test/integration_test/TC_IT_BLUEDROID_SMP.yml # components/lwip/Kconfig # components/newlib/test/test_time.c # components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py # components/spi_flash/Kconfig # components/ulp/cmake/CMakeLists.txt # components/ulp/component_ulp_common.cmake # components/vfs/vfs.c # docs/conf_common.py # docs/en/api-reference/provisioning/wifi_provisioning.rst # examples/mesh/internal_communication/main/Kconfig.projbuild # examples/protocols/aws_iot/subscribe_publish/main/CMakeLists.txt # examples/protocols/aws_iot/thing_shadow/main/CMakeLists.txt # examples/protocols/coap_client/README.md # examples/protocols/coap_server/README.md # examples/protocols/modbus_slave/main/Kconfig.projbuild # examples/protocols/mqtt/ssl/mqtt_ssl_example_test.py # examples/protocols/mqtt/tcp/main/Kconfig.projbuild # examples/protocols/mqtt/ws/mqtt_ws_example_test.py # examples/protocols/mqtt/wss/mqtt_wss_example_test.py # examples/wifi/iperf/components/iperf/iperf.c # requirements.txt # tools/ci/build_examples.sh # tools/ci/test_build_system_cmake.sh # tools/cmake/idf_functions.cmake # tools/cmake/kconfig.cmake # tools/cmake/scripts/expand_requirements.cmake # tools/esp_prov/README.md # tools/esp_prov/esp_prov.py # tools/esp_prov/transport/ble_cli.py # tools/idf.py # tools/kconfig_new/confgen.py # tools/mass_mfg/docs/README.rst # tools/mass_mfg/samples/sample_config.csv # tools/tiny-test-fw/DUT.py # tools/tiny-test-fw/IDF/IDFApp.py # tools/tiny-test-fw/IDF/IDFDUT.py # tools/tiny-test-fw/TinyFW.py # tools/unit-test-app/tools/UnitTestParser.py # tools/unit-test-app/unit_test.py
115 lines
4.7 KiB
Makefile
115 lines
4.7 KiB
Makefile
# Component support for esptool.py. Doesn't do much by itself,
|
|
# components have their own flash targets that can use these variables.
|
|
|
|
PYTHON ?= $(call dequote,$(CONFIG_PYTHON))
|
|
|
|
ifdef CONFIG_ESPTOOLPY_PORT
|
|
ESPPORT ?= $(shell $(PYTHON) $(IDF_PATH)/tools/findcp2102.py $(CONFIG_ESPTOOLPY_PORT))
|
|
endif
|
|
ESPBAUD ?= $(CONFIG_ESPTOOLPY_BAUD)
|
|
ESPFLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE)
|
|
ESPFLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ)
|
|
ESPFLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
|
|
|
CONFIG_ESPTOOLPY_COMPRESSED ?=
|
|
|
|
# two commands that can be used from other components
|
|
# to invoke esptool.py (with or without serial port args)
|
|
#
|
|
ESPTOOLPY_SRC := $(COMPONENT_PATH)/esptool/esptool.py
|
|
ESPTOOLPY := $(PYTHON) $(ESPTOOLPY_SRC) --chip esp32
|
|
ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER)
|
|
|
|
# Supporting esptool command line tools
|
|
ESPEFUSEPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espefuse.py
|
|
ESPSECUREPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espsecure.py
|
|
export ESPSECUREPY # is used in bootloader_support component
|
|
|
|
ESPTOOL_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size $(ESPFLASHSIZE)
|
|
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
|
|
|
|
ESPTOOL_ELF2IMAGE_OPTIONS :=
|
|
|
|
ifdef CONFIG_SECURE_BOOT_ENABLED
|
|
ifndef CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
|
|
ifndef IS_BOOTLOADER_BUILD
|
|
ESPTOOL_ELF2IMAGE_OPTIONS += --secure-pad
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
ifndef IS_BOOTLOADER_BUILD
|
|
ESPTOOL_ELF2IMAGE_OPTIONS += --elf-sha256-offset 0xb0
|
|
endif
|
|
|
|
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS)
|
|
|
|
ESPTOOL_ALL_FLASH_ARGS += $(APP_OFFSET) $(APP_BIN)
|
|
|
|
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
|
ifndef IS_BOOTLOADER_BUILD
|
|
# for locally signed secure boot image, add a signing step to get from unsigned app to signed app
|
|
APP_BIN_UNSIGNED := $(APP_BIN:.bin=-unsigned.bin)
|
|
|
|
$(APP_BIN): $(APP_BIN_UNSIGNED) $(SECURE_BOOT_SIGNING_KEY) $(SDKCONFIG_MAKEFILE)
|
|
$(ESPSECUREPY) sign_data --keyfile $(SECURE_BOOT_SIGNING_KEY) -o $@ $<
|
|
endif
|
|
endif
|
|
# non-secure boot (or bootloader), both these files are the same
|
|
APP_BIN_UNSIGNED ?= $(APP_BIN)
|
|
|
|
$(APP_BIN_UNSIGNED): $(APP_ELF) $(ESPTOOLPY_SRC) | check_python_dependencies
|
|
$(ESPTOOLPY) elf2image $(ESPTOOL_FLASH_OPTIONS) $(ESPTOOL_ELF2IMAGE_OPTIONS) -o $@ $<
|
|
|
|
flash: all_binaries $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash) partition_table_get_info | check_python_dependencies
|
|
@echo "Flashing binaries to serial port $(ESPPORT) (app at offset $(APP_OFFSET))..."
|
|
ifdef CONFIG_SECURE_BOOT_ENABLED
|
|
@echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)"
|
|
endif
|
|
$(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
|
|
|
|
app-flash: $(APP_BIN) $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash) partition_table_get_info | check_python_dependencies
|
|
@echo "Flashing app to serial port $(ESPPORT), offset $(APP_OFFSET)..."
|
|
$(ESPTOOLPY_WRITE_FLASH) $(APP_OFFSET) $(APP_BIN)
|
|
|
|
# Submodules normally added in component.mk, but can be added
|
|
# at the project level as long as qualified path
|
|
COMPONENT_SUBMODULES += $(COMPONENT_PATH)/esptool
|
|
|
|
erase_flash: | check_python_dependencies
|
|
@echo "Erasing entire flash..."
|
|
$(ESPTOOLPY_SERIAL) erase_flash
|
|
|
|
MONITORBAUD ?= $(CONFIG_MONITOR_BAUD)
|
|
|
|
MONITOR_PYTHON := $(PYTHON)
|
|
|
|
ifeq ("$(OS)","Windows_NT")
|
|
# miniterm and idf_monitor both need a Windows Console PTY in order
|
|
# to correctly handle user input
|
|
MONITOR_PYTHON := winpty $(PYTHON)
|
|
endif
|
|
|
|
# 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.
|
|
simple_monitor: $(call prereq_if_explicit,%flash) | check_python_dependencies
|
|
$(MONITOR_PYTHON) -m serial.tools.miniterm --rts 0 --dtr 0 --raw $(ESPPORT) $(MONITORBAUD)
|
|
|
|
PRINT_FILTER ?=
|
|
|
|
MONITOR_OPTS := --baud $(MONITORBAUD) --port $(ESPPORT) --toolchain-prefix $(CONFIG_TOOLPREFIX) --make "$(MAKE)" --print_filter "$(PRINT_FILTER)"
|
|
|
|
monitor: $(call prereq_if_explicit,%flash) | check_python_dependencies
|
|
$(summary) MONITOR
|
|
[ -f $(APP_ELF) ] || echo "*** 'make monitor' target requires an app to be compiled and flashed first."
|
|
[ -f $(APP_ELF) ] || echo "*** Run 'make flash monitor' to build, flash and monitor"
|
|
[ -f $(APP_ELF) ] || echo "*** Or alternatively 'make simple_monitor' to view the serial port as-is."
|
|
[ -f $(APP_ELF) ] || exit 1
|
|
$(MONITOR_PYTHON) $(IDF_PATH)/tools/idf_monitor.py $(MONITOR_OPTS) $(APP_ELF)
|
|
|
|
.PHONY: erase_flash
|