I am running into similar program crash issues as Thomas experienced in THIS THREAD, but unfortunately, I have not been able to fix the problem by commenting out the MMU enable bit. Can someone provide some guidance on how to properly enable the I and D caches on the ARM?
Here is the code that I stole from the other thread. I call it just after enabling privileged mode.
CP15_CTL_MMU_ENABLE .equ 0x0001
CP15_CTL_ALIGN_FAULT_ENABLE .equ 0x0002
CP15_CTL_INST_CACHE_ENABLE .equ 0x0004
CP15_CTL_DATA_CACHE_ENABLE .equ 0x1000
;__CACHE_enable .long CACHE_enable
.global CACHE_enable
CACHE_enable:.asmfunc
mov r0, #0
mrc p15, #0, r0, c1, c0, #0
; orr r0, r0, #CP15_CTL_MMU_ENABLE
orr r0, r0, #CP15_CTL_ALIGN_FAULT_ENABLE
orr r0, r0, #CP15_CTL_INST_CACHE_ENABLE
orr r0, r0, #CP15_CTL_DATA_CACHE_ENABLE
mcr p15, #0, r0, c1, c0, #0
mov r0, r0
mov r0, r0
mov r0, r0
mov r0, r0
mov r0, r0
.endasmfunc
If i leave MMU enabled, the program crashes in an ugly way (memory trashed and must reload program). If I disable MMU the program executes the code above the loops back to the beginning of main.c and starts over.
I appreciate your thoughts and help on this.
Thx,
MikeH