embedded
runtime_error
ai_generated
true
DMA transfer returns stale data from cache
ID: embedded/dma-buffer-cache-coherency
80%Fix Rate
82%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
DMA reads memory directly but CPU cache holds different data, causing coherency issues.
genericWorkarounds
-
88% success Place DMA buffers in non-cacheable MPU region
Configure MPU region as Device or Non-cacheable for DMA buffers
-
85% success Invalidate/clean D-cache before/after DMA transfers
SCB_InvalidateDCache_by_Addr(buf,size) after DMA RX complete
Dead Ends
Common approaches that don't work:
-
Disable all caching
85% fail
Destroys performance; D-cache provides 2-10x speedup.
-
Use volatile keyword on DMA buffers
90% fail
volatile only prevents compiler optimization, not hardware cache.