Skip to content

Conversation

djiatsaf-st
Copy link
Contributor

This pull request addresses multiple MPU-related faults observed during runtime tests on the STM32H7RSX
series by introducing the following changes:

  • Enable MPU regions for SRAM1 and SRAM2 access
  • Enables AHB2 peripheral clocks for SRAM1 and SRAM2
  • Configure SPECIAL_REGION to resolve access violation

Comment on lines 33 to 37
/* Region 4 */
MPU_REGION_ENTRY("SRAM_1", 0x30000000, REGION_RAM_ATTR(REGION_16K)),

/* Region 5 */
MPU_REGION_ENTRY("SRAM_2", 0x30004000, REGION_RAM_ATTR(REGION_16K)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make use of dt attribute zephyr,memory-attr instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done thanks

Comment on lines 1043 to 1050
#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_AHBSRAM1);
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_AHBSRAM2);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ideally depend on RAM activation via dts (activated by default but still)

Copy link
Contributor Author

@djiatsaf-st djiatsaf-st Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with DT macro

Comment on lines 26 to 27
/* Special region */
MPU_REGION_ENTRY("SPECIAL_REGION", 0x08fff000, REGION_FLASH_ATTR(REGION_4K)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be inside the XIP condition (this region can be accessed whatever the configuration used)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

…tion

Adds an MPU region named SPECIAL_REGION at address
0x08FFF800 with a size of 2 KB in Flash memory.

The region was previously unprotected, leading to an MPU fault when
accessed. By marking it as executable and readable with appropriate
flash memory attributes, the test now completes without triggering
a fault.

This change resolves a data Access Violation observed during
multiple tests, where the faulting address was 0x08FFF808.

Signed-off-by: Fabrice DJIATSA <[email protected]>
enables the AHB2 peripheral clocks for SRAM1 and SRAM2
on STM32H7RSX series using LL_AHB2_GRP1_EnableClock.

These clocks are required to access the corresponding SRAM regions
during runtime.

Fixes potential access faults when using SRAM1 and SRAM2.

Signed-off-by: Fabrice DJIATSA <[email protected]>
adds the `zephyr,memory-attr` property to the SRAM1 and SRAM2
memory nodes to explicitly define their MPU attributes as normal
RAM. This ensures proper memory protection and caching behavior
when these regions are used by the kernel or application.

Resolve a Data Access Violation encountered during
test, where the faulting address was 0x30000000.

Signed-off-by: Fabrice DJIATSA <[email protected]>
Copy link

compatible = "zephyr,memory-region", "mmio-sram";
reg = <0x30004000 DT_SIZE_K(16)>;
zephyr,memory-region = "SRAM2";
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR #97364 most likely gets a problem with adding the memory attribute to sram2, because the order of MPU region initialization (see arm_mpu.c):

  1. elements from mpu_regions.c
  2. entries from the device tree with zephyr,memory-attr property
  3. entries resulting from CONFIG_USERSPACE, CONFIG_NOCACHE_MEMORY etc
  4. dynamic entries

As later defined regions overlapping earlier ones have a higher priority (called region overlay), the ATTR_MPU_RAM from dt will overlay the REGION_RAM_NOCACHE_ATTR / REGION_PPB_ATTR from my PR's mpu_regions.c. Never tried to overlay a smaller region with a bigger one, so maybe this is even illegal? Anyway, I need to figure a way to define my DMA memory regions after it is configured as standard memory.

I see the point of this change (and use it in my custom boards dts for other mem nodes), but how can I solve this?

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.

4 participants