Code:
// Delete data from the cache, without touching memory
//
// Normally arm_dcache_delete() is used before receiving data via
// DMA or from bus-master peripherals which write to memory. You
// want to delete anything the cache may have stored, so your next
// read is certain to access the physical memory.
__attribute__((always_inline, unused))
static inline void arm_dcache_delete(void *addr, uint32_t size)
{
uint32_t location = [COLOR=#ff0000][B](uint32_t)addr & 0xFFFFFFE0;[/B][/COLOR]
uint32_t end_addr =[B] (uint32_t)addr + size;[/B]
asm volatile("": : :"memory");
asm("dsb");
do {
SCB_CACHE_DCIMVAC = location;
location += 32;
} while (location < end_addr);
asm("dsb");
asm("isb");
}
Had a crash.. and had to debug some code...
The marked red line leads to using a start adress that may be lower than the adress requested.
So, data got deleted, unintentionally, and my program crashed.
+ you should use the "&" for the end_addr, where it is missing..
Please fix that.
It's a killer for any mem that got allocated with malloc(), and kills the heap management.
Last edited: