Skip to content

Commit 19fc2b1

Browse files
authored
Merge pull request #11650 from OpenNuvoton/nuvoton_trng-hal-with-trng-hw
Nuvoton: Re-implement TRNG HAL with TRNG H/W
2 parents ab931ee + 8161386 commit 19fc2b1

File tree

26 files changed

+5988
-2415
lines changed

26 files changed

+5988
-2415
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/PeripheralNames.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ typedef enum {
328328

329329
} CANName;
330330

331+
typedef enum {
332+
#if defined(SCU_INIT_PNSSET5_VAL) && (SCU_INIT_PNSSET5_VAL & (1 << 25))
333+
TRNG_0 = (int) NU_MODNAME(TRNG_BASE + NS_OFFSET, 0, 0)
334+
#else
335+
TRNG_0 = (int) NU_MODNAME(TRNG_BASE, 0, 0)
336+
#endif
337+
338+
} TRNGName;
339+
331340
#ifdef __cplusplus
332341
}
333342
#endif

targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_NU_PFM_M2351_NPSA_NS/TARGET_NU_PREBUILD_SECURE/NuMaker-mbed-TZ-secure-example.hex

Lines changed: 1571 additions & 1562 deletions
Large diffs are not rendered by default.

targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_NU_PFM_M2351_NPSA_NS/TARGET_NU_PREBUILD_SECURE/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The pre-built secure code has the following hardware partition:
1818
- **TMR2/3** configured to nonsecure. TMR2 implements nonsecure `us_ticker`, and TMR3 implements nonsecure `lp_ticker`.
1919
- **PDMA0** hardwired to secure. Implements secure asynchronous transfer.
2020
- **PDMA1** configured to nonsecure. Implements nonsecure asynchronous transfer.
21+
- **TRNG** configured to secure. Accessible to nonsecure through a secure gateway.
2122

2223
## Pre-built secure code files
2324

targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "platform/SingletonPtr.h"
2828
#include "platform/PlatformMutex.h"
2929

30-
#if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT)
30+
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
3131

3232
/* Consideration for choosing proper synchronization mechanism
3333
*
@@ -345,4 +345,4 @@ extern "C" void CRPT_IRQHandler()
345345
}
346346
}
347347

348-
#endif /* #if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT) */
348+
#endif /* #if defined(MBEDTLS_CONFIG_HW_SUPPORT) */

targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,23 @@
2424
*
2525
* There's only one CRYPTO/CRPT module and we have the following policy for configuring its secure attribute:
2626
*
27-
* 1. TRNG or mbedtls H/W support can be enabled on either secure target or non-secure target, but not both.
28-
* 2. TRNG and mbedtls H/W supports cannot be enabled on different targets.
29-
* 3. On secure target, if TRNG or mbedtls H/W support is enabled, CRYPTO/CRPT must configure to secure.
30-
* 4. On non-secure target, if TRNG or mbedtls H/W support is enabled, CRYPTO/CRPT must configure to non-secure.
27+
* 1. mbedtls H/W support can be enabled on either secure target or non-secure target, but not both.
28+
* 2. On secure target, if mbedtls H/W support is enabled, CRYPTO/CRPT must configure to secure.
29+
* 3. On non-secure target, if mbedtls H/W support is enabled, CRYPTO/CRPT must configure to non-secure.
3130
*/
32-
#if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT)
31+
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
3332
#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
3433
#if defined(SCU_INIT_PNSSET1_VAL) && (SCU_INIT_PNSSET1_VAL & (1 << 18))
35-
#error("CRYPTO/CRPT must configure to secure for secure target which supports TRNG or mbedtls H/W")
34+
#error("CRYPTO/CRPT must configure to secure for secure target which supports mbedtls H/W")
3635
#endif
3736
#else
3837
#if (! defined(SCU_INIT_PNSSET1_VAL)) || (! (SCU_INIT_PNSSET1_VAL & (1 << 18)))
39-
#error("CRYPTO/CRPT must configure to non-secure for non-secure target which supports TRNG or mbedtls H/W")
38+
#error("CRYPTO/CRPT must configure to non-secure for non-secure target which supports mbedtls H/W")
4039
#endif
4140
#endif
4241
#endif
4342

44-
#if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT)
43+
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
4544

4645
#ifdef __cplusplus
4746
extern "C" {
@@ -132,6 +131,6 @@ bool crypto_dma_buffs_overlap(const void *in_buff, size_t in_buff_size, const vo
132131
}
133132
#endif
134133

135-
#endif /* #if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT) */
134+
#endif /* defined(MBEDTLS_CONFIG_HW_SUPPORT) */
136135

137136
#endif

targets/TARGET_NUVOTON/TARGET_M2351/device/M2351.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ typedef volatile unsigned short vu16;
686686
#include "m2351_qei.h"
687687
#include "m2351_can.h"
688688
#include "m2351_scu.h"
689-
#include "m2351_bootloader.h"
689+
#include "m2351_mkromlib.h"
690690

691691
#endif /* __M2351_H__ */
692692

targets/TARGET_NUVOTON/TARGET_M2351/device/M2351_funcs.S

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)