From f63b67211b808fa370c51f3ab8eb201b64d3d1d2 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 26 Nov 2025 16:15:12 +0700 Subject: [PATCH] dwc2 stm32 check if dcache enabled before calling SCB DCache function --- src/portable/synopsys/dwc2/dwc2_stm32.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/portable/synopsys/dwc2/dwc2_stm32.h b/src/portable/synopsys/dwc2/dwc2_stm32.h index 9da8de41f..516eb021b 100644 --- a/src/portable/synopsys/dwc2/dwc2_stm32.h +++ b/src/portable/synopsys/dwc2/dwc2_stm32.h @@ -337,6 +337,9 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t round_up_to_cache_line_size(uint32_ } TU_ATTR_ALWAYS_INLINE static inline bool is_cache_mem(uintptr_t addr) { + if (0 == (SCB->CCR & SCB_CCR_DC_Msk)) { + return false; // D-Cache is disabled + } for (unsigned int i = 0; i < TU_ARRAY_SIZE(uncached_regions); i++) { if (uncached_regions[i].start <= addr && addr <= uncached_regions[i].end) { return false; } }