Hello,
I am using TrustZone together with Trusted Firmware-M and Zephyr on the AN521 board in QEMU. After setting SAU and MPC memory regions, during Zephyr setup, "cpsid i" is called using inline assembly. However, this call from non-secure code memory triggers a SecureFault with the Attribution unit violation flag, suggesting memory access to a secure address. I cannot understand how this instruction could cause the SecureFault and thus have no idea how to fix it. The SecureFault Address Register is set as valid and holds an address within the non-secure stack, which is part of the non-secure region defined by the SAU. Do you have any ideas or suggestions which might help me?
EDIT: The instruction was not the problem (see my response down below)
Martin
PM, bit [0]Exception mask register. Setting the Secure PRIMASK to one raises the execution priority to 0. Settingthe Non-secure PRIMASK to one raises the execution priority to 0 if AIRCR.PRIS is clear, or 0x80 ifAIRCR.PRIS is set.
Could it be, that an interrupt with priority < 0x80 is active?
Thanks for the tip! After checking that no interrupt was active, I added some dummy code in front of the SecureFault causing instruction and the Fault got triggered again. So, the problem is not with the instruction but with the changed stack pointer after the function call. Still weird but a different problem.
EDIT: Like always with these weird problems the solution was simple. I defined the wrong address in the config of my non-secure data. Written 0x3[...] instead of 0x2[...]. A small mistake with huge consequences
If the problem is solved then mark it as "answered"!