Skip to content

Commit 3ea4ecd

Browse files
ahasztagtomchy
authored andcommitted
[nrf noup] Make fprotect area span only MCUBoot
nrf-squash! [nrf noup] treewide: add NCS partition manager support This commit changes the fprotect area size definition. This is necessary, as if TFM is used, tfm_storage is placed between mcuboot and the application. The old implementation led to the protected fprotect area including both MCUBoot and tfm_storage. This was unnecessary and in case of nRF54L15 (where the maximum FPROTECT area is small) not being able to use FPROTECT in case TF-M was used. Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
1 parent 9ba25b8 commit 3ea4ecd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

boot/zephyr/main.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,24 @@ int main(void)
903903

904904
#if USE_PARTITION_MANAGER && CONFIG_FPROTECT
905905

906+
/* Round up to next CONFIG_FPROTECT_BLOCK_SIZE boundary.
907+
* This is used for backwards compatibility, as some applications
908+
* use MCUBoot size unaligned to CONFIG_FPROTECT_BLOCK_SIZE.
909+
* However, even in these cases, the start of the next area
910+
* was still aligned to CONFIG_FPROTECT_BLOCK_SIZE and the
911+
* remaining space was filled by an EMPTY section by partition manager.
912+
*/
913+
#define FPROTECT_ALIGN_UP(x) \
914+
((((x) + CONFIG_FPROTECT_BLOCK_SIZE - 1) / CONFIG_FPROTECT_BLOCK_SIZE) * \
915+
CONFIG_FPROTECT_BLOCK_SIZE)
916+
906917
#ifdef PM_S1_ADDRESS
907918
/* MCUBoot is stored in either S0 or S1, protect both */
908919
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_S0_ADDRESS)
909920
#define PROTECT_ADDR PM_S0_ADDRESS
910921
#else
911922
/* There is only one instance of MCUBoot */
912-
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_MCUBOOT_ADDRESS)
923+
#define PROTECT_SIZE FPROTECT_ALIGN_UP(PM_MCUBOOT_SIZE)
913924
#define PROTECT_ADDR PM_MCUBOOT_ADDRESS
914925
#endif
915926

0 commit comments

Comments
 (0)