Skip to content

Commit 5b83f5b

Browse files
committed
Enable D-Cache for Cortex-M7
Related to #485 Enable D-Cache for Cortex-M7 devices. * Enable the D-Cache in `src/modm/platform/core/cortex/startup.c.in` by adding `SCB_EnableDCache()` after `SCB_EnableICache()`. * Add a comment explaining the D-Cache enablement and the need for manual invalidation on certain operations. * Update the documentation in `docs/src/reference/build-systems.md` to reflect the D-Cache enablement for Cortex-M7 devices. * Add a note in the documentation about the need for manual invalidation on certain operations.
1 parent a90537c commit 5b83f5b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

docs/src/reference/build-systems.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,8 @@ This can be significantly easier than manually editing the generated build
8787
scripts, and is also persistent across library regeneration.
8888
Please see the [`modm:build` documentation](../module/modm-build/#collectors)
8989
for the available collectors and their inputs.
90+
91+
## Cortex-M7 D-Cache Enablement
92+
93+
For Cortex-M7 devices, the D-Cache is now enabled by default with a write-through policy. This change improves performance by caching data reads and writes. However, it is important to note that manual invalidation of the D-Cache is required on certain operations, such as writing to Flash. Users can still enable the write-back policy in `main()` if required.
94+

src/modm/platform/core/cortex/startup.c.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void __modm_startup(void)
100100
%% if "m7" in core
101101
// Enable instruction cache
102102
SCB_EnableICache();
103+
// Enable data cache with write-through policy
104+
SCB_EnableDCache();
103105
%% endif
104106

105107
%% if core != "cortex-m0"

0 commit comments

Comments
 (0)