Skip to content

Commit ac93ce8

Browse files
MarkusLassilanordicjm
authored andcommitted
sysbuild: Add AP-Protect settings
Add the following sysbuild settings which add corresponding Kconfig settings for all the images in the build: - SB_CONFIG_APPROTECT_USE_UICR - SB_CONFIG_APPROTECT_LOCK - SB_CONFIG_APPROTECT_USER_HANDLING - SB_CONFIG_SECURE_APPROTECT_USE_UICR - SB_CONFIG_SECURE_APPROTECT_LOCK - SB_CONFIG_SECURE_APPROTECT_USER_HANDLING Update AP-Protect documentation. Signed-off-by: Markus Lassila <[email protected]>
1 parent cbcfa64 commit ac93ce8

File tree

7 files changed

+218
-15
lines changed

7 files changed

+218
-15
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ Build and configuration system
6060

6161
* Added the ``SB_CONFIG_MCUBOOT_NRF53_MULTI_IMAGE_UPDATE`` sysbuild Kconfig option that enables updating the network core on the nRF5340 SoC from external flash.
6262

63+
* Added AP-Protect sysbuild Kconfig options to enable the corresponding AP-Protect Kconfig options for all images in the build:
64+
65+
* ``SB_CONFIG_APPROTECT_LOCK`` for the :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK` Kconfig option.
66+
* ``SB_CONFIG_APPROTECT_USER_HANDLING`` for the :kconfig:option:`CONFIG_NRF_APPROTECT_USER_HANDLING` Kconfig option.
67+
* ``SB_CONFIG_APPROTECT_USE_UICR`` for the :kconfig:option:`CONFIG_NRF_APPROTECT_USE_UICR` Kconfig option.
68+
* ``SB_CONFIG_SECURE_APPROTECT_LOCK`` for the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_LOCK` Kconfig option.
69+
* ``SB_CONFIG_SECURE_APPROTECT_USER_HANDLING`` for the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING` Kconfig option.
70+
* ``SB_CONFIG_SECURE_APPROTECT_USE_UICR`` for the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USE_UICR` Kconfig option.
71+
6372
* Removed the non-working support for configuring the NSIB signing key through the environmental or command line variable (``SB_SIGNING_KEY_FILE``) along with child image.
6473

6574
.. note::
@@ -1298,6 +1307,7 @@ Documentation
12981307
* The :ref:`dfu_tools_mcumgr_cli` page after it was removed from the Zephyr repository.
12991308
* The :ref:`ug_nrf54h20_suit_soc_binaries` page.
13001309
* The :ref:`ug_nrf54h20_suit_push` page documentating the SUIT push model-based update process.
1310+
* The :ref:`app_secure_approtect` section to the :ref:`app_approtect` page.
13011311

13021312
* Restructured the :ref:`app_bootloaders` documentation and combined the DFU and bootloader articles.
13031313
Additionally, created a new bootloader :ref:`bootloader_quick_start`.
@@ -1320,3 +1330,4 @@ Documentation
13201330
This table replaces the subpage that was previously describing these features in more detail and was duplicating information available in other sections.
13211331
* The :ref:`nrf_security_drivers_cracen` section with a reference to the :ref:`ug_nrf54l_cryptography` page.
13221332
* The :ref:`ug_tfm` page with the correct list of samples demonstrating TF-M.
1333+
* The :ref:`app_approtect_ncs` section on the :ref:`app_approtect` page with details on setting the Kconfig options and register values to enable AP-Protect.

doc/nrf/security/ap_protect.rst

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,43 +170,144 @@ Based on the available implementation types, you can configure the access port p
170170

171171
.. _app_approtect_ncs_lock:
172172

173-
Enabling AP-Protect with :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK`
174-
====================================================================
173+
Enabling software AP-Protect with :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK`
174+
=============================================================================
175+
176+
Setting the :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK` Kconfig option to ``y`` and compiling the firmware enables the software access protection mechanism for SoCs of the nRF53 Series and the SoC revisions of the nRF52 Series that feature the hardware and software type of AP-Protect.
177+
178+
Enabling the Kconfig option writes the debugger register in the ``SystemInit()`` function to lock the access port protection at every boot.
179+
In addition to this, the ``UICR.APPROTECT`` register should be written as instructed in :ref:`app_approtect_uicr_approtect`.
180+
181+
.. note::
182+
For multi-image builds, this Kconfig option needs to be set for the first image (usually a bootloader).
183+
Otherwise, the software AP-Protect will not be sufficient as the debugger can be attached to the device after the first image opens the software AP-Protect with the :kconfig:option:`CONFIG_NRF_APPROTECT_USE_UICR` Kconfig option, which is the default value.
184+
185+
When using sysbuild, set the ``SB_CONFIG_APPROTECT_LOCK`` sysbuild Kconfig option, which enables the :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK` Kconfig option for all images.
175186

176-
Setting the :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK` Kconfig option to ``y`` and compiling the firmware is enough to enable the access port protection mechanism for SoCs of the nRF53 Series and those SoCs of the nRF52 Series that feature the hardware and software type of AP-Protect.
177-
The access port protection configured in this way cannot be disabled without erasing the flash.
187+
.. important::
188+
On the nRF91x1 Series devices, the register setting related to the :kconfig:option:`CONFIG_NRF_APPROTECT_LOCK` Kconfig option does not persist in System ON IDLE mode.
189+
You must lock the ``UICR.APPROTECT`` register to enable the hardware AP-Protect mechanism as instructed in :ref:`app_approtect_uicr_approtect`.
178190

179191
.. _app_approtect_ncs_user_handling:
180192

181-
Enabling AP-Protect with :kconfig:option:`CONFIG_NRF_APPROTECT_USER_HANDLING`
182-
=============================================================================
193+
Enabling software AP-Protect with :kconfig:option:`CONFIG_NRF_APPROTECT_USER_HANDLING`
194+
======================================================================================
183195

184-
Setting the :kconfig:option:`CONFIG_NRF_APPROTECT_USER_HANDLING` Kconfig option to ``y`` and compiling the firmware allows you to handle the state of AP-Protect at a later stage.
196+
Setting the :kconfig:option:`CONFIG_NRF_APPROTECT_USER_HANDLING` Kconfig option to ``y`` and compiling the firmware allows you to handle the state of the software AP-Protect at a later stage.
185197
This option in fact does not touch the mechanism and keeps it closed.
186198

187199
You can use this option for example to implement the authenticated debug and lock.
188200
See the SoC or SiP hardware documentation for more information.
189201

202+
.. note::
203+
For multi-image builds, this Kconfig option has to be set for all images.
204+
The default value is to open the device if the ``UICR.APPROTECT`` register is not set.
205+
This allows the debugger to be attached to the device.
206+
207+
When using sysbuild, set the ``SB_CONFIG_APPROTECT_USER_HANDLING`` sysbuild Kconfig option, which enables the :kconfig:option:`CONFIG_NRF_APPROTECT_USER_HANDLING` Kconfig option for all images.
208+
190209
.. _app_approtect_ncs_use_uicr:
191210

192-
Enabling AP-Protect with :kconfig:option:`CONFIG_NRF_APPROTECT_USE_UICR`
193-
========================================================================
211+
Enabling software AP-Protect with :kconfig:option:`CONFIG_NRF_APPROTECT_USE_UICR`
212+
=================================================================================
194213

195-
Setting the :kconfig:option:`CONFIG_NRF_APPROTECT_USE_UICR` Kconfig option to ``y`` and compiling the firmware makes the AP-Protect disabled by default.
214+
Setting the :kconfig:option:`CONFIG_NRF_APPROTECT_USE_UICR` Kconfig option to ``y`` and compiling the firmware makes the software AP-Protect disabled by default.
196215
This is the default setting in the |NCS|.
197216

198217
You can start debugging the firmware without additional steps needed.
199218

200-
Once you are done debugging, run the following command to enable the access port protection:
219+
.. _app_approtect_uicr_approtect:
220+
221+
Enabling hardware AP-Protect by locking the ``UICR.APPROTECT`` register
222+
=======================================================================
223+
224+
For the devices that are in a production environment, it is highly recommended to lock the ``UICR.APPROTECT`` register to prevent unauthorized access to the device.
225+
If the access port protection is configured this way, it cannot be disabled without erasing the flash memory.
226+
227+
.. note::
228+
This is the only mechanism supported by the nRF52 Series and the nRF9160 devices that do not support both hardware and software AP-Protect.
229+
230+
To lock the ``UICR.APPROTECT`` register, complete the following steps:
201231

202232
.. code-block:: console
203233
204234
nrfjprog --rbp ALL
205235
206-
This command enables the AP-Protect and resets the device.
236+
This command enables the hardware AP-Protect (and Secure AP-Protect) and resets the device.
237+
238+
.. _app_secure_approtect:
239+
240+
Secure AP-Protect
241+
=================
242+
243+
With :ref:`Trusted Firmware-M (TF-M) <ug_tfm>` comes :ref:`security by separation <app_boards_spe_nspe>`, enabling a Secure Processing Environment (SPE) that is isolated from the Non-Secure Processing Environment (NSPE).
244+
TF-M is available for the nRF53 and nRF91 Series devices.
245+
246+
While AP-Protect blocks access to all CPU registers and memories, Secure AP-Protect limits the CPU access to the non-secure side only.
247+
This allows debugging of the NSPE, while the SPE debugging is blocked.
248+
249+
The following Kconfig options for enabling Secure AP-Protect are available for the nRF91x1 and nRF53 Series devices:
250+
251+
* :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_LOCK`
252+
* :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING`
253+
* :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USE_UICR`
254+
255+
In addition, you can enable hardware Secure AP-Protect by setting the ``UICR.SECUREAPPROTECT`` register as instructed in :ref:`app_secure_approtect_uicr_approtect`.
256+
257+
Enabling software Secure AP-Protect with :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_LOCK`
258+
-------------------------------------------------------------------------------------------
207259

208-
To enable only the Secure AP-Protect, run the following command:
260+
Setting the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_LOCK` Kconfig option to ``y`` and compiling the firmware enables the secure access protection mechanism for SoCs of the nRF53 Series.
261+
262+
Enabling this Kconfig option writes the secure debugger register in the ``SystemInit()`` function to lock the secure access port protection at every boot.
263+
In addition to this, the ``UICR.SECUREAPPROTECT`` register should be written as instructed in :ref:`app_secure_approtect_uicr_approtect`.
264+
265+
.. note::
266+
For multi-image builds, this Kconfig option needs to be set for the first image (usually a bootloader).
267+
Otherwise, the software Secure AP-Protect will not be sufficient as the debugger can be attached to the SPE after the first image opens the software Secure AP-Protect with the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USE_UICR` Kconfig option, which is the default value.
268+
269+
When using sysbuild, set the sysbuild Kconfig option ``SB_CONFIG_SECURE_APPROTECT_LOCK``, which enables the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_LOCK` Kconfig option for all images.
270+
271+
.. important::
272+
On the nRF91x1 Series devices, the register setting related to the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_LOCK` Kconfig option does not persist in System ON IDLE mode.
273+
You must lock the ``UICR.SECUREAPPROTECT`` register to enable the hardware Secure AP-Protect mechanism as instructed in :ref:`app_secure_approtect_uicr_approtect`.
274+
275+
Enabling software Secure AP-Protect with :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING`
276+
----------------------------------------------------------------------------------------------------
277+
278+
Setting the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING` Kconfig option to ``y`` and compiling the firmware allows you to handle the state of the software Secure AP-Protect at a later stage.
279+
This option does not touch the mechanism and keeps it closed.
280+
281+
You can for example use this option to implement an authenticated debug and lock of the SPE.
282+
See the SoC or SiP hardware documentation for more information.
283+
284+
.. note::
285+
For multi-image builds, this Kconfig option needs to be set for all images.
286+
The default value is to open the device if the ``UICR.SECUREAPPROTECT`` is not set.
287+
This allows the debugger to be attached to the device.
288+
289+
When using sysbuild, set the ``SB_CONFIG_SECURE_APPROTECT_USER_HANDLING`` sysbuild Kconfig option, which enables the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING` Kconfig option for all images.
290+
291+
Enabling software Secure AP-Protect with :kconfig:option:`CONFIG_SECURE_NRF_APPROTECT_USE_UICR`
292+
-----------------------------------------------------------------------------------------------
293+
294+
Setting the :kconfig:option:`CONFIG_NRF_SECURE_APPROTECT_USE_UICR` Kconfig option to ``y`` and compiling the firmware disables the software Secure AP-Protect mechanism by default.
295+
This is the default setting in the |NCS|.
296+
297+
You can start debugging the SPE without additional steps needed.
298+
299+
.. _app_secure_approtect_uicr_approtect:
300+
301+
Enabling hardware Secure AP-Protect by locking the ``UICR.SECUREAPPROTECT`` register
302+
------------------------------------------------------------------------------------
303+
304+
To enable only the hardware Secure AP-Protect mechanism, run the following command:
305+
306+
.. note::
307+
This is the only mechanism supported for the nRF9160 devices that do not have software support for Secure AP-Protect.
209308

210309
.. code-block:: console
211310
212311
nrfjprog --rbp SECURE
312+
313+
This command enables hardware Secure AP-Protect and resets the device.

samples/tfm/tfm_psa_template/prj.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ CONFIG_TFM_EXCEPTION_INFO_DUMP=y
1212

1313
CONFIG_TFM_PARTITION_INITIAL_ATTESTATION=y
1414
CONFIG_TFM_NRF_PROVISIONING=y
15-
CONFIG_NRF_APPROTECT_LOCK=y
16-
CONFIG_NRF_SECURE_APPROTECT_LOCK=y
1715

1816
CONFIG_SECURE_BOOT=y
1917
CONFIG_BUILD_S1_VARIANT=y

samples/tfm/tfm_psa_template/sysbuild.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ SB_CONFIG_SECURE_BOOT_APPCORE=y
99
SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
1010
SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y
1111
SB_CONFIG_MCUBOOT_UPDATEABLE_IMAGES=2
12+
SB_CONFIG_APPROTECT_LOCK=y
13+
SB_CONFIG_SECURE_APPROTECT_LOCK=y

sysbuild/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,30 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
490490
if(SB_CONFIG_SDP)
491491
include_sdp()
492492
endif()
493+
494+
foreach(config APPROTECT_USE_UICR APPROTECT_LOCK APPROTECT_USER_HANDLING
495+
SECURE_APPROTECT_USE_UICR SECURE_APPROTECT_USER_HANDLING SECURE_APPROTECT_LOCK)
496+
if(SB_CONFIG_${config})
497+
if(SB_CONFIG_BOOTLOADER_MCUBOOT)
498+
set_config_bool(mcuboot CONFIG_NRF_${config} y)
499+
endif()
500+
if(SB_CONFIG_SECURE_BOOT_APPCORE)
501+
set_config_bool(b0 CONFIG_NRF_${config} y)
502+
endif()
503+
set_config_bool(${DEFAULT_IMAGE} CONFIG_NRF_${config} y)
504+
endif()
505+
endforeach()
506+
if(SB_CONFIG_SUPPORT_NETCORE AND NOT SB_CONFIG_NETCORE_NONE)
507+
foreach(config APPROTECT_USE_UICR APPROTECT_LOCK APPROTECT_USER_HANDLING)
508+
if(SB_CONFIG_${config})
509+
if(SB_CONFIG_SECURE_BOOT_NETCORE)
510+
set_config_bool(b0n CONFIG_NRF_${config} y)
511+
endif()
512+
set_config_bool(${SB_CONFIG_NETCORE_IMAGE_NAME} CONFIG_NRF_${config} y)
513+
endif()
514+
endforeach()
515+
endif()
516+
493517
endfunction(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
494518

495519
function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_image_cmake)

sysbuild/Kconfig.approtect

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright (c) 2024 Nordic Semiconductor
2+
#
3+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
4+
5+
choice APPROTECT_HANDLING
6+
prompt "APPROTECT handling"
7+
depends on SOC_SERIES_NRF52X || SOC_SERIES_NRF53X || \
8+
SOC_SERIES_NRF91X
9+
default APPROTECT_NO_SYSBUILD
10+
help
11+
Specifies how the SystemInit() function of all the images should
12+
handle the APPROTECT mechanism.
13+
14+
config APPROTECT_USE_UICR
15+
bool "Use UICR"
16+
help
17+
Enable CONFIG_NRF_APPROTECT_USE_UICR in all images.
18+
19+
config APPROTECT_LOCK
20+
bool "Lock"
21+
help
22+
Enable CONFIG_NRF_APPROTECT_LOCK in all images.
23+
24+
config APPROTECT_USER_HANDLING
25+
bool "Allow user handling"
26+
depends on !SOC_SERIES_NRF52X
27+
help
28+
Enable CONFIG_NRF_APPROTECT_USER_HANDLING in all images.
29+
30+
config APPROTECT_NO_SYSBUILD
31+
bool "No sysbuild level configuration"
32+
help
33+
Approtect handling is not configured at sysbuild level.
34+
35+
endchoice
36+
37+
choice SECURE_APPROTECT_HANDLING
38+
prompt "Secure APPROTECT handling"
39+
depends on SOC_NRF5340_CPUAPP || SOC_SERIES_NRF91X
40+
default SECURE_APPROTECT_NO_SYSBUILD
41+
help
42+
Specifies how the SystemInit() function of all the images should
43+
handle the secure APPROTECT mechanism.
44+
45+
config SECURE_APPROTECT_USE_UICR
46+
bool "Use UICR"
47+
help
48+
Enable CONFIG_NRF_SECURE_APPROTECT_USE_UICR in all images.
49+
50+
config SECURE_APPROTECT_LOCK
51+
bool "Lock"
52+
help
53+
Enable CONFIG_NRF_SECURE_APPROTECT_LOCK in all images.
54+
55+
config SECURE_APPROTECT_USER_HANDLING
56+
bool "Allow user handling"
57+
depends on !SOC_SERIES_NRF52X
58+
help
59+
Enable CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING in all images.
60+
61+
config SECURE_APPROTECT_NO_SYSBUILD
62+
bool "No sysbuild level configuration"
63+
help
64+
Secure approtect handling is not configured at sysbuild level.
65+
66+
endchoice

sysbuild/Kconfig.sysbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ rsource "Kconfig.matter"
8080
rsource "Kconfig.wifi"
8181
rsource "Kconfig.suit"
8282
rsource "Kconfig.sdp"
83+
rsource "Kconfig.approtect"

0 commit comments

Comments
 (0)