Switching back to the "Secure world" TrustZone (lpcxpresso55s69)

cancel
Showing results for 
Search instead for 
Did you mean: 

Switching back to the "Secure world" TrustZone (lpcxpresso55s69)

248 Views
Contributor III
When using the security extension supported by the ARMv8-M, It is cited that when switching from a secure to a non-secure world, a call to a non secure world is conducted. It is noted that the comeback to the secure world is done automatically as quoted:
"During the state transition, the return address and some processor state information are pushed onto the Secure stack, while the return address on the Link Register (LR) is set to a special value called FNC_RETURN. The Least Significant Bit (LSB) of the
function address must be 0"  
Using the "Hello_world" example provided in the MCUXpresso IDE (also shown in this blog ), I added a PRINTF("Comeback to the secure world again"); expecting that it will be printed in the console. However, no thing happened. 
I added a break-point but it was not seen, this could mean that there where no switch back to the secure world. 
pastedImage_4.png
Is there a missing step that I should have included? Does it has to do with the Secure stack?  
Labels (1)
1 Reply

13 Views
NXP TechSupport
NXP TechSupport

Hello Randa,

Your PRINTF after the ResetHandler_ns will not be executed. This is because the hello world example was not created to return to the secure world. You can check this by looking at the main function in the nonsecure world, it simply goes into an infinite loop.

The section of the document you are refering to, explains the procedure for calling of functions. In this example we can see that the non_secure world makes use of the PRINTF even if its declared in the secure world. This is because it was created as a secure entry point. In the non_secure world it uses PRINTF_NSE, but if you check its declaration in the veneer table you can see that it is using the PRINTF.

pastedImage_1.png

There is not an example made that jumps back and forth between sections of the code as you have described above. Instead the examples show, how to call functions between worlds. I recommend to check the example called "secure_fault_ns/s" this is based on the hello world example but you can see the different manners that a fault can occur in the secure world.

Keep in mind, restrictions are imposed for Non-secure to Secure transitions to ensure that only valid Secure API entry points can be used for calling from the Normal world to Secure code, or when the transition is caused by returning from a Non-secure API back to Secure code.You can check more information in Chapter 47.

Best Regards,

Sabina