Skip to content

Conversation

@djiatsaf-st
Copy link
Contributor

@djiatsaf-st djiatsaf-st commented Oct 16, 2025

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To prevent conflicts with Ethernet support, an overlay was added on the driver test side that explicitly sets the zephyr,memory-attr property to DT_MEM_ARM(ATTR_MPU_RAM).

Changes was only required for testing purpose.

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]>
@zephyrbot zephyrbot added area: MEMC area: Tests Issues related to a particular existing or missing test labels Oct 20, 2025
@zephyrbot zephyrbot requested a review from nashif October 20, 2025 12:51
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
};

/* System data RAM accessible over AHB bus: SRAM2 in D2 domain */
Copy link
Contributor

Choose a reason for hiding this comment

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

Make SRAM2 status = "disabled"; by default and add comment that zephyr,memory-attr must be added explicitly for the SRAM to be accessible.

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

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.

Note: add the zephyr,memory-attr property in the board overlay for SRAM2
to avoid conflict with the support of h7rs ethernet with MPU regions
enabled.
see link below for more details :
https://github.com/zephyrproject-rtos/zephyr/pull/97364/files#r2439668915

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

reg = <0x30000000 DT_SIZE_K(16)>;
compatible = "zephyr,memory-region", "mmio-sram";
zephyr,memory-region = "SRAM1";
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.

Should sram1 mapping attributes also be set by the system overlay, or at least the board?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I previously did that https://github.com/zephyrproject-rtos/zephyr/pull/97731#discussion_r2436709223 but is better to do it this way unless there is a conflict, such as with SRAM2

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Approved, but please update PR description:
Configure SPECIAL_REGION to resolve access violation doesn't apply anymore

@cfriedt cfriedt merged commit be071fa into zephyrproject-rtos:main Oct 22, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: Clock Control area: MEMC area: Tests Issues related to a particular existing or missing test platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants