arch/arm/stm32h5: Add MPU support - #20122
Open
darrylring wants to merge 3 commits into
Open
Conversation
|
This adds MPU initialization code based on the STM32U5. Unlike the STM32U5 code, though, this allows the MPU to be used outside of PROTECTED build mode. PROTECTED build mode is still not yet supported. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Darryl Ring <darryl@bluerobotics.com>
If CONFIG_ARM_MPU and CONFIG_STM32_ICACHE are set, this will configure an MPU region marking the OTP flash as non-cacheable. This prevents hard faults when accessing the 4K OTP region from software. Signed-off-by: Darryl Ring <darryl@bluerobotics.ca>
darrylring
force-pushed
the
feature/stm32h5-mpu
branch
from
September 11, 2026 23:52
13ff421 to
47c7ac8
Compare
acassis
requested review from
JorgeGzm,
cederom,
linguini1,
raiden00pl and
xiaoxiang781216
September 12, 2026 21:33
acassis
previously approved these changes
Sep 12, 2026
| #include "mpu.h" | ||
| #include "stm32_mpuinit.h" | ||
|
|
||
| #ifdef CONFIG_ARM_MPU |
Contributor
There was a problem hiding this comment.
@darrylring the Make.defs and CMakefile.txt already prevents the file to be compiled if CONFIG_ARM_MPU is not enabled. In the past Greg used to add this double check, but it is not necessary
The compilation of stm32_mpuinit.c is guarded by CMakeLists.txt and Make.defs, so this is unneccessary. Signed-off-by: Darryl Ring <darryl@bluerobotics.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds basic MPU support for the STM32H5 based on the initialization in the STM32U5 (same core).
The STM32H5 has a couple issues ("features") related to the OTP flash region:
NOTE: This does not enable protected mode builds (
CONFIG_BUILD_PROTECTED) at this time. I don't currently understand that portion of the codebase enough (yet) to attempt that.Impact
No impact, since MPU support is currently not implemented.
Testing
I added code to the NUCLEO-H563ZI board to configure an MPU region over the OTP flash in the case that
CONFIG_ARM_MPUandCONFIG_STM32_ICACHEare enabled. I have not added these to anydefconfig, though.Before, with
CONFIG_STM32_ICACHEdisabled:Before, with
CONFIG_STM32_ICACHEenabled:After, with
CONFIG_ARM_MPUandCONFIG_STM32_ICACHEenabled: