Skip to content
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

MPU API (Reopened) #8871

Merged
merged 23 commits into from Nov 28, 2018
Merged

MPU API (Reopened) #8871

merged 23 commits into from Nov 28, 2018

Conversation

cmonr
Copy link
Contributor

@cmonr cmonr commented Nov 26, 2018

Description

This PR is #8335, but reopened.

For some reason Travis CI tried to build the mpu branch in ARMmbed, which doesn't exist...

Pull request type

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

@cmonr
Copy link
Contributor Author

cmonr commented Nov 26, 2018

CI started.

Will clear out stale statuses in a bit.

@cmonr cmonr requested a review from a team November 27, 2018 04:01
@cmonr
Copy link
Contributor Author

cmonr commented Nov 27, 2018

Oddly incorrect status checks bypassed.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 27, 2018

Build failures:

04:25:42 [WIO_BG96:ARM] [Error] mbed_mpu_v7m.c@26,0: #35: #error directive: "Device has v7m MPU but it is not enabled. Add 'MPU' to device_has in targets.json"

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 27, 2018

I'll fetch this PR and try to fix it now

Add a minimalistic HAL MPU API with the ability to prevent execution
in ram.
Test that the MPU correctly stops execution of memory in the stack
region, heap region, data region and bss region. Also check that the
MPU can be enabled, disabled and freed.
Enable the MPU as part of the boot sequence and disable it before
starting a new application. Also add reference counted MPU lock and
unlock functions to allow code to execute from ram when necessary.
Add the class MpuXnLock which uses RAII  to allow execution from RAM
in a block of code.
Add a design document which covers the proposed implementation of
execute never.
When programming flash using the FlashIAP API allow execution from
ram. Many devices require flashing to be done from RAM.

Also allow execution from ram when running the low level flash tests.
Create a dedicated MPU directory for standard Arm MPU implementations
in preparation for the Arm v8m MPU. Replace MBED_MPU_ENABLED with
DEVICE_MPU to align with the porting layer of other HAL APIs.
Add MPU for devices which support the API in targets.json.
Add a driver for the v8m MPU.
Add a formal HAL specification consisting of:
-defined and undefined behavior
-test descriptions
-enable doxygen for MPU
Rename MpuXnLock  to ScopedMpuXnLock so it has the same naming
convention as ScopedMutexLock. Also make this class inherit from
NonCopyable to prevent misuse.
Make the following changes:
-Allow a vector specific ARM MPU driver by defining MBED_MPU_CUSTOM
-Allow ROM address to be configured for ARMv7-M devices by
    setting the define MBED_MPU_ROM_END
-Add ROM write protection
    -Add new functions and lock
    -enable at boot
    -disable during flash programming
Change ARMvXm to ARMvX-M in the design doc.
Ensure that code written to ram is flushed and that caches are cleared
before attempting to executing from ram. This fixes CI failures on the
MPU test when it is built for Cotex-M7 devices such as the
NUCLEO-F746ZG.
Change the variable names in FlashIAP from
'xn' to 'make_ram_executable' and from 'wn' to 'make_rom_writable' to
make the code more readable.
Hook both the HardFault and the MemManage IRQs since it is up to the
target to determine which fault is enabled.
For enhanced security ARMv8-M firmware doesn't allow the hardfault
handler to be hooked by non-secure code. Because of this there is no
way to recover from the MPU fault tests. This PR disables those tests
until hardfault recovery is supported by secure firmware.
Invert the name of the lock functions and classes so you are not
locking a negative.
Remove the design document since it is out of date and up to date
content is in the final docs.
c1728p9 and others added 3 commits November 27, 2018 09:29
Set a default value for MPU_ROM_END in target so this is defined for
all targets.
Run astyle to fix CI failures.
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 27, 2018

Rebased + address the build failures (new target support)

Restarting CI now

They should support MPU as they have all defined. Otherwise it fails to build
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 27, 2018

Two more targets needed fixing, did not spot them in the previous failures, restarting CI

@mbed-ci
Copy link

mbed-ci commented Nov 27, 2018

Test run: SUCCESS

Summary: 4 of 4 test jobs passed
Build number : 4
Build artifacts
Build logs

@cmonr cmonr added risk: A and removed risk: G labels Nov 27, 2018
@cmonr
Copy link
Contributor Author

cmonr commented Nov 28, 2018

Restarting export CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants