I have struggled for access the peripherals device under user/unprivileged mode for days.
When I switch the task (FreeRTOS's) to unprivileged mode(CONTROL.nPRIV=1), access/read the the uart/i2c will cause a hardfault and the CFSR shows it's a bus fault:
CFSR = 00008200
Bus fault: Precise Data Access (address in BFAR)
Bus fault: BFAR Has Valid Contents
BFAR= 40184000 (uart base address)
The same code could run normally under privileged mode(CONTROL.nPRIV=0).
I have already configure 0x40000000 ~ 0x5FFFFFFF could be accessed under unprivileged mode via MPU. ( If not will generate a MemManage fault, that's correct according to ARM design document)
I also try to modify CSU_CSLx register(Central Security Unit) during the code running, but no any improvement.
But when I modify those initial configures bits may cause the code get same fault even under privileged mode. That's also make me confusion.
Would you please give me a hand?