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
Reduce ROM impact of MPU code #9030
Conversation
Save around 400 bytes from images using FlashIAP by omitting MPU manager reference counting if DEVICE_MPU is 0.
We can omit the need for the "change MPU state" calls from simple images by specifying the initial state at init.
MPU lock under- or overflow is not a likely random runtime failure - it will be a mismatched lock/unlock programming error, so should be detected during development. Make the checks asserts so they can be left out from release builds. MBED_ASSERT is also a bit smaller than MBED_ERROR in develop builds.
What are the final numbers for all the cases you describe savings for? (On "random" platform) |
Enabling standard ARMv7M Using the scoped locks, as FlashIAP does, pulls in another 451 bytes in a develop build (including the asserts), making a total of 659 bytes of MPU code, plus 4 bytes of RAM. Plus there will be extra code in the callsites. All MPU-related code is fully eliminated if |
659 is a lot still, client guys won't be happy. |
@bulislaw So do we want to take this to RC3 or not ? |
@adbridge you'll want this PR either way. A separate PR will be needed to turn off the MPU by default if this is too much rom for client. |
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.
@c1728p9 can we make sure docs are clear on how to disable it, also could we send an email to @JanneKiiskila and @yogpan01 to warn them it's coming.
CI started |
Thanks for pushing this one in, I'm very not eager to disable MPU by default as it would really hurt our security promise - however if footprint is an issue I'm happy to discuss it further |
@kjbracey-arm If you're around, this is about to fail CI with build errors. |
Test run: FAILEDSummary: 3 of 7 test jobs failed Failed test jobs:
|
Add the header platform/mbed_assert.h to fix build errors with platform/mbed_mpu_mgmt.c.
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
@bulislaw I created #9040 which adds a platform config option to turn off the MPU. Prior to this it had to be turned off either at runtime or by removing device_has from the current target. I added docs for this config in ARMmbed/mbed-os-5-docs#868. |
Description
Saves 400+ bytes from an image using FlashIAP with
DEVICE_MPU
disabled - the MPU management code is totally eliminated.Saves around 100 bytes from develop images using FlashIAP with
DEVICE_MPU
enabled - asserts are smaller than errors. Saves more from release builds by omitting the asserts.Saves around 90 bytes from images not manipulating the MPU with
DEVICE_MPU
enabled - don't need to always include thembed_mpu_enable_ram_xn
andmbed_mpu_enable_rom_wn
calls.Fixes #9007.
Pull request type