Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I get a HardFault, when I call a Non-Secure function (Nucleo L552ZE-Q)

Hello everyone,

I am currently working on an OS that currently doesn't support TrustZone, where I want to do one simple task: Jump to a non-secure function and immediatly return to the secure function.

I modified the function pointer to the ns_function according to this link and configured the SAU according to this page and used the -mcmse flag, TZEN is also set. However, I get a forced Hard Fault, when I try to execute the non-secure code. Why does that happen? Is there something else I have to take into account?

I've only worked once with the Nucleo L552ZE-Q, which was the only time I ever worked with TrustZone. Furthermore, I cannot use the STM32CubeIDE, since the project was not developed with it. Also, the code for secure and non-secure should be in the same binary.

I am using version 11.2.1 of the toolchain from arm.

Thank you very much for any tips you can give me.

Parents
  • What I mean is that I try to enable the OS to use TrustZone. Ans as stated above, I thought about the SAU and the call of the non-secure function (eventhough the NS and S function are in the same file, I call the NS-Function, as if it was in another file by using a function pointer. The LSB is also manipulated for the BLXNS jump into NS and the attribute cmse_nonsecure_call is used).

    Having everything above taken into account, what else could cause a HardFault, when I jump to a non-secure section? What else must I do to make this work?

Reply
  • What I mean is that I try to enable the OS to use TrustZone. Ans as stated above, I thought about the SAU and the call of the non-secure function (eventhough the NS and S function are in the same file, I call the NS-Function, as if it was in another file by using a function pointer. The LSB is also manipulated for the BLXNS jump into NS and the attribute cmse_nonsecure_call is used).

    Having everything above taken into account, what else could cause a HardFault, when I jump to a non-secure section? What else must I do to make this work?

Children