Merge branch 'feat/move_bootloader_part_table_flash_deps' into 'master'

refactor(build-system): Simplify flash target creation

See merge request espressif/esp-idf!41777
This commit is contained in:
Sudeep Mohanty
2025-09-24 11:43:48 +02:00
4 changed files with 13 additions and 37 deletions

View File

@@ -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()

View File

@@ -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)

View File

@@ -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()

View File

@@ -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()