Skip to content

Commit 879e8c0

Browse files
travis3630nordicjm
authored andcommitted
nrf_security: add nrf7120 to CRACEN driver
Add nrf7120 for CRACEN core drivers Signed-off-by: Travis Lam <[email protected]>
1 parent e521a26 commit 879e8c0

File tree

8 files changed

+85
-28
lines changed

8 files changed

+85
-28
lines changed

dts/common/nordic/nrf7120_enga.dtsi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@
7979
#size-cells = <1>;
8080
ranges;
8181

82-
nordic_reserved: memory@200ff000{
82+
nordic_reserved: memory@200fe000{
8383
#address-cells = <1>;
8484
#size-cells = <1>;
8585
compatible = "mmio-sram";
86-
reg = <0x200ff000 0xf00>;
87-
ranges = <0x0 0x200ff000 0xf00>;
86+
reg = <0x200fe000 0x1000>;
87+
ranges = <0x0 0x200fe000 0x1000>;
8888
};
8989

90-
nrf_kmu_reserved_push_area: memory@200fff00{
90+
nrf_kmu_cracen_exchange_area: memory@200ff000{
9191
#address-cells = <1>;
9292
#size-cells = <1>;
93-
reg = <0x200fff00 0x0100>;
93+
reg = <0x200ff000 0x1000>;
9494
compatible = "zephyr,memory-region", "mmio-sram";
95-
zephyr,memory-region = "NRF_KMU_RESERVED_PUSH";
95+
zephyr,memory-region = "NRF_KMU_CRACEN_EXCHANGE";
9696
};
9797

9898
nrf_mpc_region: memory@50041000 {

lib/hw_unique_key/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ config HW_UNIQUE_KEY_LOAD
1818
depends on HAS_HW_NRF_CC310
1919
depends on NRF_CC3XX_PLATFORM
2020
select FPROTECT
21-
imply NRFX_NVMC if !SOC_SERIES_NRF54LX
21+
imply NRFX_NVMC if !CRACEN_HW_PRESENT
2222
help
2323
Use this on devices with no KMU. Enable this in the immutable
2424
bootloader to load the HUK from the allocated flash area
@@ -46,7 +46,7 @@ config HW_UNIQUE_KEY
4646
select PSA_WANT_ALG_GCM if CRACEN_HW_PRESENT
4747
select PSA_NEED_CRACEN_KMU_DRIVER if CRACEN_HW_PRESENT
4848
select FPROTECT if HAS_HW_NRF_ACL
49-
imply NRFX_NVMC if !SOC_SERIES_NRF54LX
49+
imply NRFX_NVMC if !CRACEN_HW_PRESENT
5050
default y if BUILD_WITH_TFM
5151
help
5252
This option will load the Hardware Unique Key (HUK) in the KDR
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
#define NRF_KMU_PUSH_BASE_ADDRESS 0x200FFF00
2-
1+
# This section must be loaded first of all the
2+
# custom sections because we want it to be placed
3+
# at the top address of RAM.
34
SECTION_PROLOGUE(NRF_KMU_RESERVED_PUSH_SECTION,(NOLOAD) ,)
45
{
56
__nrf_kmu_reserved_push_area = .;
67
*(.nrf_kmu_reserved_push_area)
78
__nrf_kmu_reserved_push_area_end = .;
8-
} GROUP_NOLOAD_LINK_IN(NRF_KMU_RESERVED_PUSH, NRF_KMU_RESERVED_PUSH)
9+
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
910

10-
/* Check that the section is correctly placed at 0x200F_FF00 */
11-
ASSERT(__nrf_kmu_reserved_push_area == NRF_KMU_PUSH_BASE_ADDRESS, \
12-
"Error: The section NRF_KMU_RESERVED_PUSH_SECTION needs to be \
13-
placed at 0x200F_FF00 but it is not, please edit the\
14-
device tree to define section NRF_KMU_RESERVED_PUSH at 0x200F_FF00 \
15-
the to RAM address.")
11+
# It doesn't seem to be possible to enforce placing a section
12+
# at a specific address in memory using the Zephyr SECTION macros.
13+
# So this assert is necessary to avoid accidentatly moving this
14+
# section to a different address.
15+
ASSERT(__nrf_kmu_reserved_push_area == RAM_ADDR, "Error: \
16+
The section NRF_KMU_RESERVED_PUSH_SECTION needs to be \
17+
placed on the top RAM address but it is not, please edit \
18+
your linker scripts to make sure that it is placed on \
19+
the top RAM address.")

subsys/nrf_security/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if NRF_SECURITY
6060

6161
config MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
6262
bool
63-
default y if SOC_SERIES_NRF54LX && PSA_CRYPTO_DRIVER_CRACEN
63+
default y if CRACEN_HW_PRESENT && PSA_CRYPTO_DRIVER_CRACEN
6464
default y if PSA_WANT_PLATFORM_KEYS
6565
help
6666
Promptless option used to control if the PSA Crypto core should have support for builtin keys or not.

subsys/nrf_security/include/nrf_security_api_structure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* with hardware acceleration or alternative implementations. The supported drivers include:
2222
* - Arm CryptoCell cc3xx (hardware acceleration for nRF52840, nRF91 Series, and nRF5340)
2323
* - nrf_oberon (optimized cryptographic algorithms)
24-
* - CRACEN (hardware acceleration for nRF54L Series)
24+
* - CRACEN (hardware acceleration for nRF54L and nRF71 Series)
2525
*
2626
* For detailed documentation on these drivers, see the nRF Connect SDK documentation:
2727
* https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/security/nrf_security/index.html

subsys/nrf_security/src/drivers/cracen/Kconfig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
#
66

77
config CRACEN_HW_PRESENT
8-
def_bool SOC_SERIES_NRF54LX || SOC_SERIES_NRF92X
8+
def_bool SOC_SERIES_NRF54LX || SOC_SERIES_NRF92X || SOC_SERIES_NRF71X
99

1010
config CRACEN_HW_VERSION_BASE
1111
def_bool SOC_SERIES_NRF54HX || SOC_NRF54L15 || SOC_NRF54L10 || SOC_NRF54L05
1212

1313
config CRACEN_HW_VERSION_LITE
14-
def_bool SOC_NRF54LM20A || SOC_NRF54LV10A
14+
def_bool SOC_NRF54LM20A || SOC_NRF54LV10A || SOC_NRF7120_ENGA
1515

1616
config CRACEN_NEED_MULTIPART_WORKAROUNDS
1717
def_bool SOC_NRF54LM20A
1818

1919
config CRACEN_NEED_IKG_INTERRUPT_WORKAROUND
20-
def_bool SOC_NRF54LM20A || SOC_NRF54LV10A
20+
def_bool SOC_NRF54LM20A || SOC_NRF54LV10A || SOC_NRF7120_ENGA
2121

2222
# Configure CRACEN_LOG_LEVEL
2323
module = CRACEN
@@ -37,8 +37,9 @@ config CRACEN_LOAD_MICROCODE
3737

3838
config CRACEN_LIB_KMU
3939
bool "CRACEN KMU library"
40-
depends on SOC_SERIES_NRF54LX
41-
select NRFX_RRAMC if !BUILD_WITH_TFM
40+
depends on CRACEN_HW_PRESENT
41+
select NRFX_RRAMC if !BUILD_WITH_TFM && SOC_SERIES_NRF54LX
42+
select NRFX_MRAMC if !BUILD_WITH_TFM && SOC_SERIES_NRF71X
4243
default y
4344
help
4445
The CRACEN KMU library.

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/lib_kmu.c

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212

1313
#include <nrf.h>
1414

15+
#if defined(CONFIG_SOC_SERIES_NRF54LX)
1516
#include <nrfx_rramc.h>
17+
#elif defined(CONFIG_SOC_SERIES_NRF71X)
18+
#include <nrfx_mramc.h>
19+
20+
#define REG_MRAMC_CONFIGNVR_PAGE_3 (uint32_t *)((uint32_t)NRF_MRAMC + 0x58C)
21+
#define MRAM_SICR_ENABLE_WRITE_ERASE 0xFFF00022
22+
#define MRAM_SICR_DISABLE_WRITE_ERASE 0x0
23+
#endif
1624

1725
#include <cracen/lib_kmu.h>
1826

@@ -34,6 +42,35 @@ void lib_kmu_clear_all_events(void)
3442
#endif
3543
}
3644

45+
#if defined(CONFIG_SOC_SERIES_NRF71X)
46+
static void mram_enable_kmu_write_erase_to_sicr(bool permission)
47+
{
48+
/* CONFIGNVR.PAGE[3] contain the SICR info block
49+
* setting info block write and erase permission to
50+
* allow KMU to write to SICR in MRAM.
51+
*
52+
* Register not available on hal_nordic this version, need
53+
* to update this when it is available, WZN-5799.
54+
*/
55+
static nrf_mramc_readynext_timeout_t prev_readynext_timeout;
56+
57+
if (permission) {
58+
/* Save previous readynext timeout value */
59+
nrf_mramc_readynext_timeout_get(NRF_MRAMC, &prev_readynext_timeout);
60+
nrf_mramc_readynext_timeout_t readynext_timeout = {
61+
.value = NRF_MRAMC_READYNEXTTIMEOUT_DEFAULT,
62+
.direct_write = true,
63+
};
64+
nrf_mramc_readynext_timeout_set(NRF_MRAMC, &readynext_timeout);
65+
} else {
66+
nrf_mramc_readynext_timeout_set(NRF_MRAMC, &prev_readynext_timeout);
67+
}
68+
69+
*REG_MRAMC_CONFIGNVR_PAGE_3 = permission ?
70+
MRAM_SICR_ENABLE_WRITE_ERASE : MRAM_SICR_DISABLE_WRITE_ERASE;
71+
}
72+
#endif
73+
3774
static int trigger_task_and_wait_for_event_or_error(volatile uint32_t *task,
3875
volatile uint32_t *event)
3976
{
@@ -80,7 +117,7 @@ int lib_kmu_provision_slot(int slot_id, struct kmu_src *kmu_src)
80117
__ASSERT(IS_PTR_ALIGNED_BYTES(kmu_src->dest, 16), "DEST misaligned");
81118

82119
int result = 1;
83-
120+
#if defined(CONFIG_SOC_SERIES_NRF54LX)
84121
#if defined(__NRF_TFM__)
85122
nrf_rramc_config_t rramc_config;
86123

@@ -92,19 +129,28 @@ int lib_kmu_provision_slot(int slot_id, struct kmu_src *kmu_src)
92129
#else
93130
nrfx_rramc_write_enable_set(true, 0);
94131
#endif
132+
#elif defined(CONFIG_SOC_SERIES_NRF71X)
133+
/* Enable write and erase from KMU to SICR in MRAM */
134+
mram_enable_kmu_write_erase_to_sicr(true);
135+
#endif
95136

96137
NRF_KMU_S->KEYSLOT = slot_id;
97138
NRF_KMU_S->SRC = (uint32_t)kmu_src;
98139

99140
result = trigger_task_and_wait_for_event_or_error(&(NRF_KMU_S->TASKS_PROVISION),
100141
&(NRF_KMU_S->EVENTS_PROVISIONED));
101142

143+
#if defined(CONFIG_SOC_SERIES_NRF54LX)
102144
#if defined(__NRF_TFM__)
103145
rramc_config.write_buff_size = orig_write_buf_size;
104146
nrf_rramc_config_set(NRF_RRAMC_S, &rramc_config);
105147
#else
106148
nrfx_rramc_write_enable_set(false, 0);
107149
#endif
150+
#elif defined(CONFIG_SOC_SERIES_NRF71X)
151+
/* Disable write and erase from KMU to SICR in MRAM */
152+
mram_enable_kmu_write_erase_to_sicr(false);
153+
#endif
108154

109155
return result;
110156
}
@@ -145,17 +191,23 @@ int lib_kmu_block_slot_range(int slot_id, unsigned int slot_count)
145191

146192
int lib_kmu_revoke_slot(int slot_id)
147193
{
148-
#if !defined(__NRF_TFM__)
194+
#if !defined(__NRF_TFM__) && defined(CONFIG_SOC_SERIES_NRF54LX)
149195
nrfx_rramc_write_enable_set(true, 0);
196+
#elif defined(CONFIG_SOC_SERIES_NRF71X)
197+
/* Enable write and erase from KMU to SICR in MRAM */
198+
mram_enable_kmu_write_erase_to_sicr(true);
150199
#endif
151200

152201
NRF_KMU_S->KEYSLOT = slot_id;
153202

154203
int result = trigger_task_and_wait_for_event_or_error(&(NRF_KMU_S->TASKS_REVOKE),
155204
&(NRF_KMU_S->EVENTS_REVOKED));
156205

157-
#if !defined(__NRF_TFM__)
206+
#if !defined(__NRF_TFM__) && defined(CONFIG_SOC_SERIES_NRF54LX)
158207
nrfx_rramc_write_enable_set(false, 0);
208+
#elif defined(CONFIG_SOC_SERIES_NRF71X)
209+
/* Disable write and erase from KMU to SICR in MRAM */
210+
mram_enable_kmu_write_erase_to_sicr(false);
159211
#endif
160212

161213
return result;

subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <security/cracen.h>
2424
#include <nrf_security_mutexes.h>
2525

26-
#if CONFIG_CRACEN_HW_VERSION_LITE && !CONFIG_SOC_NRF54LM20A && !CONFIG_SOC_NRF54LV10A
26+
#if defined(CONFIG_CRACEN_HW_VERSION_LITE) && !defined(CONFIG_CRACEN_NEED_IKG_INTERRUPT_WORKAROUND)
2727
#error Check to see if the current board needs the IKG-PKE interrupt workaround or not, \
2828
then update this error
2929
#endif

0 commit comments

Comments
 (0)