M2351: Re-build default secure image/gateway library to favor Pelion application

In this new memory partition, secure program is most simplified and non-secure program can make most use of memory for its large application like Pelion:

-   Flash (512KiB in total): 64KiB for secure and 448KiB for nonsecure.
-   SRAM (96KiB in total): 8KiB for secure and 88KiB for nonsecure.

Besides, to make secure program fit into 8KiB:

-   Decrease boot stack size to 0x600 bytes
-   Remove serial support
pull/11594/head
Chun-Chieh Li 2019-09-30 09:57:25 +08:00
parent 59771b704d
commit 26e6b15110
4 changed files with 969 additions and 1592 deletions

View File

@ -1,14 +1,15 @@
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 pre-built secure image, and `cmse_lib.o` is its accompanying
secure gateway library, which exports secure functions to nonsecure code. It is built from the [non-PSA 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.
The M2351 is a TrustZone target that requires two programs: secure and nonsecure.
Secure program runs first to set up the secure environment and then brings up the nonsecure program. `NuMaker-mbed-TZ-secure-example.hex` is the pre-built secure image, and `cmse_lib.o` is its accompanying secure gateway library, which exports secure functions to nonsecure program.
It is built from the [non-PSA secure program template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example). Because secure program and nonsecure program may start at an address other than `0x0`, we have chosen `.hex` rather than `.bin` as the output format.
## Hardware partition
On TrustZone targets, you need to partition the hardware first for secure code to run on secure world and nonsecure code to run on nonsecure world.
On TrustZone targets, you need to partition the hardware first for secure program to run on secure world and nonsecure program to run on nonsecure world.
The pre-built secure code has the following hardware partition:
The pre-built secure program will set up the following hardware partition:
- Flash (512KiB in total): 256KiB for secure and 256KiB for nonsecure.
- SRAM (96KiB in total): 32KiB for secure and 64KiB for nonsecure.
- Flash (512KiB in total): 64KiB for secure and 448KiB for nonsecure.
- SRAM (96KiB in total): 8KiB for secure and 88KiB for nonsecure.
- Peripherals: Most are configured to nonsecure except the following, which are hardwired or reserved:
- **SYS/CLK** hardwired to secure. Accessible to nonsecure through a secure gateway.
- **FMC** hardwired to secure. Accessible to nonsecure through a secure gateway.
@ -20,13 +21,22 @@ The pre-built secure code has the following hardware partition:
- **PDMA1** configured to nonsecure. Implements nonsecure asynchronous transfer.
- **TRNG** configured to secure. Accessible to nonsecure through a secure gateway.
## Pre-built secure code files
In this memory partition, secure program is the most simplified.
Then non-secure program can make use of the most memory available for its large application like Pelion.
To regenerate the default secure program, in [non-PSA secure program template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example), run:
```sh
$ mbed compile -m NU_PFM_M2351_NPSA_S -t ARMC6 --profile release
```
## Pre-built secure program files
- NuMaker-mbed-TZ-secure-example.hex
Pre-built secure image generated in non-PSA secure target build and to combine with non-secure image in non-PSA non-secure target post-build
- cmse_lib.o
Pre-built secure gateway library generated in non-PSA secure target build and to link with non-secure code in non-PSA non-secure target build
Pre-built secure gateway library generated in non-PSA secure target build and to link with non-secure program in non-PSA non-secure target build
## Reference
Please refer to the [non-PSA secure code template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example) for details.
Please refer to the [non-PSA secure program template](https://github.com/OpenNuvoton/NuMaker-mbed-TZ-secure-example) for details.

View File

@ -8878,25 +8878,29 @@
"components_add": ["FLASHIAP"],
"post_binary_hook": {"function": "M2351Code.merge_secure"},
"secure_image_filename": "NuMaker-mbed-TZ-secure-example.hex",
"mbed_rom_start" : "0x10040000",
"mbed_rom_size" : "0x40000",
"mbed_ram_start" : "0x30008000",
"mbed_ram_size" : "0x10000"
"mbed_rom_start" : "0x10010000",
"mbed_rom_size" : "0x70000",
"mbed_ram_start" : "0x30002000",
"mbed_ram_size" : "0x16000"
},
"NU_PFM_M2351_NPSA_S": {
"overrides": {
"boot-stack-size" : "0x600"
},
"inherits": ["NU_PFM_M2351"],
"core": "Cortex-M23",
"trustzone": true,
"extra_labels_add": [
"M23_S"
],
"device_has_remove": ["SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES"],
"components_add": ["FLASHIAP"],
"deliver_to_target": "NU_PFM_M2351_NPSA_NS",
"delivery_dir": "TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_NU_PFM_M2351_NPSA_NS/TARGET_NU_PREBUILD_SECURE",
"mbed_rom_start" : "0x0",
"mbed_rom_size" : "0x40000",
"mbed_rom_size" : "0x10000",
"mbed_ram_start" : "0x20000000",
"mbed_ram_size" : "0x8000"
"mbed_ram_size" : "0x2000"
},
"NUMAKER_M252KG": {
"core": "Cortex-M23",