Skip to content

Commit e62b292

Browse files
jonathannilsenrlubos
authored andcommitted
[nrf noup] boot: add support for MPCCONF based write protection
Add support for write protecting both the bootloader partition and the booted image partitions on nRF54H20 by configuring the global domain MPCs. The protection scheme uses a combination of UICR.MPCCONF, to protect the bootloader partition from boot, and ironside_se_mpcconf_write(), to protect the images that will be booted. Currently the only goal of the support is to write protect the MRAM partitions - in the future more advanced schemes could be added. Unlike the somewhat related and recently added PERIPHCONF support, the MPC configuration is hardcoded in MCUboot and is not currently possible to change via DFU. The feature depends on support added in IronSide SE v23.4.0+27. Signed-off-by: Jonathan Nilsen <jonathan.nilsen@nordicsemi.no>
1 parent f0d1d0c commit e62b292

7 files changed

Lines changed: 482 additions & 5 deletions

File tree

boot/zephyr/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,10 @@ endif()
822822
if(CONFIG_NCS_MCUBOOT_LOAD_PERIPHCONF)
823823
zephyr_sources(${BOOT_DIR}/zephyr/load_ironside_se_conf.c)
824824
endif()
825+
if(CONFIG_NCS_MCUBOOT_MPCCONF_STATIC_WRITE_PROTECTION)
826+
zephyr_sources(${BOOT_DIR}/zephyr/load_ironside_se_conf_mpc.c)
827+
endif()
828+
825829

826830
if(SYSBUILD AND CONFIG_PCD_APP)
827831
# Sysbuild requires details of the RAM flash device are stored to the cache of MCUboot so

boot/zephyr/include/load_ironside_se_conf.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
extern "C" {
1414
#endif
1515

16+
struct boot_rsp;
1617
struct boot_loader_state;
1718
struct image_header;
1819
struct flash_area;
@@ -30,6 +31,15 @@ int nrf_add_custom_tlv_data(struct boot_loader_state *state, int slot);
3031
/* Configure peripherals using parameters loaded from PERIPHCONF TLVs. */
3132
int nrf_load_periphconf(void);
3233

34+
/* Update information about which slot is being booted.
35+
* This determines which MPCCONF that is loaded by nrf_load_mpcconf(): active images are
36+
* write protected, and inactivate images are kept writable.
37+
*/
38+
int nrf_mpcconf_update_active_slot(const struct boot_rsp *rsp);
39+
40+
/* Configure global domain MPCs based on the images being booted. */
41+
int nrf_load_mpcconf(void);
42+
3343
#ifdef __cplusplus
3444
}
3545
#endif

boot/zephyr/load_ironside_se_conf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
#include "bootutil/bootutil_log.h"
99
#include "../bootutil/src/bootutil_priv.h"
1010
#include "flash_map_backend/flash_map_backend.h"
11+
#include <zephyr/devicetree.h>
1112
#include <zephyr/sys/math_extras.h>
13+
#include <zephyr/sys/util.h>
1214

1315
#include <ironside/se/api.h>
1416

1517
BOOT_LOG_MODULE_DECLARE(mcuboot);
1618

1719
#define PERIPHCONF_TLV_ID CONFIG_NCS_MCUBOOT_PERIPHCONF_TLV_ID
18-
19-
#define MAX_PERIPHCONFS CONFIG_NCS_MCUBOOT_LOAD_PERIPHCONF_MAX_BLOBS
20+
#define MAX_PERIPHCONFS CONFIG_NCS_MCUBOOT_LOAD_PERIPHCONF_MAX_BLOBS
2021

2122
/* To store parsed PERIPHCONF parameters between reading them from
2223
* the TLVs and calling the IronSide API.

0 commit comments

Comments
 (0)