From 28f1b186756000f980de00c99fa3666cd74e2fec Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Mon, 16 Dec 2024 17:35:34 +0800 Subject: [PATCH] fix(bootloader): add a new property that contains the default linker scripts --- components/bootloader/subproject/CMakeLists.txt | 4 ++++ components/bootloader/subproject/main/CMakeLists.txt | 7 +------ .../bootloader_components/main/CMakeLists.txt | 10 ++-------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index 2a74c266d1..60accb480f 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -65,6 +65,10 @@ set(common_req log esp_rom esp_common esp_hw_support newlib) idf_build_set_property(EXTRA_COMPONENT_EXCLUDE_DIRS "${EXTRA_COMPONENT_EXCLUDE_DIRS}") idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${common_req}") idf_build_set_property(__OUTPUT_SDKCONFIG 0) +# Define a property for the default linker script +set(LD_DEFAULT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/main/ld/${IDF_TARGET}") +idf_build_set_property(BOOTLOADER_LINKER_SCRIPT "${LD_DEFAULT_PATH}/bootloader.ld" APPEND) +idf_build_set_property(BOOTLOADER_LINKER_SCRIPT "${LD_DEFAULT_PATH}/bootloader.rom.ld" APPEND) project(bootloader) idf_build_set_property(COMPILE_DEFINITIONS "BOOTLOADER_BUILD=1" APPEND) diff --git a/components/bootloader/subproject/main/CMakeLists.txt b/components/bootloader/subproject/main/CMakeLists.txt index fa832f63b7..a28ff8f61d 100644 --- a/components/bootloader/subproject/main/CMakeLists.txt +++ b/components/bootloader/subproject/main/CMakeLists.txt @@ -1,12 +1,7 @@ idf_component_register(SRCS "bootloader_start.c" REQUIRES bootloader bootloader_support) -set(target_folder "${target}") - -idf_build_get_property(target IDF_TARGET) -set(scripts "ld/${target_folder}/bootloader.ld") - -list(APPEND scripts "ld/${target_folder}/bootloader.rom.ld") +idf_build_get_property(scripts BOOTLOADER_LINKER_SCRIPT) target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}") target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bootloader_hooks_include") diff --git a/examples/custom_bootloader/bootloader_override/bootloader_components/main/CMakeLists.txt b/examples/custom_bootloader/bootloader_override/bootloader_components/main/CMakeLists.txt index 261a7fa29c..38781730f8 100644 --- a/examples/custom_bootloader/bootloader_override/bootloader_components/main/CMakeLists.txt +++ b/examples/custom_bootloader/bootloader_override/bootloader_components/main/CMakeLists.txt @@ -1,12 +1,6 @@ idf_component_register(SRCS "bootloader_start.c" REQUIRES bootloader bootloader_support) -idf_build_get_property(target IDF_TARGET) - -set(target_folder "${target}") - -# Use the linker script files from the actual bootloader -set(scripts "${IDF_PATH}/components/bootloader/subproject/main/ld/${target_folder}/bootloader.ld" - "${IDF_PATH}/components/bootloader/subproject/main/ld/${target_folder}/bootloader.rom.ld") - +# Use the default linker scripts +idf_build_get_property(scripts BOOTLOADER_LINKER_SCRIPT) target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}")