|
1 | 1 | # Default secure code for M2351
|
2 | 2 |
|
3 |
| -M2351 is a TrustZone target which requires two codes: secure and non-secure. |
4 |
| -Secure code would run first to set up secure environment and then bring up non-secure code. |
5 |
| -`NuMaker-mbed-TZ-secure-example.hex` is the default secure code and `cmse_lib.o` is its accompanying |
6 |
| -secure gateway library which exports secure functions to non-secure code. It is built from |
7 |
| -[secure code template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example). |
8 |
| -With secure/non-secure code possibly not starting at address `0x0`, `.hex` rather than `.bin` is |
9 |
| -chosen as output format. |
| 3 | +The M2351 is a TrustZone target that requires two codes: secure and nonsecure. Secure code runs first to set up the secure environment and then brings up the nonsecure code. `NuMaker-mbed-TZ-secure-example.hex` is the default secure code, and `cmse_lib.o` is its accompanying |
| 4 | +secure gateway library, which exports secure functions to nonsecure code. It is built from the [secure code template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example). Because secure and nonsecure code may start at an address other than `0x0`, we have chosen `.hex` rather than `.bin` as the output format. |
10 | 5 |
|
11 | 6 | ## Hardware partition
|
12 | 7 |
|
13 |
| -On TrustZone targets, it is necessary to partition the hardware first for secure/non-secure code |
14 |
| -to run on secure/non-secure worlds respectively. |
| 8 | +On TrustZone targets, you need to partition the hardware first for secure code to run on secure worlds and nonsecure code to run on nonsecure worlds. |
15 | 9 |
|
16 | 10 | The default secure code has the following hardware partition:
|
17 |
| -- Flash (512KiB in total): 256KiB/256KiB to secure/non-secure respectively |
18 |
| -- SRAM (96KiB in total): 32KiB/64KiB to secure/non-secure respectively |
19 |
| -- Peripherals: most are configured to non-secure except the following which are hardwired or reserved: |
20 |
| - - **SYS/CLK** hardwired to secure. Accessible to non-secure through secure gateway |
21 |
| - - **FMC** hardwired to secure. Accessible to non-secure through secure gateway |
22 |
| - - **WDT** hardwired to secure. Accessible to non-secure through secure gateway |
23 |
| - - **RTC** configured to secure. Accessible to non-secure through secure gateway |
24 |
| - - **TMR0/1** hardwired to secure. Implement secure `us_ticker`/`lp_ticker` respectively |
25 |
| - - **TMR2/3** configured to non-secure. Implement non-secure `us_ticker`/`lp_ticker` respectively |
26 |
| - - **PDMA0** hardwired to secure. Implement secure asynchronous transfer |
27 |
| - - **PDMA1** configured to non-secure. Implement non-secure asynchronous transfer |
28 |
| - |
29 |
| -## Flash secure/non-secure code |
30 |
| - |
31 |
| -To flash secure/non-secure code on M2351, drag-n-drop `NuMaker-mbed-TZ-secure-example.hex` |
32 |
| -first and then built user program e.g. [mbed-os-example-blinky.hex](https://github.com/ARMmbed/mbed-os-example-blinky). |
| 11 | + |
| 12 | +- Flash (512KiB in total): 256KiB for secure and 256KiB for nonsecure. |
| 13 | +- SRAM (96KiB in total): 32KiB for secure and 64KiB for nonsecure. |
| 14 | +- Peripherals: Most are configured to nonsecure except the following, which are hardwired or reserved: |
| 15 | + - **SYS/CLK** hardwired to secure. Accessible to nonsecure through a secure gateway. |
| 16 | + - **FMC** hardwired to secure. Accessible to nonsecure through a secure gateway. |
| 17 | + - **WDT** hardwired to secure. Accessible to nonsecure through a secure gateway. |
| 18 | + - **RTC** configured to secure. Accessible to nonsecure through a secure gateway. |
| 19 | + - **TMR0/1** hardwired to secure. TMR0 implements secure `us_ticker`, and TMR1 implements secure `lp_ticker`. |
| 20 | + - **TMR2/3** configured to nonsecure. TMR2 implements nonsecure `us_ticker`, and TMR3 implements nonsecure `lp_ticker`. |
| 21 | + - **PDMA0** hardwired to secure. Implements secure asynchronous transfer. |
| 22 | + - **PDMA1** configured to nonsecure. Implements nonsecure asynchronous transfer. |
| 23 | + |
| 24 | +## Flash secure and nonsecure code |
| 25 | + |
| 26 | +To flash secure and nonsecure code on the M2351, drag-and-drop `NuMaker-mbed-TZ-secure-example.hex` first, and then build the user program, for example, [mbed-os-example-blinky.hex](https://github.com/ARMmbed/mbed-os-example-blinky). |
33 | 27 |
|
34 | 28 | ## Reference
|
35 | 29 |
|
36 |
| -Refer to [secure code template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example) for details. |
| 30 | +Please refer to the [secure code template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example) for details. |
0 commit comments