Skip to content

M2354: add TRNG to device_has list #14800

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

Closed
wants to merge 1 commit into from
Closed

M2354: add TRNG to device_has list #14800

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 17, 2021

Summary of changes

The NU_M2354 target does have a TRNG but it is missing from the device_has list
in targets.json. This commit updates this file such that DEVICE_TRNG is defined
for NU_M2354. No further additions are required to port the M2345's true random
number generator to Mbed OS.

Impact of changes

Migration actions required

Documentation

None


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[ ] Feature update (New feature / Functionality change / New API)
[ ] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[ ] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[ ] Tests / results supplied as part of this PR

Reviewers

@MarceloSalazar
@ccli8


The NU_M2354 target does have a TRNG but it is missing from the device_has list
in targets.json. This commit updates this file such that DEVICE_TRNG is defined
for NU_M2354. No further additions are required to port the M2345's true random
number generator to Mbed OS.
@MarceloSalazar MarceloSalazar requested a review from a team June 17, 2021 12:10
Copy link
Contributor

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The TRNG implementation is based on PSA where psa_generate_random is provided by TF-M.

Maybe in the future we can consider globally enabling TRNG on TF-M targets in Mbed OS - are TF-M targets required/guaranteed to have it? @noonfom

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 17, 2021

Was this tested on hw or if we don't have it currently, can @ARMmbed/team-nuvoton help us?

@MarceloSalazar
Copy link

@noonfom as you have HW, can you please run the corresponding Greentea test and share the logs?

mbed test -t <toolchain> -m <target> -v -n *mbed-os-tests-mbed_hal-trng*

@ghost
Copy link
Author

ghost commented Jun 17, 2021

@LDong-Arm TF-M targets are not required/guaranteed to have a TRNG, e.g., AN521 uses a PRNG.

@0xc0170 I built and ran mbed-os-example-sockets with a TLS socket. That's about all the testing I've done so far.

@MarceloSalazar Sure, I'll run the Greentea test this afternoon.

@ccli8
Copy link
Contributor

ccli8 commented Jun 18, 2021

M2354 has TRNG implementation on TF-M side. And it gets available through PSA TRNG on Mbed.

Actually, this PR isn't necessary. Looking into mbed-os/targets/targets.json, NU_M2354 target has had TRNG through inheriting PSA_V8_M target:

"PSA_V8_M": {
"inherits": [
"PSA_Target"
],
"extra_labels": [
"TFM",
"TFM_LATEST",
"TFM_V8M"
],
"device_has": [
"TRNG"
],

@ccli8
Copy link
Contributor

ccli8 commented Jun 18, 2021

Actually, this PR isn't necessary...

Sorry, missing one point. DEVICE_TRNG isn't defined without change. The suggested fix should be: change device_has with device_has_add. Then TRNG will get in through inheriting PSA_V8_M target.

mbed-os/targets/targets.json

Lines 6997 to 7002 in 3319beb

"device_has": [
"USTICKER",
"LPTICKER",
"RTC",
"ANALOGIN",
"ANALOGOUT",

@0xc0170 0xc0170 added needs: work release-type: patch Indentifies a PR as containing just a patch and removed needs: CI labels Jun 18, 2021
@ccli8
Copy link
Contributor

ccli8 commented Jun 21, 2021

@noonfom How about changedevice_has with device_has_add for adding TRNG in?

@LDong-Arm
Copy link
Contributor

LDong-Arm commented Jun 21, 2021

@noonfom As @ccli8 noted, the base target PSA_V8_M declares TRNG via device_has but it doesn't work as it gets replaced by each target's own device_has.

@LDong-Arm TF-M targets are not required/guaranteed to have a TRNG, e.g., AN521 uses a PRNG.

If TRNG is not guaranteed by TF-M, maybe we should remove it from PSA_V8_M and add it to individual PSA_V8_M targets. This would also mean device_has_add -> device_has in each target, as there would be not be a base to "add" to anymore.

@ghost
Copy link
Author

ghost commented Jun 21, 2021

Thanks @ccli8 and @LDong-Arm. Closing in favour of #14807.

@ghost ghost closed this Jun 21, 2021
@mergify mergify bot removed needs: work release-type: patch Indentifies a PR as containing just a patch labels Jun 21, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants