Skip to content

Commit 4eff835

Browse files
committed
[nrf noup] platform: nordic_nrf: Add support for 54l
Add support for 54l Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no> Change-Id: I3574d73222dd23d202e5259a863f2e1b4b001739
1 parent 293f6cf commit 4eff835

16 files changed

Lines changed: 1089 additions & 99 deletions

File tree

platform/ext/target/nordic_nrf/common/core/CMakeLists.txt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ if (NOT NRF_BOARD_SELECTED)
1919
"Instead of '${TFM_PLATFORM}', choose e.g. '${hint}'.")
2020
endif()
2121

22+
# At the time of writing there is no systematic way to identify which
23+
# NVM technology is used by the SoC from the Kconfig, so we just
24+
# hardcode this information here instead.
25+
if(PSA_API_TEST_TARGET STREQUAL nrf54l15)
26+
set(HAS_RRAMC 1)
27+
else()
28+
set(HAS_NVMC 1)
29+
endif()
30+
2231
#========================= Platform dependencies ===============================#
2332

2433
include(hal_nordic.cmake)
@@ -63,10 +72,25 @@ target_include_directories(platform_s
6372
services/include
6473
)
6574

75+
set(nvm_sources
76+
$<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_drivers/Driver_Flash.c>
77+
)
78+
79+
if(HAS_RRAMC)
80+
list(APPEND nvm_sources
81+
${HAL_NORDIC_PATH}/nrfx/drivers/src/nrfx_rramc.c
82+
)
83+
elseif(HAS_NVMC)
84+
list(APPEND nvm_sources
85+
${HAL_NORDIC_PATH}/nrfx/drivers/src/nrfx_nvmc.c
86+
)
87+
else()
88+
message(FATAL_ERROR "Unexpected device")
89+
endif()
90+
6691
target_sources(platform_s
67-
PRIVATE
68-
cmsis_drivers/Driver_Flash.c
69-
${HAL_NORDIC_PATH}/nrfx/drivers/src/nrfx_nvmc.c
92+
PRIVATE
93+
${nvm_sources}
7094
nrfx_glue.c
7195
native_drivers/mpu_armv8m_drv.c
7296
native_drivers/spu.c
@@ -127,10 +151,9 @@ target_compile_definitions(platform_s
127151
if(BL2)
128152
target_sources(platform_bl2
129153
PRIVATE
130-
cmsis_drivers/Driver_Flash.c
154+
${nvm_sources}
131155
cmsis_drivers/Driver_USART.c
132156
${HAL_NORDIC_PATH}/nrfx/drivers/src/nrfx_uarte.c
133-
${HAL_NORDIC_PATH}/nrfx/drivers/src/nrfx_nvmc.c
134157
nrfx_glue.c
135158
)
136159
target_sources(bl2

platform/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_Flash.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@
2121
#include <RTE_Device.h>
2222
#include <flash_layout.h>
2323
#include <string.h>
24+
25+
#include <nrf.h>
26+
27+
#if defined(NRF_NVMC_S)
2428
#include <nrfx_nvmc.h>
29+
#elif defined(NRF_RRAMC_S)
30+
#include <nrfx_rramc.h>
31+
#else
32+
#error "Unrecognized platform"
33+
#endif
2534

2635
#ifndef ARG_UNUSED
2736
#define ARG_UNUSED(arg) (void)arg
@@ -92,7 +101,30 @@ static int32_t ARM_Flash_Initialize(ARM_Flash_SignalEvent_t cb_event)
92101
return ARM_DRIVER_ERROR;
93102
}
94103

104+
#ifdef NRF_RRAMC_S
105+
/* Disable buffering until it's security impact is understood */
106+
uint8_t write_buff_size = 0;
107+
108+
/* Don't use an event handler until it's understood whether we
109+
* want it or not */
110+
nrfx_rramc_evt_handler_t handler = NULL;
111+
112+
nrfx_rramc_config_t p_config = NRFX_RRAMC_DEFAULT_CONFIG(write_buff_size);
113+
114+
nrfx_err_t err_code = nrfx_rramc_init(&p_config, handler);
115+
116+
switch(err_code){
117+
case NRFX_SUCCESS:
118+
case NRFX_ERROR_ALREADY:
119+
// TF-M appears to be invoking ARM_FLASH_Initialize multiple
120+
// times, but this is of no concern to the driver.
121+
return ARM_DRIVER_OK;
122+
default:
123+
return ARM_DRIVER_ERROR;
124+
}
125+
#else
95126
return ARM_DRIVER_OK;
127+
#endif
96128
}
97129

98130
static int32_t ARM_Flash_ReadData(uint32_t addr, void *data, uint32_t cnt)
@@ -124,18 +156,32 @@ static int32_t ARM_Flash_ProgramData(uint32_t addr, const void *data,
124156
return ARM_DRIVER_ERROR_PARAMETER;
125157
}
126158

159+
#ifdef NRF_NVMC_S
127160
nrfx_nvmc_words_write(addr, data, cnt);
161+
#else
162+
nrfx_rramc_words_write(addr, data, cnt);
163+
#endif
128164

129165
/* Conversion between bytes and data items */
130166
return cnt;
131167
}
132168

133169
static int32_t ARM_Flash_EraseSector(uint32_t addr)
134170
{
171+
#ifdef NRF_NVMC_S
135172
nrfx_err_t err_code = nrfx_nvmc_page_erase(addr);
173+
136174
if (err_code != NRFX_SUCCESS) {
137175
return ARM_DRIVER_ERROR_PARAMETER;
138176
}
177+
#else
178+
for (uint32_t *erase_word_ptr = (uint32_t *)addr;
179+
(uint32_t)erase_word_ptr < addr + FLASH_AREA_IMAGE_SECTOR_SIZE; erase_word_ptr++) {
180+
if(*erase_word_ptr != 0xFFFFFFFFU) {
181+
nrfx_rramc_word_write((uint32_t)erase_word_ptr, 0xFFFFFFFFU);
182+
}
183+
}
184+
#endif
139185

140186
return ARM_DRIVER_OK;
141187
}

platform/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_USART.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#define ARM_USART_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2, 2)
4141

42-
#if RTE_USART0 || RTE_USART1 || RTE_USART2 || RTE_USART3
42+
#if RTE_USART0 || RTE_USART1 || RTE_USART2 || RTE_USART3 || RTE_USART22
4343

4444
#define PSEL_DISCONNECTED 0xFFFFFFFFUL
4545

@@ -438,4 +438,9 @@ DRIVER_USART(2);
438438
DRIVER_USART(3);
439439
#endif
440440

441-
#endif /* RTE_USART0 || RTE_USART1 || RTE_USART2 || RTE_USART3 */
441+
// TODO: NCSDK-25009: Support choosing an instance for TF-M
442+
#if RTE_USART22
443+
DRIVER_USART(22);
444+
#endif
445+
446+
#endif /* RTE_USART0 || RTE_USART1 || RTE_USART2 || RTE_USART3 || RTE_USART22 */
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef NRFX_CONFIG_NRF54L15_APPLICATION_H__
8+
#define NRFX_CONFIG_NRF54L15_APPLICATION_H__
9+
10+
#ifndef NRFX_CONFIG_H__
11+
#error "This file should not be included directly. Include nrfx_config.h instead."
12+
#endif
13+
14+
/**
15+
* @brief NRFX_DEFAULT_IRQ_PRIORITY
16+
*
17+
* Integer value. Minimum: 0 Maximum: 7
18+
*/
19+
#ifndef NRFX_DEFAULT_IRQ_PRIORITY
20+
#define NRFX_DEFAULT_IRQ_PRIORITY 7
21+
#endif
22+
23+
/**
24+
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
25+
*
26+
* Integer value. Minimum: 0 Maximum: 7
27+
*/
28+
#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
29+
#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY NRFX_DEFAULT_IRQ_PRIORITY
30+
#endif
31+
32+
/**
33+
* @brief NRFX_RRAMC_ENABLED
34+
*
35+
* Boolean. Accepted values: 0 and 1.
36+
*/
37+
#ifndef NRFX_RRAMC_ENABLED
38+
#define NRFX_RRAMC_ENABLED 0
39+
#endif
40+
41+
/**
42+
* @brief NRFX_RRAMC_DEFAULT_CONFIG_IRQ_PRIORITY
43+
*
44+
* Integer value. Minimum: 0. Maximum: 7.
45+
*/
46+
#ifndef NRFX_RRAMC_DEFAULT_CONFIG_IRQ_PRIORITY
47+
#define NRFX_RRAMC_DEFAULT_CONFIG_IRQ_PRIORITY NRFX_DEFAULT_IRQ_PRIORITY
48+
#endif
49+
50+
/**
51+
* @brief NRFX_RRAMC_CONFIG_LOG_ENABLED
52+
*
53+
* Boolean. Accepted values: 0 and 1.
54+
*/
55+
#ifndef NRFX_RRAMC_CONFIG_LOG_ENABLED
56+
#define NRFX_RRAMC_CONFIG_LOG_ENABLED 0
57+
#endif
58+
59+
/**
60+
* @brief NRFX_RRAMC_CONFIG_LOG_LEVEL
61+
*
62+
* Integer value.
63+
* Supported values:
64+
* - Off = 0
65+
* - Error = 1
66+
* - Warning = 2
67+
* - Info = 3
68+
* - Debug = 4
69+
*/
70+
#ifndef NRFX_RRAMC_CONFIG_LOG_LEVEL
71+
#define NRFX_RRAMC_CONFIG_LOG_LEVEL 3
72+
#endif
73+
74+
#endif // NRFX_CONFIG_NRF54L15_APPLICATION_H__

platform/ext/target/nordic_nrf/common/core/faults.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ void SPU_Handler(void)
2222
/* Clear SPU interrupt flag and pending SPU IRQ */
2323
spu_clear_events();
2424

25+
#ifdef SPU_IRQn
2526
NVIC_ClearPendingIRQ(SPU_IRQn);
27+
#else
28+
// TODO: NCSDK-25011: Support nrf54l
29+
#endif
2630

2731
tfm_core_panic();
2832
}

0 commit comments

Comments
 (0)