From b3c631e188ea99063a42a7912b19d1582b5ae9f0 Mon Sep 17 00:00:00 2001 From: Arthur Gay Date: Fri, 24 Oct 2025 19:43:29 +0200 Subject: [PATCH] cmake: mcuboot: Flash encrypted image when loading to RAM When both `SB_CONFIG_MCUBOOT_MODE_RAM_LOAD` and `SB_CONFIG_BOOT_ENCRYPTION` are enabled, MCUBoot loads an encrypted image from flash, decrypts it, and then executes it from RAM. Previously, the unencrypted image was being flashed. This caused a boot failure because MCUBoot would attempt to decrypt an unencrypted image. This commit ensures the encrypted image is flashed when this configuration is active, allowing the system to boot correctly. Signed-off-by: Arthur Gay --- cmake/mcuboot.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/mcuboot.cmake b/cmake/mcuboot.cmake index 43d265c419d5f..d1e4a6761c14e 100644 --- a/cmake/mcuboot.cmake +++ b/cmake/mcuboot.cmake @@ -283,6 +283,9 @@ function(zephyr_mcuboot_tasks) set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${imgtool_sign} ${imgtool_args} --encrypt "${keyfile_enc}" ${output}.hex ${output}.signed.encrypted.hex) + if(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) + zephyr_runner_file(hex ${output}.signed.encrypted.hex) + endif() endif() if(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD OR CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT)