Forum Discussion
Hi,
The problem is caused by a bug in the hwlib library. When building with armclang (-O2), some inline assembler functions are omitted which results in wrong cache/mmu configuration.
As an example lets take a helper function from "alt_cache.c" file:
static __inline __attribute__((always_inline)) void sctlr_write_helper(uint32_t sctlr)
{
#if defined(__ARMCOMPILER_VERSION)
__asm("MCR p15, 0, %[sctlr], c1, c0, 0" : : [sctlr] "r" (sctlr));
#elif defined(__ARMCC_VERSION)
__asm("MCR p15, 0, sctlr, c1, c0, 0");
#else
__asm("MCR p15, 0, %0, c1, c0, 0" : : "r" (sctlr));
#endif
}
The armclang inline assembler requires the "volatile" keyword to be used like this:
static __inline __attribute__((always_inline)) void sctlr_write_helper(uint32_t sctlr)
{
#if defined(__ARMCOMPILER_VERSION)
__asm volatile ("MCR p15, 0, %[sctlr], c1, c0, 0" : : [sctlr] "r" (sctlr));
#elif defined(__ARMCC_VERSION)
__asm("MCR p15, 0, sctlr, c1, c0, 0");
#else
__asm("MCR p15, 0, %0, c1, c0, 0" : : "r" (sctlr));
#endif
}
Here is the link to the ARM documentation: