Hi,
I'm writing bare metal A15 application.
I've been trying to implement exclusive DDR memory access to implement a ring buffer that could be written in the main loop and in the interrupt. I can't disable the interrupt. All the accesses to that memory are from single A15 core.
I'm using following functions to load and store value, and to check if the access was not exclusive:
// Exclusive load uint32_t LDREX(volatile uint32_t *addr) { uint32_t res; asm volatile( " ldrex %0, [%1]\n" " bx lr" : "=&r" (res) /* %0 put output to res. Don't overlap the register with the register used for variable addr */ : "r" (addr)); /* %1 use addr as pointer*/ return res; } // store value exclusively to the given address. // return 0 if success uint32_t STREX(uint32_t value, uint32_t *addr) { uint32_t res=0; asm volatile ("strex %0, %2, [%1]" : "=&r" (res) : "r" (addr), "r" (value) ); return res; }
However. The first call to LDREX causes the Abort exception. I have tried different MMU settings: non shareable, shareable inner and shareable outer, but non of them does the trick.
What could be the reason for that?
Is there some other, recommended and implemented way to implement such exclusivity check on A15?