Skip to content

Commit f620ab6

Browse files
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
2 parents 4c589d6 + b719292 commit f620ab6

File tree

4 files changed

+13
-37
lines changed

4 files changed

+13
-37
lines changed

components/bootloader/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ if(NOT CONFIG_SECURE_BOOT OR CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT)
3232
esptool_py_flash_target_image(flash bootloader
3333
${CONFIG_BOOTLOADER_OFFSET_IN_FLASH}
3434
"${BOOTLOADER_BUILD_DIR}/bootloader.bin")
35+
36+
# Add bootloader as a dependency to the flash target
37+
add_dependencies(flash bootloader)
3538
endif()

components/esptool_py/project_include.cmake

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -745,39 +745,6 @@ function(__esptool_py_setup_utility_targets)
745745
)
746746
endfunction()
747747

748-
# __esptool_py_setup_main_flash_target
749-
#
750-
# @brief Sets up the main `flash` target and its dependencies.
751-
#
752-
# This function creates the main `flash` target, which is used to flash multiple
753-
# images to the target device. It determines the dependencies for a full
754-
# project flash (bootloader, partition table, the main app) and then calls
755-
#
756-
function(__esptool_py_setup_main_flash_target)
757-
__ensure_esptool_py_setup()
758-
759-
idf_build_get_property(non_os_build NON_OS_BUILD)
760-
761-
if(NOT non_os_build)
762-
set(flash_deps "")
763-
764-
if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
765-
list(APPEND flash_deps "partition_table_bin")
766-
endif()
767-
768-
if(CONFIG_APP_BUILD_GENERATE_BINARIES)
769-
list(APPEND flash_deps "app")
770-
endif()
771-
772-
if(CONFIG_APP_BUILD_BOOTLOADER)
773-
list(APPEND flash_deps "bootloader")
774-
endif()
775-
776-
# Create the flash target. If encryption is enabled, it will also create
777-
# an encrypted-flash target.
778-
esptool_py_custom_target(flash project "${flash_deps}" FILENAME_PREFIX "flash")
779-
endif()
780-
endfunction()
781748

782749
# Adds espefuse functions for global use
783750
idf_component_get_property(esptool_py_dir esptool_py COMPONENT_DIR)

components/partition_table/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,8 @@ if(CONFIG_APP_BUILD_GENERATE_BINARIES AND CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
174174
"${build_dir}/partition_table/${final_partition_bin}")
175175
esptool_py_flash_target_image(flash partition-table "${PARTITION_TABLE_OFFSET}"
176176
"${build_dir}/partition_table/${final_partition_bin}")
177+
178+
# Add partition table as a dependency to the flash target
179+
add_dependencies(flash partition_table_bin)
177180
add_deprecated_target_alias(partition_table-flash partition-table-flash)
178181
endif()

tools/cmake/flash_targets.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ function(__idf_build_setup_flash_targets)
1111
idf_build_get_property(build_dir BUILD_DIR)
1212
idf_build_get_property(project_bin PROJECT_BIN)
1313
partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
14-
esptool_py_custom_target(app-flash app "app")
1514

15+
# Create app-flash target for flashing just the application
16+
esptool_py_custom_target(app-flash app "app")
1617
esptool_py_flash_target_image(app-flash app "${app_partition_offset}" "${build_dir}/${project_bin}")
17-
esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${project_bin}")
1818

19-
# Setup the main flash target and dependencies
20-
__esptool_py_setup_main_flash_target()
19+
# Create main flash target for flashing the entire system (bootloader + partition table + app)
20+
# Note: Bootloader and partition table components add their own dependencies to this flash target
21+
# in their respective CMakeLists.txt files
22+
esptool_py_custom_target(flash project "app" FILENAME_PREFIX "flash")
23+
esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${project_bin}")
2124

2225
# Generate flasher_args.json configuration files
2326
__idf_build_generate_flasher_args()

0 commit comments

Comments
 (0)