From fdf644cf1fb46cb55598e9b9d963451cb8699498 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Mon, 17 Feb 2025 16:32:44 +0100 Subject: [PATCH] zephyr: fix Mbed TLS configuration header file selection Mbed TLS already provides MBEDTLS_CFG_FILE Kconfig when it's builtin. So we only need to override that config when not using the builtin Mbed TLS version. This commit also fixes some hardcoding of "mcuboot-mbedtls-cfg.h" in Kconfig and prj.conf. Signed-off-by: Valerio Setti --- boot/zephyr/CMakeLists.txt | 4 ++-- boot/zephyr/Kconfig | 3 +-- boot/zephyr/prj.conf | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt index b332000da..387152d4b 100644 --- a/boot/zephyr/CMakeLists.txt +++ b/boot/zephyr/CMakeLists.txt @@ -210,7 +210,7 @@ if(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 OR CONFIG_BOOT_ENCRYPT_EC256) # to set MBEDTLS_CONFIG_FILE ourselves. When using Zephyr's copy, this # variable is set by its Kconfig in the Zephyr codebase. zephyr_library_compile_definitions( - MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h" + MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}" ) elseif(CONFIG_BOOT_SIGNATURE_TYPE_NONE) zephyr_library_include_directories( @@ -256,7 +256,7 @@ elseif(CONFIG_BOOT_SIGNATURE_TYPE_ED25519 OR CONFIG_BOOT_ENCRYPT_X25519) ${TINYCRYPT_SHA512_DIR}/source/sha512.c ) zephyr_library_compile_definitions( - MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h" + MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}" ) else() zephyr_include_directories(include) diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig index 9afd292b0..5fbfd73a7 100644 --- a/boot/zephyr/Kconfig +++ b/boot/zephyr/Kconfig @@ -286,8 +286,7 @@ config MCUBOOT_CLEANUP_RAM if MBEDTLS config MBEDTLS_CFG_FILE - default "config-tls-generic.h" if MBEDTLS_BUILTIN - default "mcuboot-mbedtls-cfg.h" if BOOT_USE_MBEDTLS + default "mcuboot-mbedtls-cfg.h" if BOOT_USE_MBEDTLS && !MBEDTLS_BUILTIN endif diff --git a/boot/zephyr/prj.conf b/boot/zephyr/prj.conf index 851c133ec..119e07579 100644 --- a/boot/zephyr/prj.conf +++ b/boot/zephyr/prj.conf @@ -1,7 +1,6 @@ CONFIG_PM=n CONFIG_MAIN_STACK_SIZE=10240 -CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" CONFIG_BOOT_SWAP_SAVE_ENCTLV=n CONFIG_BOOT_ENCRYPT_IMAGE=n