2016-08-17 23:08:22 +08:00
|
|
|
#
|
|
|
|
# Partition table
|
|
|
|
#
|
|
|
|
# The partition table is not a real component that gets linked into
|
|
|
|
# the project. Instead, it is a standalone project to generate
|
|
|
|
# the partition table binary as part of the build process. This
|
|
|
|
# binary is then added to the list of files for esptool.py to flash.
|
|
|
|
#
|
2018-04-19 09:42:26 +05:00
|
|
|
.PHONY: partition_table partition_table-flash partition_table-clean partition_table_get_info
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2018-04-26 12:07:27 +10:00
|
|
|
PARTITION_MD5_OPT :=
|
2018-07-13 11:52:57 +10:00
|
|
|
ifndef CONFIG_PARTITION_TABLE_MD5
|
2018-04-26 12:07:27 +10:00
|
|
|
PARTITION_MD5_OPT := "--disable-md5sum"
|
2018-02-16 11:12:16 +01:00
|
|
|
endif
|
|
|
|
|
2018-04-26 12:07:27 +10:00
|
|
|
PARTITION_FLASHSIZE_OPT :=
|
2018-04-20 16:57:15 +10:00
|
|
|
ifneq ("$(CONFIG_ESPTOOLPY_FLASHSIZE)", "")
|
2018-04-26 12:07:27 +10:00
|
|
|
PARTITION_FLASHSIZE_OPT := --flash-size $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
2018-04-20 16:57:15 +10:00
|
|
|
endif
|
|
|
|
|
2018-07-13 11:52:57 +10:00
|
|
|
PARTITION_SECURE_OPT :=
|
|
|
|
ifdef CONFIG_SECURE_BOOT_ENABLED
|
|
|
|
ifndef CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
|
|
|
|
PARTITION_SECURE_OPT += --secure
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-04-19 09:42:26 +05:00
|
|
|
# Address of partition table
|
|
|
|
PARTITION_TABLE_OFFSET := $(CONFIG_PARTITION_TABLE_OFFSET)
|
|
|
|
PARTITION_TABLE_OFFSET_ARG := --offset $(PARTITION_TABLE_OFFSET)
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2018-07-13 11:52:57 +10:00
|
|
|
GEN_ESP32PART := $(PYTHON) $(COMPONENT_PATH)/gen_esp32part.py -q $(PARTITION_MD5_OPT) $(PARTITION_FLASHSIZE_OPT) $(PARTITION_TABLE_OFFSET_ARG) $(PARTITION_SECURE_OPT)
|
2018-04-19 09:42:26 +05:00
|
|
|
GET_PART_INFO := $(COMPONENT_PATH)/parttool.py -q
|
2016-11-07 14:35:23 +11:00
|
|
|
|
2017-06-23 14:08:01 +10:00
|
|
|
# if CONFIG_PARTITION_TABLE_FILENAME is unset, means we haven't re-generated config yet...
|
|
|
|
ifneq ("$(CONFIG_PARTITION_TABLE_FILENAME)","")
|
|
|
|
|
2016-12-21 18:18:42 +00:00
|
|
|
ifndef PARTITION_TABLE_CSV_PATH
|
2016-08-17 23:08:22 +08:00
|
|
|
# Path to partition CSV file is relative to project path for custom
|
2017-10-18 20:43:43 +08:00
|
|
|
# partition CSV files, but relative to component dir otherwise.
|
2016-08-17 23:08:22 +08:00
|
|
|
PARTITION_TABLE_ROOT := $(call dequote,$(if $(CONFIG_PARTITION_TABLE_CUSTOM),$(PROJECT_PATH),$(COMPONENT_PATH)))
|
2017-10-20 12:14:41 +08:00
|
|
|
PARTITION_TABLE_CSV_PATH := $(call dequote,$(abspath $(PARTITION_TABLE_ROOT)/$(call dequote,$(CONFIG_PARTITION_TABLE_FILENAME))))
|
2016-12-21 18:18:42 +00:00
|
|
|
endif
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2017-06-23 14:08:01 +10:00
|
|
|
PARTITION_TABLE_CSV_NAME := $(notdir $(PARTITION_TABLE_CSV_PATH))
|
|
|
|
|
|
|
|
PARTITION_TABLE_BIN := $(BUILD_DIR_BASE)/$(PARTITION_TABLE_CSV_NAME:.csv=.bin)
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2016-12-19 13:06:21 +11:00
|
|
|
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
2016-11-07 15:45:57 +11:00
|
|
|
PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN:.bin=-unsigned.bin)
|
|
|
|
# add an extra signing step for secure partition table
|
2016-11-25 14:13:05 +11:00
|
|
|
$(PARTITION_TABLE_BIN): $(PARTITION_TABLE_BIN_UNSIGNED) $(SDKCONFIG_MAKEFILE) $(SECURE_BOOT_SIGNING_KEY)
|
|
|
|
$(ESPSECUREPY) sign_data --keyfile $(SECURE_BOOT_SIGNING_KEY) -o $@ $<
|
2016-11-07 15:45:57 +11:00
|
|
|
else
|
|
|
|
# secure bootloader disabled, both files are the same
|
|
|
|
PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN)
|
2016-11-03 17:33:30 +11:00
|
|
|
endif
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2018-08-20 17:39:56 +10:00
|
|
|
$(PARTITION_TABLE_BIN_UNSIGNED): $(PARTITION_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFILE) | check_python_dependencies
|
2016-08-17 23:08:22 +08:00
|
|
|
@echo "Building partitions from $(PARTITION_TABLE_CSV_PATH)..."
|
2016-11-11 12:29:38 +11:00
|
|
|
$(GEN_ESP32PART) $< $@
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2018-04-19 09:42:26 +05:00
|
|
|
all_binaries: $(PARTITION_TABLE_BIN) partition_table_get_info
|
|
|
|
|
|
|
|
partition_table_get_info: $(PARTITION_TABLE_BIN)
|
|
|
|
$(eval PHY_DATA_OFFSET:=$(shell $(GET_PART_INFO) --type data --subtype phy --offset $(PARTITION_TABLE_BIN)))
|
2018-06-22 11:14:22 +10:00
|
|
|
$(eval APP_OFFSET:=$(shell $(GET_PART_INFO) --default-boot-partition --offset $(PARTITION_TABLE_BIN)))
|
2018-09-18 15:10:03 +03:00
|
|
|
$(eval OTA_DATA_SIZE := $(shell $(GET_PART_INFO) --type data --subtype ota --size $(PARTITION_TABLE_BIN) || echo 0))
|
|
|
|
$(eval OTA_DATA_OFFSET := $(shell $(GET_PART_INFO) --type data --subtype ota --offset $(PARTITION_TABLE_BIN)))
|
2018-04-19 09:42:26 +05:00
|
|
|
|
|
|
|
export APP_OFFSET
|
|
|
|
export PHY_DATA_OFFSET
|
2018-06-25 11:53:10 +05:00
|
|
|
export OTA_DATA_OFFSET
|
|
|
|
export OTA_DATA_SIZE
|
2016-08-18 17:11:27 +08:00
|
|
|
|
2016-11-07 14:35:23 +11:00
|
|
|
PARTITION_TABLE_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
|
|
|
|
ESPTOOL_ALL_FLASH_ARGS += $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
|
2016-08-17 23:08:22 +08:00
|
|
|
|
2018-09-03 11:42:10 +02:00
|
|
|
partition_table: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
|
2016-08-17 23:08:22 +08:00
|
|
|
@echo "Partition table binary generated. Contents:"
|
|
|
|
@echo $(SEPARATOR)
|
2016-11-11 12:29:38 +11:00
|
|
|
$(GEN_ESP32PART) $<
|
2016-08-17 23:08:22 +08:00
|
|
|
@echo $(SEPARATOR)
|
|
|
|
@echo "Partition flashing command:"
|
|
|
|
@echo "$(PARTITION_TABLE_FLASH_CMD)"
|
|
|
|
|
2018-09-03 11:42:10 +02:00
|
|
|
partition_table-flash: $(PARTITION_TABLE_BIN) | check_python_dependencies
|
2016-08-17 23:08:22 +08:00
|
|
|
@echo "Flashing partition table..."
|
2016-11-11 12:29:38 +11:00
|
|
|
$(PARTITION_TABLE_FLASH_CMD)
|
2016-08-17 23:08:22 +08:00
|
|
|
|
|
|
|
partition_table-clean:
|
2016-11-11 12:29:38 +11:00
|
|
|
rm -f $(PARTITION_TABLE_BIN)
|
2016-08-18 17:11:27 +08:00
|
|
|
|
|
|
|
clean: partition_table-clean
|
2017-06-23 14:08:01 +10:00
|
|
|
|
|
|
|
endif
|