-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix build error with secure/non-secure ROM address on Cortex-M23/M33 #6890
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
Fix build error with secure/non-secure ROM address on Cortex-M23/M33 #6890
Conversation
Add new target configuration options tz_offset/tz_offset_ns to fix TrustZone secure/non-secure ROM address originally fetched from CMSIS pack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the documentation? These 2 should be documented (what how they differ and what is expected to have there - value ranges, and when we should add these to).
@0xc0170 Where can I add documentation for the new configuration options, |
@AnotherButler Can you help? or @deepikabhavnani might know - where we have secure target documentation, this can be mentioned there? |
We do not have any specific document for secure/non-secure. Should it be part of tools? |
I would be careful about the docs, we don't want to give an impression that current state is here to stay and something we will support. We are not going to use Mbed OS in secure mode, we will be relying on secure firmware running in TZ. If the changes only touch/address normal world lets document it, if it's for the temporary secure part, lets not add it to the docs. |
Document part suggested is addresses only, which will be needed later as well. I would recommend to rename them to SECURE_START_ADDR and MBED_START_ADDR to avoid confusion later |
@deepikabhavnani Do you mean
|
@ccli8 - I believe start address option was needed to have support in build tools, same as bootloader but I am not fully convinced with other config options for user application. We have them in target specific files. |
@deepikabhavnani I think it is necessary to change flash/SRAM partition by application developer to meet different application needs. But for this case, lets focus on flash and leave configuable for future support. According to the file change, I just fix # Fix TrustZone secure/non-secure ROM address if (self.target.core == "Cortex-M23" or self.target.core == "Cortex-M33"): rom_start = rom_start + int(getattr(self.target, "tz_offset", "0x0"), 0) elif (self.target.core == "Cortex-M23-NS" or self.target.core == "Cortex-M33-NS"): rom_start = rom_start + int(getattr(self.target, "tz_offset_ns", "0x0"), 0) if self.target.bootloader_img or self.target.restrict_size: return self._generate_bootloader_build(rom_start, rom_size) elif self.target.mbed_app_start or self.target.mbed_app_size: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍 . But should wait for @theotherjimmy approval since it is more of tools change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remain unconvinced. How does this much better from providing the secure partition binary as a boot loader to managed boot loader mode?
@theotherjimmy Would you comment more? I don't catch your point. |
@ccli8 You could provide the secure partition to managed bootloader mode through the use of |
Would it make sense for this documentation to go in our configuration section? |
@theotherjimmy To my knowledge, there would be two boot flows as TZ is introduced in:
They would have the differences:
I think B1 and B2 are both needed for different application development requirements. |
@ccli8 I'm still convinced that the |
@theotherjimmy No. This PR is to fix flash address with TZ and is not bound to the two flows. Take my on-going NUMAKER_PFM_M2351 target for example. It has 512KB flash and if I partition it to 64KB secure flash/448KB non-secure flash. Its flash address space will be: Then look at
|
@ccli8 So, if I get this correct, the non-secure partition is mapped at a different offset to the secure partition? Does the user select the size of these partitions?. Be aware that I take additional configuration parameters very seriously. Any parameters must be supported for the foreseeable future, so any complications in parameters are very serious indeed. |
@ccli8 Is this information described in CMSIS packs? |
Yes. For NUMAKER_PFM_M2351, secure/non-secure flash starts at
Yes. Partition size must be configurable by developer. This PR doesn't address it and just fixes secure/non-secure address offset.
Checking our tool team, NUMAKER_PFM_M2351 CMSIS pack just exposes IROM1 start/size (0x0, 512KB). |
@ccli8 I'm really hesitant to merge this PR, as I will have to support this That's probably not going to happen in the next few days though. |
@theotherjimmy This is 2-level issue:
This PR addresses L1, and it would get of no use if this information can be pulled from CMSIS pack. For L2, partition size is configurable by user through another tool provided by chip manufacturer, so this information is dynamic and cannot be pulled from CMSIS pack. This PR doesn't address it. I have another idea to address L1 and L2 simultaneously. Drop |
@ccli8 If I read that correctly, there is some tool outside of mbed-os that manages the secure/non-secure partition table, and It's not something we could set every time we flash a binary. If that's the case, we're in quite a pickle.
I don't follow the example though. If you're suggesting that a user can select the offset, and not the manufacturer, then why would the definitions for |
Yes.
Yes.
I'm confused. Dependent on actual partition through external tool, user could override "NUMAKER_PFM_M2351_NS": { "target.mbed_rom_start": "0x10010000", "target.mbed_rom_size": "0x70000" }, "NUMAKER_PFM_M2351_S": { "target.mbed_rom_start": "0x0", "target.mbed_rom_size": "0x10000" } |
That's what confused me: if a user always picks this, why do we have a default? |
Default is useful. For example, in most applications, secure code is small and non-secure code is large. We can give a workable partition suggestion in Then there's a similar issue for SRAM. On TZ target, like flash, SRAM also needs to be partitioned. It would be helpful to also provide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep discussion moving in a more constructive direction, @ccli8 Could you implement mbed_rom_start
and mbed_rom_size
so that we can proceed with that solution?
@0xc0170 @theotherjimmy |
Description
This PR tries to fix secure/non-secure ROM address error in bootloader-related build on Cortex-M23/M33. Take our on-going NUMAKER_PFM_M2351 as an example. Its ROM address is
0x0
from CMSIS pack. By introducingtz_offset
/tz_offset_ns
, we can correct secure/non-secure ROM address to0x0
/0x10000000
in build tool.Pull request type