Skip to content

M2351: Pre-build secure image/lib to favor pelion application #11594

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

Merged

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented Sep 30, 2019

Description

In this PR, default secure program is re-built most simplified so that non-secure program can make most use of memory for its large application like pelion. The secure program will partition memory:

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

Note for running greentea on secure target

With secure program most simplified, there's no memory available to run greentea on secure target NU_PFM_M2351_NPSA_S. If it is necessary, re-partition memory in mbed_app.json:

{
    "target_overrides": {
    ....
        "NU_PFM_M2351_NPSA_S": {
            "target.mbed_rom_start"             : "0x0",
            "target.mbed_rom_size"              : "0x40000",
            "target.mbed_ram_start"             : "0x20000000",
            "target.mbed_ram_size"              : "0x8000"
        },
    ....
    }
}

Related PR

ARMmbed/mbed-os-example-pelion#25 (comment)

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@ciarmcom ciarmcom requested review from Ronny-Liu and a team September 30, 2019 07:00
@ciarmcom
Copy link
Member

@ccli8, thank you for your changes.
@Ronny-Liu @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Just a check: This change meets the min requirement for pelion - changing the memory sizes for secure/non-secure?

Is this just a fix for a patch release, or rather functional change ?

@ccli8
Copy link
Contributor Author

ccli8 commented Sep 30, 2019

This change meets the min requirement for pelion - changing the memory sizes for secure/non-secure?

Yes, allocate more memory for non-secure program to meet min requirement of pelion.

Is this just a fix for a patch release, or rather functional change ?

Just patch release

But for CI/Greentea, it is necessary to re-partition memory for building secure target NU_PFM_M2351_NPSA_S, commented as above.

@ccli8
Copy link
Contributor Author

ccli8 commented Oct 2, 2019

Update?

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

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

@Patater please have a look

@@ -19,13 +20,51 @@ The pre-built secure code has the following hardware partition:
- **PDMA0** hardwired to secure. Implements secure asynchronous transfer.
- **PDMA1** configured to nonsecure. Implements nonsecure asynchronous transfer.

## 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

"pelion" should be "Pelion"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it necessary to change mbed_app.json to build the default image? Shouldn't the default targets.json for NU_PFM_M2351_NPSA_S be modified to have these values as the default instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modify README.md and Non-PSA secure code. The default secure program can re-generate without modification.

"mbed_ram_start" : "0x20000000",
"mbed_ram_size" : "0x8000"
"mbed_ram_size" : "0x2000"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add "target.boot-stack-size" : "0x600" here and also "target.device_has_remove": ["SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES"],?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added.

@ccli8 ccli8 force-pushed the nuvoton_m2351_partition-memory-pelion branch from 61a231b to f406f5a Compare October 3, 2019 06:52
@ccli8
Copy link
Contributor Author

ccli8 commented Oct 3, 2019

Make modification:

Default non-PSA secure program can re-generate without modification in Non-PSA secure program.

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

Changes look fine to me. I think we need some more thought put into how we'd maintain this binary.

:104710008F46C04600F026B800F027B800F028B851
:1047200000F029B800F02AB800F02BB800F02CB83F
:1047300000F02DB800F02FB800F02DB800F02BB825
:1047400000F029B800F027B800F025B8
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the maintenance plan for this binary? When will it need to be rebuilt? When will we notice that it is broken and requires rebuilding? Maybe some sort of automated test is needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@0xc0170 How do we indicate the license this binary is provided under?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the maintenance plan for this binary? When will it need to be rebuilt? When will we notice that it is broken and requires rebuilding? Maybe some sort of automated test is needed.

Currently, it is re-built by Nuvoton manually. When there's any of memory re-partition, change of IP security attribute, or change of secure function I/F, it will be re-built.

Copy link
Contributor

Choose a reason for hiding this comment

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

@0xc0170 How do we indicate the license this binary is provided under?

license file located in the folder

@bulislaw
Copy link
Member

bulislaw commented Oct 7, 2019

General question, why does this need to be a binary rather than source?

@ccli8
Copy link
Contributor Author

ccli8 commented Oct 8, 2019

General question, why does this need to be a binary rather than source?

@bulislaw This is well-defined build flow for TrustZone targets. TF-M targets like MUSCA_A1 also follows it.

@ccli8
Copy link
Contributor Author

ccli8 commented Oct 8, 2019

Other concern?

@ccli8
Copy link
Contributor Author

ccli8 commented Oct 18, 2019

Update?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 18, 2019

I am reviewing now, sorry for the delay. Looks like all reviewers approved (not explicitly though).

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 18, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Oct 18, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM

@ccli8
Copy link
Contributor Author

ccli8 commented Oct 21, 2019

To achieve minimum memory footprint on secure target, this PR re-partitions memory and makes related modifications for non-secure target to have maximum memory to run Pelion. To run CI on secure target, the above configuration must change back to normal use for secure target via mbed_app.json:

        "NU_PFM_M2351_NPSA_S": {
            "target.boot-stack-size"                : "0x1000",
            "target.device_has_add"                 : ["SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES"],
            "target.mbed_rom_start"                 : "0x0",
            "target.mbed_rom_size"                  : "0x40000",
            "target.mbed_ram_start"                 : "0x20000000",
            "target.mbed_ram_size"                  : "0x8000"
        },

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 23, 2019

@Patater Can you re-review please?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 23, 2019

@ccli8 The latest comment was regarding CI failures? Or not? How do we fix them?

@ccli8 ccli8 force-pushed the nuvoton_m2351_partition-memory-pelion branch from 45547e4 to 26e6b15 Compare October 28, 2019 02:43
@ccli8
Copy link
Contributor Author

ccli8 commented Oct 28, 2019

Make modifications:

  1. Do rebase
  2. Fix conflict

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 28, 2019

CI restarted, might still fails, will follow up what to do with the build with @ARMmbed/mbed-os-test

@mbed-ci
Copy link

mbed-ci commented Oct 28, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 28, 2019

Expected failure.

CI restarted, might still fails, will follow up what to do with the build with @ARMmbed/mbed-os-test

Please help us reviewing the failures and what can we do to pass the build for this target.

@ccli8
Copy link
Contributor Author

ccli8 commented Oct 29, 2019

On NU_PFM_M2351_NPSA_S target, not only disabled serial but also just 8KiB SRAM can cause CI build failure. My suggestion: exclude NU_PFM_M2351_NPSA_S from CI or follow #11594 (comment)

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 26, 2019

@ccli8 We will have the NU_PFM_M2351_NPSA_S disabled for building, so will restart CI once it is integrated

@cyliangtw
Copy link
Contributor

@0xc0170 For restart CI, do you need any help on the integration of "NU_PFM_M2351_NPSA_S disabled for building" ?

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 2, 2019

@cyliangtw I'll restart CI (should be fixed) later today

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 2, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Dec 2, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 requested a review from Patater December 3, 2019 08:05
@0xc0170 0xc0170 added the release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 label Dec 3, 2019
@0xc0170 0xc0170 merged commit a8ee2d8 into ARMmbed:master Dec 3, 2019
@0xc0170 0xc0170 removed the needs: CI label Dec 3, 2019
@ccli8
Copy link
Contributor Author

ccli8 commented Dec 4, 2019

What's the schedule for 6.0.0? 5.14.3 or 5.15.0 in between?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 14, 2020

What's the schedule for 6.0.0? 5.14.3 or 5.15.0 in between?

We almost missed this one. 6.0.0-alpha1 tomorrow. 5.15 was released back in December

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants