Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M2354: Support Nuvoton M2354 #124

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
target: "ARM_MUSCA_S1"
- compile:
target: "ARM_MUSCA_B1"
- compile:
target: "NU_M2354"
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ matrix:
- <<: *compile-tests
name: "Compile Regression and Compliance tests - ARM_MUSCA_B1"
env: TARGET_NAME=ARM_MUSCA_B1 CACHE_NAME=ARM_MUSCA_B1

# NU_M2354

- <<: *compile-tests
name: "Compile Regression tests - NU_M2354"
env: TARGET_NAME=NU_M2354 CACHE_NAME=NU_M2354
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ if(${MBED_TARGET} STREQUAL "ARM_MUSCA_B1")
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/device)
elseif(${MBED_TARGET} STREQUAL "ARM_MUSCA_S1")
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/device)
elseif(${MBED_TARGET} STREQUAL "NU_M2354")
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_NUVOTON/TARGET_NU_M2354/device)
else()
message(FATAL_ERROR "Unsupported target ${MBED_TARGET}")
endif()
Expand Down Expand Up @@ -69,8 +71,8 @@ if ("${MBED_CONFIG_DEFINITIONS}" MATCHES "MBED_CONF_APP_REGRESSION_TEST=1")
tfm_qcbor
tfm_t_cose
)
# Firmware Update test supports Musca B1 only
if(${MBED_TARGET} STREQUAL ARM_MUSCA_B1)
# Firmware Update test supports Musca B1/M2354 only
if((${MBED_TARGET} STREQUAL ARM_MUSCA_B1) OR (${MBED_TARGET} STREQUAL NU_M2354))
list(APPEND TEST_LIBS
tfm_test_suite_fwu_ns
tfm_api_ns
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ to build an application that runs the test suite.
* To see all available suites, run `python3 build_tfm.py -h`.
* Make sure the TF-M Regression Test suite has **PASSED** on the board before
running any PSA Compliance Test suite to avoid unpredictable behavior.
* M2354 hasn't supported PSA compliance test yet.

## Building the Mbed OS application

Expand Down Expand Up @@ -186,6 +187,8 @@ memory prevents subsequent suites from running.
the run to clear the memory. The total number of failures should match
`CRYPTO.log` in [`test/logs`](./test/logs)`/<your-target>`.

* M2354 hasn't supported PSA compliance test yet.

## Troubleshooting

### Protected Storage (PS) test failures on Musca S1
Expand Down
14 changes: 11 additions & 3 deletions build_tfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,20 @@ def _detect_and_write_tfm_version(tfm_dir, commit):
_commit_changes(MBED_TF_M_PATH)


def _clone_tfm_repo(commit):
def _clone_tfm_repo(target, commit):
"""
Clone TF-M git repos and it's dependencies
:param target: Target name
:param commit: If True then commit VERSION.txt
"""
check_and_clone_repo("trusted-firmware-m", "released-tfm", TF_M_BUILD_DIR)
if target == "NU_M2354":
check_and_clone_repo(
"trusted-firmware-m", "nuvoton-tfm", TF_M_BUILD_DIR
)
else:
check_and_clone_repo(
"trusted-firmware-m", "released-tfm", TF_M_BUILD_DIR
)

_detect_and_write_tfm_version(
os.path.join(TF_M_BUILD_DIR, "trusted-firmware-m"), commit
Expand Down Expand Up @@ -612,7 +620,7 @@ def _build_tfm(args):
"""

if not args.skip_clone:
_clone_tfm_repo(args.commit)
_clone_tfm_repo(args.mcu, args.commit)

cmake_build_dir = os.path.join(
TF_M_BUILD_DIR, "trusted-firmware-m", "cmake_build"
Expand Down
6 changes: 6 additions & 0 deletions psa_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
"master",
],
},
"nuvoton-tfm": {
"trusted-firmware-m": [
"https://github.com/OpenNuvoton/trusted-firmware-m",
"nuvoton_mbed_m2354_tfm-1.3",
],
},
}

TC_DICT = {"ARMCLANG": "ARM", "GNUARM": "GCC_ARM"}
Expand Down
12 changes: 12 additions & 0 deletions test/logs/NU_M2354/REGRESSION.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Non-secure test suites summary
Test suite 'PSA protected storage NS interface tests \(TFM_PS_TEST_1XXX\)' has .* PASSED
Test suite 'PSA internal trusted storage NS interface tests \(TFM_ITS_TEST_1XXX\)' has .* PASSED
Test suite 'Crypto non-secure interface test \(TFM_CRYPTO_TEST_6XXX\)' has .* PASSED
Test suite 'Platform Service Non-Secure interface tests\(TFM_PLATFORM_TEST_2XXX\)' has .* PASSED
Test suite 'Initial Attestation Service non-secure interface tests\(TFM_ATTEST_TEST_2XXX\)' has .* PASSED
Test suite 'QCBOR regression test\(TFM_QCBOR_TEST_7XXX\)' has .* PASSED
Test suite 'T_COSE regression test\(TFM_T_COSE_TEST_8XXX\)' has .* PASSED
Test suite 'PSA firmware update NS interface tests \(TFM_FWU_TEST_1xxx\)' has .* PASSED
Test suite 'Core non-secure positive tests \(TFM_CORE_TEST_1XXX\)' has .* PASSED
Test suite 'IPC non-secure interface test \(TFM_IPC_TEST_1XXX\)' has .* PASSED
End of Non-secure test suites
21 changes: 19 additions & 2 deletions test_psa_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def _build_tfm(args, config, suite=None):
:param suite: Test suite for PSA compliance
"""
cmd = [
"python3",
# On Windows, python3 interpreter can be python.exe instead of python3.exe.
"python3" if shutil.which("python3") is not None else "python",
"build_tfm.py",
"-m",
args.mcu,
Expand Down Expand Up @@ -180,6 +181,20 @@ def _erase_flash_storage(args, suite):
"-Intel",
]

if args.mcu == "NU_M2354":
# Note: Dummy the script for erasing flash storage because drag-n-drop flash
# invokes Mass Erase which will erase the whole flash.
cmd = [
"srec_cat",
"mbed-os-tf-m-regression-tests.bin",
"-Binary",
"-offset",
"0x0",
"-o",
binary_name,
"-Intel",
]

retcode = run_cmd_output_realtime(cmd, mbed_os_dir)
if retcode:
logging.critical(
Expand Down Expand Up @@ -423,7 +438,9 @@ def _main():
if build:
test_spec = _init_test_spec(args)
_build_regression_test(args, test_spec)
_build_compliance_test(args, test_spec)
# M2354 hasn't supported PSA compliance test yet.
LDong-Arm marked this conversation as resolved.
Show resolved Hide resolved
if args.mcu != "NU_M2354":
_build_compliance_test(args, test_spec)

with open("test_spec.json", "w") as f:
f.write(json.dumps(test_spec, indent=2))
Expand Down
26 changes: 26 additions & 0 deletions tfm_ns_import.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@
"dst": "targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/partition/signing_layout_s.c"
}
],
"NU_M2354": [
{
"src": "../platform/ext/target/nuvoton/m2354/partition/flash_layout.h",
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/flash_layout.h"
},
{
"src": "../platform/ext/target/nuvoton/m2354/partition/region_defs.h",
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/region_defs.h"
},
{
"src": "install/image_signing/layout_files/signing_layout_s.o",
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/signing_layout_s_preprocessed.h"
},
{
"src": "install/image_signing/layout_files/signing_layout_ns.o",
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/signing_layout_ns_preprocessed.h"
},
{
"src": "../bl2/ext/mcuboot/root-RSA-3072.pem",
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/signing_key/nuvoton_m2354-root-rsa-3072.pem"
},
{
"src": "install/image_signing/keys/root-RSA-3072_1.pem",
"dst": "targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/signing_key/nuvoton_m2354-root-rsa-3072_1.pem"
}
],
# List of files that should not be copied to Mbed OS even though they are covered by directory rules
# in the next sections.
# This feature keeps the yaml file small and tidy by allowing folder rules and list of files to be excluded.
Expand Down