mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 10:00:57 +02:00
refactor(build-system): Simplify flash target creation
This commit refactors the flash target creation. Now bootloader and partition table components add dependencies to the flash target directly from their component CMakeLists.txt files instead of it being done in the esptool_py component. The commit also removes the redundant __esptool_py_setup_main_flash_target() function.
This commit is contained in:
@@ -32,4 +32,7 @@ if(NOT CONFIG_SECURE_BOOT OR CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT)
|
||||
esptool_py_flash_target_image(flash bootloader
|
||||
${CONFIG_BOOTLOADER_OFFSET_IN_FLASH}
|
||||
"${BOOTLOADER_BUILD_DIR}/bootloader.bin")
|
||||
|
||||
# Add bootloader as a dependency to the flash target
|
||||
add_dependencies(flash bootloader)
|
||||
endif()
|
||||
|
@@ -745,39 +745,6 @@ function(__esptool_py_setup_utility_targets)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# __esptool_py_setup_main_flash_target
|
||||
#
|
||||
# @brief Sets up the main `flash` target and its dependencies.
|
||||
#
|
||||
# This function creates the main `flash` target, which is used to flash multiple
|
||||
# images to the target device. It determines the dependencies for a full
|
||||
# project flash (bootloader, partition table, the main app) and then calls
|
||||
#
|
||||
function(__esptool_py_setup_main_flash_target)
|
||||
__ensure_esptool_py_setup()
|
||||
|
||||
idf_build_get_property(non_os_build NON_OS_BUILD)
|
||||
|
||||
if(NOT non_os_build)
|
||||
set(flash_deps "")
|
||||
|
||||
if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
|
||||
list(APPEND flash_deps "partition_table_bin")
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BUILD_GENERATE_BINARIES)
|
||||
list(APPEND flash_deps "app")
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BUILD_BOOTLOADER)
|
||||
list(APPEND flash_deps "bootloader")
|
||||
endif()
|
||||
|
||||
# Create the flash target. If encryption is enabled, it will also create
|
||||
# an encrypted-flash target.
|
||||
esptool_py_custom_target(flash project "${flash_deps}" FILENAME_PREFIX "flash")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Adds espefuse functions for global use
|
||||
idf_component_get_property(esptool_py_dir esptool_py COMPONENT_DIR)
|
||||
|
@@ -174,5 +174,8 @@ if(CONFIG_APP_BUILD_GENERATE_BINARIES AND CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
|
||||
"${build_dir}/partition_table/${final_partition_bin}")
|
||||
esptool_py_flash_target_image(flash partition-table "${PARTITION_TABLE_OFFSET}"
|
||||
"${build_dir}/partition_table/${final_partition_bin}")
|
||||
|
||||
# Add partition table as a dependency to the flash target
|
||||
add_dependencies(flash partition_table_bin)
|
||||
add_deprecated_target_alias(partition_table-flash partition-table-flash)
|
||||
endif()
|
||||
|
@@ -11,13 +11,16 @@ function(__idf_build_setup_flash_targets)
|
||||
idf_build_get_property(build_dir BUILD_DIR)
|
||||
idf_build_get_property(project_bin PROJECT_BIN)
|
||||
partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
|
||||
|
||||
# Create app-flash target for flashing just the application
|
||||
esptool_py_custom_target(app-flash app "app")
|
||||
|
||||
esptool_py_flash_target_image(app-flash app "${app_partition_offset}" "${build_dir}/${project_bin}")
|
||||
esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${project_bin}")
|
||||
|
||||
# Setup the main flash target and dependencies
|
||||
__esptool_py_setup_main_flash_target()
|
||||
# Create main flash target for flashing the entire system (bootloader + partition table + app)
|
||||
# Note: Bootloader and partition table components add their own dependencies to this flash target
|
||||
# in their respective CMakeLists.txt files
|
||||
esptool_py_custom_target(flash project "app" FILENAME_PREFIX "flash")
|
||||
esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${project_bin}")
|
||||
|
||||
# Generate flasher_args.json configuration files
|
||||
__idf_build_generate_flasher_args()
|
||||
|
Reference in New Issue
Block a user