Skip to content

Commit 068afff

Browse files
drivers: kmu: soc: Add custom section for KMU
Add a custom section in the linker which should always be placed in the top of RAM. This will be used by the KMU to push keys into it. Since when you provision a key into the KMU you need to set specific a memory location for the PUSH operation we need to keep this memory location static across images/dfus. The linker script inclusion which places the KMU reserved buffer on the top of RAM doesn't work for non-XIP builds. The Zephyr linker script will firstly load the code for an non-XIP build in RAM and then include this KMU related linker script which results in an unpredictable placement of the KMU reserved area and a failed build. In order to support non-XIP builds the linker file is not included and the a DTS reserved-memory entry should be used. To limit the scope, the DTS reserved memory region is currently only supported for non-XIP builds. KMU is not supported upstream and so defined in sdk-nrf Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
1 parent c8a9d3e commit 068afff

4 files changed

Lines changed: 38 additions & 0 deletions

File tree

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
/drivers/flash/ @nrfconnect/ncs-co-drivers
283283
/drivers/gpio/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-ll-ursus
284284
/drivers/hw_cc3xx/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-aegir
285+
/drivers/kmu/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-aegir
285286
/drivers/mpsl/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-dragoon
286287
/drivers/mspi/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-ll-ursus
287288
/drivers/net/ @nrfconnect/ncs-co-drivers @doki-nordic

drivers/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ add_subdirectory(entropy)
88
add_subdirectory(flash)
99
add_subdirectory(gpio)
1010
add_subdirectory(hw_cc3xx)
11+
if(CONFIG_SOC_NRF7120)
12+
add_subdirectory_ifdef(CONFIG_PSA_NEED_CRACEN_KMU_DRIVER kmu)
13+
endif()
1114
if(NOT CONFIG_MPSL_FEM_ONLY)
1215
add_subdirectory(mpsl)
1316
endif()

drivers/kmu/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2026 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
#
4+
5+
dt_nodelabel(kmu_push_area_node NODELABEL nrf_kmu_reserved_push_area)
6+
7+
# We need a buffer in memory in a static location which can be used by
8+
# the KMU peripheral. The KMU has a static destination address,for nRF7120
9+
# this address is defined as 0x20000000, which is the first address in the SRAM.
10+
if(NOT CONFIG_BUILD_WITH_TFM AND CONFIG_PSA_NEED_CRACEN_KMU_DRIVER AND NOT kmu_push_area_node)
11+
# Exclamation mark is printable character with the lowest number in ASCII table.
12+
# We are sure that this file will be included first.
13+
zephyr_linker_sources(RAM_SECTIONS SORT_KEY ! kmu_push_area_section.ld)
14+
zephyr_linker_section(NAME ".nrf_kmu_reserved_push_area" ADDRESS "${RAM_ADDR}" GROUP RAM_REGION NOINIT)
15+
endif()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.
4+
SECTION_PROLOGUE(NRF_KMU_RESERVED_PUSH_SECTION,(NOLOAD) ,)
5+
{
6+
__nrf_kmu_reserved_push_area = .;
7+
*(.nrf_kmu_reserved_push_area)
8+
__nrf_kmu_reserved_push_area_end = .;
9+
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
10+
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 accidentally 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.")

0 commit comments

Comments
 (0)