Skip to content

Commit c80c5c6

Browse files
committed
platform: add nrf7120 target support
Add target device api for nrf7120. Signed-off-by: Travis Lam <[email protected]>
1 parent a155013 commit c80c5c6

File tree

7 files changed

+914
-1
lines changed

7 files changed

+914
-1
lines changed

api-tests/platform/drivers/watchdog/nrf/nrf_wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define NRF_WDT31_NS ((struct NRF_WDT_Type *)0x40109000)
3636
#define NRF_WDT0_NS ((struct NRF_WDT_Type *)0x40018000)
3737

38-
#ifdef NRF54L15_XXAA
38+
#if defined(NRF54L15_XXAA) || defined(NRF7120_ENGA_XXAA)
3939
#define PSA_TEST_WDT_INSTANCE NRF_WDT31_NS
4040
#else
4141
#define PSA_TEST_WDT_INSTANCE NRF_WDT0_NS
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/** @file
2+
* Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
#ifndef _PAL_ATTESTATION_CONFIG_H_
19+
#define _PAL_ATTESTATION_CONFIG_H_
20+
21+
#define COSE_ALGORITHM_ES256 -7
22+
#define COSE_ALG_SHA256_PROPRIETARY -72000
23+
24+
#define USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB
25+
26+
#define COSE_SIG_CONTEXT_STRING_SIGNATURE1 "Signature1"
27+
28+
/* Private value. Intentionally not documented for Doxygen.
29+
* This is the size allocated for the encoded protected headers. It
30+
* needs to be big enough for make_protected_header() to succeed. It
31+
* currently sized for one header with an algorithm ID up to 32 bits
32+
* long -- one byte for the wrapping map, one byte for the label, 5
33+
* bytes for the ID. If this is made accidentially too small, QCBOR will
34+
* only return an error, and not overrun any buffers.
35+
*
36+
* 9 extra bytes are added, rounding it up to 16 total, in case some
37+
* other protected header is to be added.
38+
*/
39+
#define T_COSE_SIGN1_MAX_PROT_HEADER (1+1+5+9)
40+
41+
/**
42+
* This is the size of the first part of the CBOR encoded TBS
43+
* bytes. It is around 20 bytes. See create_tbs_hash().
44+
*/
45+
#define T_COSE_SIZE_OF_TBS ( \
46+
1 + /* For opening the array */ \
47+
sizeof(COSE_SIG_CONTEXT_STRING_SIGNATURE1) + /* "Signature1" */ \
48+
2 + /* Overhead for encoding string */ \
49+
T_COSE_SIGN1_MAX_PROT_HEADER + /* entire protected headers */ \
50+
3 * (/* 3 NULL bstrs for fields not used */ \
51+
1 /* size of a NULL bstr */ \
52+
) \
53+
)
54+
55+
#define NULL_USEFUL_BUF_C NULLUsefulBufC
56+
57+
#define ATTEST_PUBLIC_KEY_SLOT 4
58+
#define ECC_CURVE_SECP256R1_PULBIC_KEY_LENGTH (1 + 2 * PSA_BITS_TO_BYTES(256))
59+
60+
typedef struct {
61+
uint8_t *pubx_key;
62+
size_t pubx_key_size;
63+
uint8_t *puby_key;
64+
size_t puby_key_size;
65+
} ecc_key_t;
66+
67+
struct ecc_public_key_t {
68+
const uint8_t a;
69+
uint8_t public_key[]; /* X-coordinate || Y-coordinate */
70+
};
71+
72+
static const struct ecc_public_key_t attest_public_key = {
73+
/* Constant byte */
74+
0x04,
75+
/* X-coordinate */
76+
{0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6,
77+
0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A,
78+
0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D,
79+
0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F,
80+
/* Y-coordinate */
81+
0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF,
82+
0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D,
83+
0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08,
84+
0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64},
85+
};
86+
87+
static const uint8_t initial_attestation_public_x_key[] = {
88+
0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6,
89+
0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A,
90+
0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D,
91+
0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F
92+
};
93+
94+
static const uint8_t initial_attestation_public_y_key[] = {
95+
0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF,
96+
0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D,
97+
0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08,
98+
0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64
99+
};
100+
101+
/* Initialize the structure with given public key */
102+
static const ecc_key_t attest_key = {
103+
(uint8_t *)initial_attestation_public_x_key,
104+
sizeof(initial_attestation_public_x_key),
105+
(uint8_t *)initial_attestation_public_y_key,
106+
sizeof(initial_attestation_public_y_key)
107+
};
108+
109+
#endif /* _PAL_ATTESTATION_CONFIG_H_ */
110+
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/** @file
2+
* Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
#ifndef _PAL_CONFIG_H_
19+
#define _PAL_CONFIG_H_
20+
21+
#include "pal_crypto_config.h"
22+
#include "pal_attestation_config.h"
23+
#include "pal_storage_config.h"
24+
25+
/*========================== PLATFORM CONFIGURATIONS START ==========================*/
26+
27+
// UART device info
28+
#define UART_NUM 20
29+
#define UART_20_BASE 0x0
30+
31+
/*
32+
* The nRF instance that is appropriate to use on 71 non-secure is
33+
* NRF_WDT31, but 31 breaks the test infrastructure so we pretend we are
34+
* using the non-existent instance 4 instead.
35+
*/
36+
37+
/* Watchdog device info */
38+
#define WATCHDOG_NUM 4
39+
#define WATCHDOG_4_BASE 0x40109000
40+
#define WATCHDOG_4_NUM_OF_TICK_PER_MICRO_SEC 0x1
41+
42+
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW 500000000
43+
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_MEDIUM 500000000
44+
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_HIGH 500000000
45+
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_CRYPTO 500000000
46+
47+
/* Range of 1KB Non-volatile memory to preserve data over reset. Ex, NVRAM and FLASH */
48+
#define NVMEM_NUM 1
49+
50+
#define NVMEM_0_START 0x0
51+
#define NVMEM_0_END 0x3FF
52+
53+
/*========================== PLATFORM CONFIGURATIONS END ============================*/
54+
55+
/* Define PSA test suite dependent macros for non-cmake build */
56+
#if !defined(PSA_CMAKE_BUILD)
57+
58+
/* Print verbosity = TEST */
59+
#define VERBOSITY 3
60+
61+
/* NSPE or SPE VAL build? */
62+
#define VAL_NSPE_BUILD
63+
64+
/* NSPE or SPE TEST build? */
65+
#define NONSECURE_TEST_BUILD
66+
67+
/* If not defined, skip watchdog programming */
68+
#define WATCHDOG_AVAILABLE
69+
70+
/* Are Dynamic memory APIs available to secure partition? */
71+
#define SP_HEAP_MEM_SUPP
72+
73+
/* PSA Isolation level supported by platform */
74+
#define PLATFORM_PSA_ISOLATION_LEVEL 3
75+
#endif /* PSA_CMAKE_BUILD */
76+
77+
/* Version of crypto spec used in attestation */
78+
#define CRYPTO_VERSION_BETA3
79+
80+
/* Use hardcoded public key */
81+
#define PLATFORM_OVERRIDE_ATTEST_PK
82+
83+
/* Enable custom printing for Non-secure side */
84+
#define BESPOKE_PRINT_NS
85+
86+
/* UART base address assigned */
87+
#define PLATFORM_UART_BASE UART_20_BASE
88+
89+
/* Watchdog device configurations assigned */
90+
#define PLATFORM_WD_BASE WATCHDOG_4_BASE
91+
#define PLATFORM_WD_NUM_OF_TICK_PER_MICRO_SEC WATCHDOG_4_NUM_OF_TICK_PER_MICRO_SEC
92+
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_LOW WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW
93+
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_MEDIUM WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW
94+
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_HIGH WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW
95+
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_CRYPTO WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_CRYPTO
96+
97+
/* Non-volatile memory base address assigned */
98+
#define PLATFORM_NVM_BASE NVMEM_0_START
99+
100+
/*
101+
* Include of PSA defined Header files
102+
*/
103+
#ifdef IPC
104+
/* psa/client.h: Contains the PSA Client API elements */
105+
#include "psa/client.h"
106+
107+
/*
108+
* psa_manifest/sid.h: Macro definitions derived from manifest files that map from RoT Service
109+
* names to Service IDs (SIDs). Partition manifest parse build tool must provide the implementation
110+
* of this file.
111+
*/
112+
#include "psa_manifest/sid.h"
113+
114+
/*
115+
* psa_manifest/pid.h: Secure Partition IDs
116+
* Macro definitions that map from Secure Partition names to Secure Partition IDs.
117+
* Partition manifest parse build tool must provide the implementation of this file.
118+
*/
119+
#include "psa_manifest/pid.h"
120+
#endif
121+
122+
#ifdef CRYPTO
123+
/* psa/crypto.h: Contains the PSA Crypto API elements */
124+
#include "psa/crypto.h"
125+
#endif
126+
127+
#if defined(INTERNAL_TRUSTED_STORAGE) || defined(STORAGE)
128+
/* psa/internal_trusted_storage.h: Contains the PSA ITS API elements */
129+
#include "psa/internal_trusted_storage.h"
130+
#endif
131+
132+
#if defined(PROTECTED_STORAGE) || defined(STORAGE)
133+
/* psa/protected_storage.h: Contains the PSA PS API elements */
134+
#include "psa/protected_storage.h"
135+
#endif
136+
137+
#ifdef INITIAL_ATTESTATION
138+
/* psa/initial_attestation.h: Contains the PSA Initial Attestation API elements */
139+
#include "psa/initial_attestation.h"
140+
#endif
141+
142+
extern int tfm_log_printf(const char *, ...);
143+
extern int32_t tfm_platform_system_reset(void);
144+
145+
/* Initialize the timer with the given number of ticks. */
146+
extern void pal_timer_init_ns(uint32_t ticks);
147+
148+
/* Start the timer. */
149+
extern void pal_timer_start_ns(void);
150+
151+
/* Stop and reset the timer. */
152+
extern void pal_timer_stop_ns(void);
153+
154+
/* Get the address of a free, word-aligned, 1K memory area. */
155+
extern uint32_t pal_nvmem_get_addr(void);
156+
157+
#endif /* _PAL_CONFIG_H_ */

0 commit comments

Comments
 (0)