Thanks for that. I tried putting the code there into my project. I'm not the best with assembly language, but I think I included it right. However, the assembler didn't like the line:
dcache_line_size r2, r3
From googling, it appears that this is intended to call a function to get the "data cache line size". I found a couple of such functions, in assembly language, but couldn't get them working - perhaps they were for a different architecture.
Do we already know the "data cache line size"? Could I just hard-code a value?