Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ K_SEM_DEFINE(boot_log_sem, 1, 1);
* !defined(ZEPHYR_LOG_MODE_MINIMAL)
*/

#if USE_PARTITION_MANAGER && CONFIG_FPROTECT
#include <fprotect.h>
#include <pm_config.h>
#endif
#include "nrf_protect.h"

#if CONFIG_MCUBOOT_NRF_CLEANUP_PERIPHERAL
#include <nrf_cleanup.h>
Expand Down Expand Up @@ -789,16 +786,6 @@ int main(void)

#if USE_PARTITION_MANAGER && CONFIG_FPROTECT

#ifdef PM_S1_ADDRESS
/* MCUBoot is stored in either S0 or S1, protect both */
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_S0_ADDRESS)
#define PROTECT_ADDR PM_S0_ADDRESS
#else
/* There is only one instance of MCUBoot */
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_MCUBOOT_ADDRESS)
#define PROTECT_ADDR PM_MCUBOOT_ADDRESS
#endif

rc = fprotect_area(PROTECT_ADDR, PROTECT_SIZE);

if (rc != 0) {
Expand Down
42 changes: 42 additions & 0 deletions boot/zephyr/nrf_protect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Copyright (c) 5020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef NRF_PROTECT_H__
#define NRF_PROTECT_H__

#if USE_PARTITION_MANAGER && CONFIG_FPROTECT

#include <pm_config.h>
#include <fprotect.h>

#ifdef PM_S1_ADDRESS
/* MCUBoot is stored in either S0 or S1, protect both */
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_S0_ADDRESS)
#define PROTECT_ADDR PM_S0_ADDRESS
#else
/* There is only one instance of MCUBoot */
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_MCUBOOT_ADDRESS)
#define PROTECT_ADDR PM_MCUBOOT_ADDRESS
#endif

#ifdef CONFIG_SOC_SERIES_NRF54LX
#if defined(CONFIG_FPROTECT_ALLOW_COMBINED_REGIONS)
#define REGION_SIZE_MAX (62 *1024)
#if (PROTECT_ADDR != 0)
#error "FPROTECT with combined regions can only be used to protect from address 0"
#endif
#else
#define REGION_SIZE_MAX (31 *1024)
#endif

#if (PROTECT_SIZE > REGION_SIZE_MAX)
#error "FPROTECT size too large"
#endif

#endif /* CONFIG_SOC_SERIES_NRF54LX */

#endif /* USE_PARTITION_MANAGER && CONFIG_FPROTECT */

#endif /* NRF_PROTECT_H__ */