Skip to content

Commit 2d3cd7e

Browse files
committed
M2354: Support Nuvoton M2354
1. Change trusted-firmware-m download path to Nuvoton forked repository (nuvoton_mbed_m2354_tfm-1.3) 2. Add post-build copy paths specific to M2354 (tfm_ns_import.yaml) 3. Detect python/python3 command name across platforms 4. Enable Mbed CLI 2 (CMake) 5. Enable Greentea test path (1) Disable PSA compliance test, which M2354 hasn't supported yet (2) Add compare log (REGRESSION.log only) 6. Update CI configuration 7. Update readme NOTE1: Dummy the script for erasing flash storage for Greentea test because drag-n-drop flash invokes Mass Erase which will erase the whole flash. NOTE2: As ITS/PS/NV counter regions are changed (flash_layout.h), the script for erasing flash storage needs update accordingly. But this can skip with above. NOTE3: To cover root-RSA-3072.pem missing in TF-M install (https://developer.trustedfirmware.org/T957), change its source path for copy: From: install/image_signing/keys/root-RSA-3072.pem To: ../bl2/ext/mcuboot/root-RSA-3072.pem NOTE4: For PSA Firmware Update test, in CMakeLists (for Mbed CLI 2), test lib tfm_test_suite_fwu_ns is needed. NOTE5: REGRESSION.log needs to contain PSA Firmware Update test.
1 parent 0fb365e commit 2d3cd7e

File tree

9 files changed

+89
-7
lines changed

9 files changed

+89
-7
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ jobs:
2727
target: "ARM_MUSCA_S1"
2828
- compile:
2929
target: "ARM_MUSCA_B1"
30+
- compile:
31+
target: "NU_M2354"

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ matrix:
8686
- <<: *compile-tests
8787
name: "Compile Regression and Compliance tests - ARM_MUSCA_B1"
8888
env: TARGET_NAME=ARM_MUSCA_B1 CACHE_NAME=ARM_MUSCA_B1
89+
90+
# NU_M2354
91+
92+
- <<: *compile-tests
93+
name: "Compile Regression tests - NU_M2354"
94+
env: TARGET_NAME=NU_M2354 CACHE_NAME=NU_M2354

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ if(${MBED_TARGET} STREQUAL "ARM_MUSCA_B1")
2828
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/device)
2929
elseif(${MBED_TARGET} STREQUAL "ARM_MUSCA_S1")
3030
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/device)
31+
elseif(${MBED_TARGET} STREQUAL "NU_M2354")
32+
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_NUVOTON/TARGET_NU_M2354/device)
3133
else()
3234
message(FATAL_ERROR "Unsupported target ${MBED_TARGET}")
3335
endif()
@@ -69,8 +71,8 @@ if ("${MBED_CONFIG_DEFINITIONS}" MATCHES "MBED_CONF_APP_REGRESSION_TEST=1")
6971
tfm_qcbor
7072
tfm_t_cose
7173
)
72-
# Firmware Update test supports Musca B1 only
73-
if(${MBED_TARGET} STREQUAL ARM_MUSCA_B1)
74+
# Firmware Update test supports Musca B1/M2354 only
75+
if((${MBED_TARGET} STREQUAL ARM_MUSCA_B1) OR (${MBED_TARGET} STREQUAL NU_M2354))
7476
list(APPEND TEST_LIBS
7577
tfm_test_suite_fwu_ns
7678
tfm_api_ns

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ to build an application that runs the test suite.
102102
* To see all available suites, run `python3 build_tfm.py -h`.
103103
* Make sure the TF-M Regression Test suite has **PASSED** on the board before
104104
running any PSA Compliance Test suite to avoid unpredictable behavior.
105+
* M2354 hasn't supported PSA compliance test yet.
105106

106107
## Building the Mbed OS application
107108

@@ -186,6 +187,8 @@ memory prevents subsequent suites from running.
186187
the run to clear the memory. The total number of failures should match
187188
`CRYPTO.log` in [`test/logs`](./test/logs)`/<your-target>`.
188189
190+
* M2354 hasn't supported PSA compliance test yet.
191+
189192
## Troubleshooting
190193
191194
### Protected Storage (PS) test failures on Musca S1

build_tfm.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,20 @@ def _detect_and_write_tfm_version(tfm_dir, commit):
6565
_commit_changes(MBED_TF_M_PATH)
6666

6767

68-
def _clone_tfm_repo(commit):
68+
def _clone_tfm_repo(target, commit):
6969
"""
7070
Clone TF-M git repos and it's dependencies
71+
:param target: Target name
7172
:param commit: If True then commit VERSION.txt
7273
"""
73-
check_and_clone_repo("trusted-firmware-m", "released-tfm", TF_M_BUILD_DIR)
74+
if target == "NU_M2354":
75+
check_and_clone_repo(
76+
"trusted-firmware-m", "nuvoton-tfm", TF_M_BUILD_DIR
77+
)
78+
else:
79+
check_and_clone_repo(
80+
"trusted-firmware-m", "released-tfm", TF_M_BUILD_DIR
81+
)
7482

7583
_detect_and_write_tfm_version(
7684
os.path.join(TF_M_BUILD_DIR, "trusted-firmware-m"), commit
@@ -612,7 +620,7 @@ def _build_tfm(args):
612620
"""
613621

614622
if not args.skip_clone:
615-
_clone_tfm_repo(args.commit)
623+
_clone_tfm_repo(args.mcu, args.commit)
616624

617625
cmake_build_dir = os.path.join(
618626
TF_M_BUILD_DIR, "trusted-firmware-m", "cmake_build"

psa_builder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
"master",
4444
],
4545
},
46+
"nuvoton-tfm": {
47+
"trusted-firmware-m": [
48+
"https://github.com/OpenNuvoton/trusted-firmware-m",
49+
"nuvoton_mbed_m2354_tfm-1.3",
50+
],
51+
},
4652
}
4753

4854
TC_DICT = {"ARMCLANG": "ARM", "GNUARM": "GCC_ARM"}

test/logs/NU_M2354/REGRESSION.log

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Non-secure test suites summary
2+
Test suite 'PSA protected storage NS interface tests \(TFM_PS_TEST_1XXX\)' has .* PASSED
3+
Test suite 'PSA internal trusted storage NS interface tests \(TFM_ITS_TEST_1XXX\)' has .* PASSED
4+
Test suite 'Crypto non-secure interface test \(TFM_CRYPTO_TEST_6XXX\)' has .* PASSED
5+
Test suite 'Platform Service Non-Secure interface tests\(TFM_PLATFORM_TEST_2XXX\)' has .* PASSED
6+
Test suite 'Initial Attestation Service non-secure interface tests\(TFM_ATTEST_TEST_2XXX\)' has .* PASSED
7+
Test suite 'QCBOR regression test\(TFM_QCBOR_TEST_7XXX\)' has .* PASSED
8+
Test suite 'T_COSE regression test\(TFM_T_COSE_TEST_8XXX\)' has .* PASSED
9+
Test suite 'PSA firmware update NS interface tests \(TFM_FWU_TEST_1xxx\)' has .* PASSED
10+
Test suite 'Core non-secure positive tests \(TFM_CORE_TEST_1XXX\)' has .* PASSED
11+
Test suite 'IPC non-secure interface test \(TFM_IPC_TEST_1XXX\)' has .* PASSED
12+
End of Non-secure test suites

test_psa_target.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def _build_tfm(args, config, suite=None):
9494
:param suite: Test suite for PSA compliance
9595
"""
9696
cmd = [
97-
"python3",
97+
# On Windows, python3 interpreter can be python.exe instead of python3.exe.
98+
"python3" if shutil.which("python3") is not None else "python",
9899
"build_tfm.py",
99100
"-m",
100101
args.mcu,
@@ -180,6 +181,20 @@ def _erase_flash_storage(args, suite):
180181
"-Intel",
181182
]
182183

184+
if args.mcu == "NU_M2354":
185+
# Note: Dummy the script for erasing flash storage because drag-n-drop flash
186+
# invokes Mass Erase which will erase the whole flash.
187+
cmd = [
188+
"srec_cat",
189+
"mbed-os-tf-m-regression-tests.bin",
190+
"-Binary",
191+
"-offset",
192+
"0x0",
193+
"-o",
194+
binary_name,
195+
"-Intel",
196+
]
197+
183198
retcode = run_cmd_output_realtime(cmd, mbed_os_dir)
184199
if retcode:
185200
logging.critical(
@@ -423,7 +438,9 @@ def _main():
423438
if build:
424439
test_spec = _init_test_spec(args)
425440
_build_regression_test(args, test_spec)
426-
_build_compliance_test(args, test_spec)
441+
# M2354 hasn't supported PSA compliance test yet.
442+
if args.mcu != "NU_M2354":
443+
_build_compliance_test(args, test_spec)
427444

428445
with open("test_spec.json", "w") as f:
429446
f.write(json.dumps(test_spec, indent=2))

tfm_ns_import.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,32 @@
4040
"dst": "targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/partition/signing_layout_s.c"
4141
}
4242
],
43+
"NU_M2354": [
44+
{
45+
"src": "../platform/ext/target/nuvoton/m2354/partition/flash_layout.h",
46+
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/flash_layout.h"
47+
},
48+
{
49+
"src": "../platform/ext/target/nuvoton/m2354/partition/region_defs.h",
50+
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/region_defs.h"
51+
},
52+
{
53+
"src": "install/image_signing/layout_files/signing_layout_s.o",
54+
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/signing_layout_s_preprocessed.h"
55+
},
56+
{
57+
"src": "install/image_signing/layout_files/signing_layout_ns.o",
58+
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/signing_layout_ns_preprocessed.h"
59+
},
60+
{
61+
"src": "../bl2/ext/mcuboot/root-RSA-3072.pem",
62+
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/signing_key/nuvoton_m2354-root-rsa-3072.pem"
63+
},
64+
{
65+
"src": "install/image_signing/keys/root-RSA-3072_1.pem",
66+
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/signing_key/nuvoton_m2354-root-rsa-3072_1.pem"
67+
}
68+
],
4369
# List of files that should not be copied to Mbed OS even though they are covered by directory rules
4470
# in the next sections.
4571
# This feature keeps the yaml file small and tidy by allowing folder rules and list of files to be excluded.

0 commit comments

Comments
 (0)