mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
123 lines
5.3 KiB
Makefile
123 lines
5.3 KiB
Makefile
#
|
|
# 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.
|
|
#
|
|
.PHONY: partition_table partition_table-flash partition_table-clean partition_table_get_info
|
|
|
|
PARTITION_MD5_OPT :=
|
|
ifndef CONFIG_PARTITION_TABLE_MD5
|
|
PARTITION_MD5_OPT := "--disable-md5sum"
|
|
endif
|
|
|
|
PARTITION_FLASHSIZE_OPT :=
|
|
ifneq ("$(CONFIG_ESPTOOLPY_FLASHSIZE)", "")
|
|
PARTITION_FLASHSIZE_OPT := --flash-size $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
|
endif
|
|
|
|
PARTITION_SECURE_OPT :=
|
|
ifdef CONFIG_SECURE_BOOT
|
|
ifndef CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
|
|
ifdef CONFIG_SECURE_BOOT_V2_ENABLED
|
|
PARTITION_SECURE_OPT += --secure v2
|
|
else
|
|
PARTITION_SECURE_OPT += --secure v1
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
# Address of partition table
|
|
PARTITION_TABLE_OFFSET := $(CONFIG_PARTITION_TABLE_OFFSET)
|
|
PARTITION_TABLE_OFFSET_ARG := --offset $(PARTITION_TABLE_OFFSET)
|
|
|
|
GEN_ESP32PART := $(PYTHON) $(COMPONENT_PATH)/gen_esp32part.py -q $(PARTITION_MD5_OPT) $(PARTITION_FLASHSIZE_OPT) $(PARTITION_TABLE_OFFSET_ARG) $(PARTITION_SECURE_OPT)
|
|
GET_PART_INFO := $(COMPONENT_PATH)/parttool.py -q
|
|
|
|
# if CONFIG_PARTITION_TABLE_FILENAME is unset, means we haven't re-generated config yet...
|
|
ifneq ("$(CONFIG_PARTITION_TABLE_FILENAME)","")
|
|
|
|
ifndef PARTITION_TABLE_CSV_PATH
|
|
# Path to partition CSV file is relative to project path for custom
|
|
# partition CSV files, but relative to component dir otherwise.
|
|
PARTITION_TABLE_ROOT := $(call dequote,$(if $(CONFIG_PARTITION_TABLE_CUSTOM),$(PROJECT_PATH),$(COMPONENT_PATH)))
|
|
PARTITION_TABLE_CSV_PATH := $(call dequote,$(abspath $(PARTITION_TABLE_ROOT)/$(call dequote,$(CONFIG_PARTITION_TABLE_FILENAME))))
|
|
endif
|
|
|
|
PARTITION_TABLE_CSV_NAME := $(notdir $(PARTITION_TABLE_CSV_PATH))
|
|
|
|
PARTITION_TABLE_BIN := $(BUILD_DIR_BASE)/$(PARTITION_TABLE_CSV_NAME:.csv=.bin)
|
|
|
|
ifdef CONFIG_SECURE_BOOT_V1_ENABLED
|
|
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
|
PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN:.bin=-unsigned.bin)
|
|
# add an extra signing step for secure partition table
|
|
$(PARTITION_TABLE_BIN): $(PARTITION_TABLE_BIN_UNSIGNED) $(SDKCONFIG_MAKEFILE) $(SECURE_BOOT_SIGNING_KEY)
|
|
$(ESPSECUREPY) sign_data --version 1 --keyfile $(SECURE_BOOT_SIGNING_KEY) -o $@ $<
|
|
else
|
|
# secure bootloader disabled, both files are the same
|
|
PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN)
|
|
endif
|
|
else
|
|
# secure bootloader disabled, both files are the same
|
|
PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN)
|
|
endif
|
|
|
|
$(PARTITION_TABLE_BIN_UNSIGNED): $(PARTITION_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFILE) | check_python_dependencies
|
|
@echo "Building partitions from $(PARTITION_TABLE_CSV_PATH)..."
|
|
$(GEN_ESP32PART) $< $@
|
|
|
|
all_binaries: $(PARTITION_TABLE_BIN) partition_table_get_info check_table_contents
|
|
|
|
partition_table_get_info: $(PARTITION_TABLE_BIN)
|
|
$(eval PHY_DATA_OFFSET:=$(shell $(GET_PART_INFO) --partition-table-file $(PARTITION_TABLE_BIN) \
|
|
--partition-table-offset $(PARTITION_TABLE_OFFSET) \
|
|
get_partition_info --partition-type data --partition-subtype phy --info offset))
|
|
$(eval APP_OFFSET:=$(shell $(GET_PART_INFO) --partition-table-file $(PARTITION_TABLE_BIN) \
|
|
--partition-table-offset $(PARTITION_TABLE_OFFSET) \
|
|
get_partition_info --partition-boot-default --info offset))
|
|
$(eval OTA_DATA_OFFSET:=$(shell $(GET_PART_INFO) --partition-table-file $(PARTITION_TABLE_BIN) \
|
|
--partition-table-offset $(PARTITION_TABLE_OFFSET) \
|
|
get_partition_info --partition-type data --partition-subtype ota --info offset))
|
|
$(eval OTA_DATA_SIZE:=$(shell $(GET_PART_INFO) --partition-table-file $(PARTITION_TABLE_BIN) \
|
|
--partition-table-offset $(PARTITION_TABLE_OFFSET) \
|
|
get_partition_info --partition-type data --partition-subtype ota --info size))
|
|
$(eval FACTORY_OFFSET:=$(shell $(GET_PART_INFO) --partition-table-file $(PARTITION_TABLE_BIN) \
|
|
--partition-table-offset $(PARTITION_TABLE_OFFSET) \
|
|
get_partition_info --partition-type app --partition-subtype factory --info offset))
|
|
|
|
export APP_OFFSET
|
|
export PHY_DATA_OFFSET
|
|
export OTA_DATA_OFFSET
|
|
export OTA_DATA_SIZE
|
|
|
|
# If anti-rollback option is set then factory partition should not be in Partition Table.
|
|
# In this case, should be used the partition table with two ota app without the factory.
|
|
check_table_contents: partition_table_get_info
|
|
@echo $(if $(CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK), $(if $(FACTORY_OFFSET), $(error "ERROR: Anti-rollback option is enabled. Partition table should consist of two ota app without factory partition."), ""), "")
|
|
|
|
PARTITION_TABLE_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
|
|
ESPTOOL_ALL_FLASH_ARGS += $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
|
|
UF2_ADD_BINARIES += $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
|
|
|
|
partition_table: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
|
|
@echo "Partition table binary generated. Contents:"
|
|
@echo $(SEPARATOR)
|
|
$(GEN_ESP32PART) $<
|
|
@echo $(SEPARATOR)
|
|
@echo "Partition flashing command:"
|
|
@echo "$(PARTITION_TABLE_FLASH_CMD)"
|
|
|
|
partition_table-flash: $(PARTITION_TABLE_BIN) | check_python_dependencies
|
|
@echo "Flashing partition table..."
|
|
$(PARTITION_TABLE_FLASH_CMD)
|
|
|
|
partition_table-clean:
|
|
rm -f $(PARTITION_TABLE_BIN)
|
|
|
|
clean: partition_table-clean
|
|
|
|
endif
|