From 8c363321db546b7d5dae71e5cfcbc2892cfb4b4f Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Wed, 15 May 2019 11:40:57 +0800 Subject: [PATCH 1/2] cmake: fix custom bootloader issue Issue is that when users creates a custom bootloader from $IDF_PATH/components/bootloader. Parent project build uses the copy but bootloader subproject build uses the original still. The issue is solved by passing the custom bootloader as extra component directory so bootloader build knows to use the new copy (itself) in the build. --- components/bootloader/project_include.cmake | 3 ++- components/bootloader/subproject/CMakeLists.txt | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/bootloader/project_include.cmake b/components/bootloader/project_include.cmake index e08c18f7dd..209957c978 100644 --- a/components/bootloader/project_include.cmake +++ b/components/bootloader/project_include.cmake @@ -49,10 +49,11 @@ if((NOT CONFIG_SECURE_BOOT_ENABLED) OR CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH) externalproject_add(bootloader # TODO: support overriding the bootloader in COMPONENT_PATHS - SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject" + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject" BINARY_DIR "${bootloader_build_dir}" CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH} -DSECURE_BOOT_SIGNING_KEY=${secure_boot_signing_key} + -DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR} INSTALL_COMMAND "" BUILD_ALWAYS 1 # no easy way around this... BUILD_BYPRODUCTS ${bootloader_binary_files} diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index aad0ff99eb..9459c13420 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -27,9 +27,9 @@ target_linker_script(bootloader.elf # as cmake won't attach linker args to a header-only library, attach # linker args directly to the bootloader.elf set(ESP32_BOOTLOADER_LINKER_SCRIPTS - "../../esp32/ld/esp32.rom.ld" - "../../esp32/ld/esp32.rom.spiram_incompatible_fns.ld" - "../../esp32/ld/esp32.peripherals.ld") + "${IDF_PATH}/components/esp32/ld/esp32.rom.ld" + "${IDF_PATH}/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld" + "${IDF_PATH}/components/esp32/ld/esp32.peripherals.ld") target_linker_script(bootloader.elf ${ESP32_BOOTLOADER_LINKER_SCRIPTS}) From e821c22a8c5df4cb15cd7f5d13f7cf746842dca2 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Wed, 15 May 2019 14:49:51 +0800 Subject: [PATCH 2/2] ci: check that custom bootloader overrides original --- tools/ci/test_build_system_cmake.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 75fb523c4a..1c0b0b3e34 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -365,6 +365,14 @@ EOF export PATH="$OLDPATH" rm ./python + print_status "Custom bootloader overrides original" + clean_build_dir + (mkdir components && cd components && cp -r $IDF_PATH/components/bootloader .) + idf.py build + grep "$PWD/components/bootloader/subproject/main/bootloader_start.c" build/bootloader/compile_commands.json \ + || failure "Custom bootloader source files should be built instead of the original's" + rm -rf components + print_status "All tests completed" if [ -n "${FAILURES}" ]; then echo "Some failures were detected:"