mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-04 11:55:21 +02:00
bootloader: Add support of anti-rollback
Added: * set a secure version in app/bootloader. * description anti-rollback to ota part * emulate the secure_version write and read operations * efuse_em partition. * a description about a rollback for native_ota_example. Closes: TW26335
This commit is contained in:
@@ -69,6 +69,15 @@ if(CONFIG_SECURE_BOOT_ENABLED AND
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
# 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.
|
||||
if(CONFIG_APP_ANTI_ROLLBACK AND FACTORY_OFFSET)
|
||||
fail_at_build_time(check_table_contents
|
||||
"ERROR: Anti-rollback option is enabled. Partition table should consist of two ota app without factory partition.")
|
||||
add_dependencies(bootloader check_table_contents)
|
||||
add_dependencies(app check_table_contents)
|
||||
endif()
|
||||
|
||||
add_dependencies(bootloader partition_table)
|
||||
add_dependencies(app partition_table)
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ $(PARTITION_TABLE_BIN_UNSIGNED): $(PARTITION_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFIL
|
||||
@echo "Building partitions from $(PARTITION_TABLE_CSV_PATH)..."
|
||||
$(GEN_ESP32PART) $< $@
|
||||
|
||||
all_binaries: $(PARTITION_TABLE_BIN) partition_table_get_info
|
||||
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-type data --partition-subtype phy \
|
||||
@@ -71,12 +71,19 @@ partition_table_get_info: $(PARTITION_TABLE_BIN)
|
||||
--partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --info offset))
|
||||
$(eval OTA_DATA_SIZE:=$(shell $(GET_PART_INFO) --partition-type data --partition-subtype ota \
|
||||
--partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --info size))
|
||||
$(eval FACTORY_OFFSET:=$(shell $(GET_PART_INFO) --partition-type app --partition-subtype factory \
|
||||
--partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --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_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)
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ SUBTYPES = {
|
||||
"nvs": 0x02,
|
||||
"coredump": 0x03,
|
||||
"nvs_keys": 0x04,
|
||||
"efuse": 0x05,
|
||||
"esphttpd": 0x80,
|
||||
"fat": 0x81,
|
||||
"spiffs": 0x82,
|
||||
|
||||
@@ -60,6 +60,9 @@ get_partition_info(OTADATA_PARTITION_OFFSET
|
||||
get_partition_info(OTADATA_PARTITION_SIZE
|
||||
"--partition-type data --partition-subtype ota" "size")
|
||||
|
||||
get_partition_info(FACTORY_OFFSET
|
||||
"--partition-type app --partition-subtype factory" "offset")
|
||||
|
||||
endif()
|
||||
|
||||
set(BOOTLOADER_OFFSET 0x1000)
|
||||
|
||||
Reference in New Issue
Block a user