From 8abd562fd3b59fb073c6132b5cc1e88dddb18691 Mon Sep 17 00:00:00 2001 From: Almir Okato Date: Thu, 22 May 2025 13:02:09 -0300 Subject: [PATCH 1/2] espressif: mcuboot: get MCUBOOT_BOOT_MAX_ALIGN value from DT This change affects only MCUboot Zephyr Port for ESP chips or Zephyr application with MCUboot compatibilty (which builds the bootutil lib). In these cases, MCUBOOT_BOOT_MAX_ALIGN value must be taken from DT flash write-block-size if its greater than 8. Signed-off-by: Almir Okato --- .../port/include/boot/mcuboot_config/mcuboot_config.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h b/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h index ade7590637..1332494118 100644 --- a/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h +++ b/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h @@ -7,6 +7,8 @@ #ifndef __MCUBOOT_CONFIG_H__ #define __MCUBOOT_CONFIG_H__ +#include + /* * Signature types * @@ -29,8 +31,13 @@ #define MCUBOOT_SIGN_ED25519 #endif -#if defined(CONFIG_SECURE_FLASH_ENC_ENABLED) -#define MCUBOOT_BOOT_MAX_ALIGN 32 +/* This mcuboot_config.h is used only by Zephyr builds, such as MCUboot + * Zephyr Port for ESP chips or a Zephyr application with MCUboot + * compatibilty (that builds the bootutil lib). + * In these cases, MCUBOOT_BOOT_MAX_ALIGN value must be taken from DT if + * the write-block-size is greater than 8 */ +#if DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size) > 8 +#define MCUBOOT_BOOT_MAX_ALIGN DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size) #endif /* From 8304d6a36445a4591e4af957827b96cb64fd8f50 Mon Sep 17 00:00:00 2001 From: Almir Okato Date: Sat, 24 May 2025 15:02:21 -0300 Subject: [PATCH 2/2] espressif: port: add MCUBOOT_FLASH_HAS_HW_ENCRYPTION config to mcuboot_config header Signed-off-by: Almir Okato --- zephyr/port/include/boot/mcuboot_config/mcuboot_config.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h b/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h index 1332494118..7ca6ee09f0 100644 --- a/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h +++ b/zephyr/port/include/boot/mcuboot_config/mcuboot_config.h @@ -40,6 +40,14 @@ #define MCUBOOT_BOOT_MAX_ALIGN DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size) #endif +#if defined(CONFIG_SECURE_FLASH_ENC_ENABLED) || (MCUBOOT_BOOT_MAX_ALIGN == 32) +#define MCUBOOT_FLASH_HAS_HW_ENCRYPTION 1 +#endif + +#ifdef MCUBOOT_FLASH_HAS_HW_ENCRYPTION +#define FLASH_AUX_WRITE_BUFFER_SIZE 0x100 +#endif + /* * Upgrade mode *