When i call the custom-code certify() function inside my code in a secure partition i can build the programm, but after clicking flash/running the secure uart-output prints "FATAL ERROR: SecureFault". My program in the non-secure world and in the secure world doesn't seem to run at all as nothing else beside the error is output to the terminal, so the error doesn't occur at runtime when calling certify().
When i outcomment just the line calling certify() the programm works again without problems.
The certify() function is from existing code already used on another platform and i also previously called it inside the secure partition in an earlier version of the code, so it itself shouldn't cause the problem (especially as it isn't a runtime fault when the function executes, but rather already before any code even in the non-secure world executes). (I also already call another function from the same existing code which works.)
What could be the cause of the error?
(Maybe the problem is related to memory use or sth like that?
My programm uses the heap in the secure partition (see this thread for more info: https://devzone.nordicsemi.com/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm). The heap is used whether certify() is called or not, but certify() uses it more extensively. On the other hand i already increased the heap-limit to what should be more than enough and certify() doesn't even actually execute, so i don't know if that's really related.)
Heres the full output of the secure-world-uart when flashing as additional context(the non-secure world doesn't output anything):
[Sec Thread] Secure image initializing! TF-M isolation level is: 0x00000001 Booting TF-M v2.0.0 FATAL ERROR: SecureFault Here is some context for the exception: EXC_RETURN (LR): 0xFFFFFFBD Exception came from non-secure FW in thread mode. xPSR: 0x00000007 MSP: 0x200033F8 PSP: 0x2000A9A8 MSP_NS: 0x2001B940 PSP_NS: 0x2001B730 Exception frame at: 0x2001B730 R0: 0x40000105 [Sec Thread] Secure image initializing! TF-M isolation level is: 0x00000001 Booting TF-M v2.0.0 Creating an empty ITS flash layout. FATAL ERROR: SecureFault Here is some context for the exception: EXC_RETURN (LR): 0xFFFFFFBD Exception came from non-secure FW in thread mode. xPSR: 0x00000007 MSP: 0x200033F8 PSP: 0x2000A9A8 MSP_NS: 0x2001B940 PSP_NS: 0x2001B730 Exception frame at: 0x2001B730 R0: 0x40000105 R1: 0x020103F5 R2: 0x2001B80C R3: 0x2001B838 R12: 0x020003F5 LR: 0x00052DF1 PC: 0x0001FC20 xPSR: 0x01000000 Callee saved register state: R4: 0x0001FC21 R5: 0x020103F5 R6: 0x2001B80C R7: 0x00000000 R8: 0x40000105 R9: 0x00051104 R10: 0x00051104 R11: 0x00051104 CFSR: 0x00000000 BFSR: 0x00000000 BFAR: Not Valid MMFSR: 0x00000000 MMFAR: Not Valid UFSR: 0x00000000 HFSR: 0x00000000 SFSR: 0x00000001 SFAR: Not Valid
Regards