Skip to content

Commit b1b2bb5

Browse files
committed
Short-circuit dcache disable
Do not attempt to clean and invalidate the DCache if SCB_DisableDCache is invoked when it was not enabled in the first place. This prevents landing junk into RAM after a POR.
1 parent f622607 commit b1b2bb5

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

CMSIS/Core/Include/core_starmc1.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,6 +3326,11 @@ __STATIC_FORCEINLINE void SCB_DisableDCache (void)
33263326
uint32_t sets;
33273327
uint32_t ways;
33283328

3329+
/* Return if D-cache is not enabled (prevent flushing junk after POR) */
3330+
if ((SCB->CCR & SCB_CCR_DC_Msk) == 0U) {
3331+
return;
3332+
}
3333+
33293334
SCB->CSSELR = 0U; /* select Level 1 data cache */
33303335
__DSB();
33313336

CMSIS/Core/Include/m-profile/armv7m_cachel1.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ __STATIC_FORCEINLINE void SCB_DisableDCache (void)
189189
#endif
190190
;
191191

192+
/* Return if D-cache is not enabled (prevent flushing junk after POR) */
193+
if ((SCB->CCR & SCB_CCR_DC_Msk) == 0U) {
194+
return;
195+
}
196+
192197
SCB->CSSELR = 0U; /* select Level 1 data cache */
193198
__DSB();
194199

0 commit comments

Comments
 (0)