cmake: Add partition table generation

This commit is contained in:
Angus Gratton 2018-01-18 12:12:13 +11:00 committed by Angus Gratton
parent 97e01a4c4d
commit 3ae4822115
2 changed files with 47 additions and 0 deletions

View file

@ -1 +1,46 @@
set(partition_table_offset 0x8000)
# Set partition_csv to the configured partition source file
#
if(CONFIG_PARTITION_TABLE_CUSTOM)
# Custom filename expands any path relative to the project
get_filename_component(partition_csv "${CONFIG_PARTITION_TABLE_CUSTOM}" ABSOLUTE BASE_DIR "${PROJECT_PATH}")
else()
# Other .csv files are always in the component directory
set(partition_csv "${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_PARTITION_TABLE_FILENAME}")
endif()
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
set(unsigned_partition_bin "partition-unsigned.bin")
set(final_partition_bin "partition.bin")
set(final_partition_target "sign_partition_table")
else()
set(unsigned_partition_bin "partition.bin")
set(final_partition_bin "partition.bin")
set(final_partition_target "build_partition_table")
endif()
add_custom_target(build_partition_table ALL
"${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py" -q
${partition_csv} ${unsigned_partition_bin}
BYPRODUCTS ${unsigned_partition_bin}
DEPENDS ${partition_csv} "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
VERBATIM)
# Add signing steps
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
get_filename_component(secure_boot_signing_key "${CONFIG_SECURE_BOOT_SIGNING_KEY}" ABSOLUTE BASE_DIR "${PROJECT_PATH}")
add_custom_target(signpartition_table ALL
"${PYTHON}" "${ESPSECUREPY}" sign_data --keyfile "${secure_boot_signing_key}" -o "${final_partition_bin}" "${unsigned_partition_bin}"
BYPRODUCTS "${final_partition_bin}"
DEPENDS "${unsigned_partition_bin}"
VERBATIM)
endif()
# Use global properties ESPTOOL_WRITE_FLASH_ARGS & FLASH_DEPENDS to pass this info to the esptool component for flashing
set_property(GLOBAL APPEND_STRING PROPERTY ESPTOOL_WRITE_FLASH_ARGS "${final_partition_bin} ${partition_table_offset} ")
set_property(GLOBAL APPEND PROPERTY FLASH_DEPENDS "${final_partition_target}")
register_config_only_component()

View file

@ -38,6 +38,8 @@ kconfig_process_config()
# Include sdkconfig.cmake so rest of the build knows the configuration
include(${SDKCONFIG_CMAKE})
set(PYTHON "${CONFIG_PYTHON}")
# Add some idf-wide definitions
idf_set_global_compiler_options()