2016-08-17 11:08:22 -04: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 00:42:26 -04:00
.PHONY : partition_table partition_table -flash partition_table -clean partition_table_get_info
2016-08-17 11:08:22 -04:00
2018-04-25 22:07:27 -04:00
PARTITION_MD5_OPT :=
2018-07-12 21:52:57 -04:00
i f n d e f C O N F I G _ P A R T I T I O N _ T A B L E _ M D 5
2018-04-25 22:07:27 -04:00
PARTITION_MD5_OPT := "--disable-md5sum"
2018-02-16 05:12:16 -05:00
e n d i f
2018-04-25 22:07:27 -04:00
PARTITION_FLASHSIZE_OPT :=
2018-04-20 02:57:15 -04:00
i f n e q ( "$(CONFIG_ESPTOOLPY_FLASHSIZE)" , "" )
2018-04-25 22:07:27 -04:00
PARTITION_FLASHSIZE_OPT := --flash-size $( CONFIG_ESPTOOLPY_FLASHSIZE)
2018-04-20 02:57:15 -04:00
e n d i f
2018-07-12 21:52:57 -04:00
PARTITION_SECURE_OPT :=
2020-02-24 14:51:41 -05:00
i f d e f C O N F I G _ S E C U R E _ B O O T
2018-07-12 21:52:57 -04:00
i f n d e f C O N F I G _ S E C U R E _ B O O T _ A L L O W _ S H O R T _ A P P _ P A R T I T I O N
2023-02-12 10:59:39 -05:00
i f d e f C O N F I G _ S E C U R E _ B O O T _ V 2 _ E N A B L E D
PARTITION_SECURE_OPT += --secure v2
e l s e
PARTITION_SECURE_OPT += --secure v1
e n d i f
2018-07-12 21:52:57 -04:00
e n d i f
e n d i f
2018-04-19 00:42:26 -04:00
# Address of partition table
PARTITION_TABLE_OFFSET := $( CONFIG_PARTITION_TABLE_OFFSET)
PARTITION_TABLE_OFFSET_ARG := --offset $( PARTITION_TABLE_OFFSET)
2016-08-17 11:08:22 -04:00
2018-07-12 21:52:57 -04: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 00:42:26 -04:00
GET_PART_INFO := $( COMPONENT_PATH) /parttool.py -q
2016-11-06 22:35:23 -05:00
2017-06-23 00:08:01 -04:00
# if CONFIG_PARTITION_TABLE_FILENAME is unset, means we haven't re-generated config yet...
i f n e q ( "$(CONFIG_PARTITION_TABLE_FILENAME)" , "" )
2016-12-21 13:18:42 -05:00
i f n d e f P A R T I T I O N _ T A B L E _ C S V _ P A T H
2016-08-17 11:08:22 -04:00
# Path to partition CSV file is relative to project path for custom
2017-10-18 08:43:43 -04:00
# partition CSV files, but relative to component dir otherwise.
2016-08-17 11:08:22 -04:00
PARTITION_TABLE_ROOT := $( call dequote,$( if $( CONFIG_PARTITION_TABLE_CUSTOM) ,$( PROJECT_PATH) ,$( COMPONENT_PATH) ) )
2017-10-20 00:14:41 -04:00
PARTITION_TABLE_CSV_PATH := $( call dequote,$( abspath $( PARTITION_TABLE_ROOT) /$( call dequote,$( CONFIG_PARTITION_TABLE_FILENAME) ) ) )
2016-12-21 13:18:42 -05:00
e n d i f
2016-08-17 11:08:22 -04:00
2017-06-23 00:08:01 -04: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 11:08:22 -04:00
2020-02-24 14:51:41 -05:00
i f d e f C O N F I G _ S E C U R E _ B O O T _ V 1 _ E N A B L E D
2016-12-18 21:06:21 -05:00
i f d e f C O N F I G _ S E C U R E _ B O O T _ B U I L D _ S I G N E D _ B I N A R I E S
2016-11-06 23:45:57 -05:00
PARTITION_TABLE_BIN_UNSIGNED := $( PARTITION_TABLE_BIN:.bin= -unsigned.bin)
# add an extra signing step for secure partition table
2016-11-24 22:13:05 -05:00
$(PARTITION_TABLE_BIN) : $( PARTITION_TABLE_BIN_UNSIGNED ) $( SDKCONFIG_MAKEFILE ) $( SECURE_BOOT_SIGNING_KEY )
2020-02-24 14:51:41 -05:00
$( ESPSECUREPY) sign_data --version 1 --keyfile $( SECURE_BOOT_SIGNING_KEY) -o $@ $<
e l s e
# secure bootloader disabled, both files are the same
PARTITION_TABLE_BIN_UNSIGNED := $( PARTITION_TABLE_BIN)
e n d i f
2016-11-06 23:45:57 -05:00
e l s e
# secure bootloader disabled, both files are the same
PARTITION_TABLE_BIN_UNSIGNED := $( PARTITION_TABLE_BIN)
2016-11-03 02:33:30 -04:00
e n d i f
2016-08-17 11:08:22 -04:00
2018-08-20 03:39:56 -04:00
$(PARTITION_TABLE_BIN_UNSIGNED) : $( PARTITION_TABLE_CSV_PATH ) $( SDKCONFIG_MAKEFILE ) | check_python_dependencies
2016-08-17 11:08:22 -04:00
@echo " Building partitions from $( PARTITION_TABLE_CSV_PATH) ... "
2016-11-10 20:29:38 -05:00
$( GEN_ESP32PART) $< $@
2016-08-17 11:08:22 -04:00
2019-02-13 04:32:23 -05:00
all_binaries : $( PARTITION_TABLE_BIN ) partition_table_get_info check_table_contents
2018-04-19 00:42:26 -04:00
partition_table_get_info : $( PARTITION_TABLE_BIN )
2019-05-26 23:07:54 -04:00
$( eval PHY_DATA_OFFSET:= $( shell $( GET_PART_INFO) --partition-table-file $( PARTITION_TABLE_BIN) \
2019-06-04 03:49:55 -04:00
--partition-table-offset $( PARTITION_TABLE_OFFSET) \
2019-05-26 23:07:54 -04:00
get_partition_info --partition-type data --partition-subtype phy --info offset) )
$( eval APP_OFFSET:= $( shell $( GET_PART_INFO) --partition-table-file $( PARTITION_TABLE_BIN) \
2019-06-04 03:49:55 -04:00
--partition-table-offset $( PARTITION_TABLE_OFFSET) \
2019-05-26 23:07:54 -04:00
get_partition_info --partition-boot-default --info offset) )
$( eval OTA_DATA_OFFSET:= $( shell $( GET_PART_INFO) --partition-table-file $( PARTITION_TABLE_BIN) \
2019-06-04 03:49:55 -04:00
--partition-table-offset $( PARTITION_TABLE_OFFSET) \
2019-05-26 23:07:54 -04:00
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) \
2019-06-04 03:49:55 -04:00
--partition-table-offset $( PARTITION_TABLE_OFFSET) \
2019-05-26 23:07:54 -04:00
get_partition_info --partition-type data --partition-subtype ota --info size) )
$( eval FACTORY_OFFSET:= $( shell $( GET_PART_INFO) --partition-table-file $( PARTITION_TABLE_BIN) \
2019-06-04 03:49:55 -04:00
--partition-table-offset $( PARTITION_TABLE_OFFSET) \
2019-05-26 23:07:54 -04:00
get_partition_info --partition-type app --partition-subtype factory --info offset) )
2018-04-19 00:42:26 -04:00
export APP_OFFSET
export PHY_DATA_OFFSET
2018-06-25 02:53:10 -04:00
export OTA_DATA_OFFSET
export OTA_DATA_SIZE
2016-08-18 05:11:27 -04:00
2019-02-13 04:32:23 -05:00
# 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
2019-05-09 08:10:35 -04:00
@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." ) , "" ) , "" )
2019-02-13 04:32:23 -05:00
2016-11-06 22:35:23 -05: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)
2020-12-11 10:28:11 -05:00
UF2_ADD_BINARIES += $( PARTITION_TABLE_OFFSET) $( PARTITION_TABLE_BIN)
2016-08-17 11:08:22 -04:00
2018-09-03 05:42:10 -04:00
partition_table : $( PARTITION_TABLE_BIN ) partition_table_get_info | check_python_dependencies
2016-08-17 11:08:22 -04:00
@echo "Partition table binary generated. Contents:"
@echo $( SEPARATOR)
2016-11-10 20:29:38 -05:00
$( GEN_ESP32PART) $<
2016-08-17 11:08:22 -04:00
@echo $( SEPARATOR)
@echo "Partition flashing command:"
@echo " $( PARTITION_TABLE_FLASH_CMD) "
2018-09-03 05:42:10 -04:00
partition_table-flash : $( PARTITION_TABLE_BIN ) | check_python_dependencies
2016-08-17 11:08:22 -04:00
@echo "Flashing partition table..."
2016-11-10 20:29:38 -05:00
$( PARTITION_TABLE_FLASH_CMD)
2016-08-17 11:08:22 -04:00
partition_table-clean :
2016-11-10 20:29:38 -05:00
rm -f $( PARTITION_TABLE_BIN)
2016-08-18 05:11:27 -04:00
clean : partition_table -clean
2017-06-23 00:08:01 -04:00
e n d i f