-
Notifications
You must be signed in to change notification settings - Fork 3k
Override ROM/RAM start/size for TrustZone targets #7133
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
Override ROM/RAM start/size for TrustZone targets #7133
Conversation
This fix relies on target configuration options (mbed_rom_start/mbed_rom_size) defined to override CMSIS pack or no CMSIS pack. This is useful for a target which: 1. Doesn't support CMSIS pack, or 2. Supports TrustZone and user needs to change its flash partition
…er/linker This fix relies on target configuration options (mbed_rom_start/mbed_rom_size) defined.
…r/linker This fix relies on target configuration options (mbed_ram_start/mbed_ram_size) defined.
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.
Please don't modify macros in the toolchains. If you need the MBED_ROM_START
and other macros outside of boot loader mode, we should do that in config, is it's a configuration decision.
@ccli8 I like this proposal. I take it that the macros are needed even when you're not building a bootloader? |
Yes. The
Then about how to define the |
@ccli8 My suggestion is to make this behave like a bootloader build. That way a user also gets visual verification. I can make that modification if you would like. |
@theotherjimmy OK. Please modify it. |
…IZE don't pass to linker
@theotherjimmy I fix the |
@ccli8 I upgraded the implementation to treat the ROM + RAM specifiers as part of the bootloader mode. This should let you override them as you would any other configuration variable, and starts a generic "RAM reservation" framework using regions, much like the bootloader builds. @marcuschangarm RAM reservation. |
@theotherjimmy The modification doesn't meet my requirement. Compiling "NUMAKER_PFM_M2351_NS": { "target.mbed_rom_start": "0x10010000", "target.mbed_rom_size": "0x70000", "target.mbed_ram_start": "0x30002000", "target.mbed_ram_size": "0x16000", "target.mbed_app_start" : "0x10024000", "target.mbed_app_size" : "0x5C000", Checking .profile-c/.profile-cxx, ROM start/size are overridden by
Checking .profile-ld, same as above, ROM start/size don't correctly pass to linker.
|
@ccli8 Cloud-client-example uses an unmanaged bootloader project. The defines in here will not take priority over them. The numbers are correct. |
@theotherjimmy The modification meets the initial goal: use As I know, |
This is where we disagree. If this patch is to be useful to those without cmsis-packs, then we need them to be mixable. |
@theotherjimmy It seems the disagree lies in that you use
Currently, the modification meets G1 and doesn't meet G2/G3. In my opinion, now that |
@ccli8 That's where this patch gets clever: The presence of Why do you need the direct ROM information? |
tools/config/__init__.py
Outdated
for memory in memories: | ||
try: | ||
size = cmsis_part['memory']['IRAM1']['size'] | ||
start = cmsis_part['memory']['IRAM1']['start'] |
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.
Oh, that's wrong. Just a sec.
Like G2, flash algorithm needs ROM information to be passed in. Take /* Secure flash */ static const flash_target_config_t flash_target_config = { .page_size = 4, .flash_start = 0x0, #if defined(FMC_SECURE_ROM_SIZE) .flash_size = FMC_SECURE_ROM_SIZE, #else .flash_size = 0x80000, #endif .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; /* Non-secure flash */ static const flash_target_config_t flash_target_config_ns = { .page_size = 4, .flash_start = NS_OFFSET + FMC_SECURE_ROM_SIZE, #if defined(FMC_SECURE_ROM_SIZE) .flash_size = 0x80000 - FMC_SECURE_ROM_SIZE, #else .flash_size = 0, #endif .sectors = sectors_info_ns, .sector_info_count = sizeof(sectors_info_ns) / sizeof(sector_info_t) }; |
@theotherjimmy Continuing my above comment. For G3 (linker script), |
@ccli8 Thanks for the detail. I'll make |
Are we waiting for another commit here to resolve this? I added a label needs: work |
@0xc0170 Yes. We're waiting on me. Just a moment. |
* MBED_ROM_START = start of current rom (independent of BL modes) * MBED_ROM_SIZE = size of current rom (independent of BL modes)
@ccli8 That should do it. I'm liking the way the configuration is getting a "richer" set of features and the toolchains are adding the appropriate stuff as defines. |
@theotherjimmy This modification can meet my requirement of configuring TrustZone target. Many thanks for your support. |
/morph build |
Build : SUCCESSBuild number : 2421 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2051 |
Test : SUCCESSBuild number : 2202 |
Description
On TrustZone targets, ROM/RAM start/size are not so fixed and can be changed by external tool or other means. This PR introduces new target configuration options for user to override ROM/RAM start/size dependent on its real case.
mbed_rom_start
/mbed_rom_size
)rom_start
/rom_size
pulled from CMSIS pack or no CMSIS packMBED_ROM_START
/MBED_ROM_SIZE
) to compilerMBED_ROM_START
/MBED_ROM_SIZE
) to linkermbed_ram_start
/mbed_ram_size
)ram_start
/ram_size
pulled from CMSIS pack or no CMSIS packMBED_RAM_START
/MBED_RAM_SIZE
) to compilerMBED_RAM_START
/MBED_RAM_SIZE
) to linkerTake our on-going NUMAKER_PFM_M2351 as an example. We have partitioned 512 KB flash/96KB SRAM to:
Secure flash: 64KB
Non-secure flash: 448KB
Secure SRAM: 8KB
Non-secure SRAM: 88KB
For build for NUMAKER_PFM_M2351 secure target, we must have
mbed_app.json
:For build for NUMAKER_PFM_M2351 non-secure target, we must have
mbed_app.json
:Related PR
#6890
Pull request type