Hi everyone

I wanted to make it easier to debug HardFaults/BusFaults/SecureFaults in TFM, since I’ve gotten quite a few of them while adding the nrf platforms.

I have created a proposal in https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/7891 and would like to get some comments on the general idea.

The proposal gathers a number of different values, especially the ones that are harder to retrieve in a debugger, like the fault status registers in SCB.

The values are placed in memory so they can be inspected in a debugger, and if built with -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_DEBUG they are also printed.

Here is an example of the printout:

FATAL ERROR: HardFault

Here is some context for the exception:

    EXC_RETURN (LR): 0xFFFFFFBD

    Exception came from non-secure FW in thread mode.

    MSP(_S):  0x200007F8

    PSP(_S):  0x20000F28

    Exception frame at: 0x200176D8

        R0:  0x0000003E

        R1:  0x00000001

        R2:  0x00000001

        R3:  0xFFFFFFFF

        R12: 0x00000000

        LR:  0x00050623

        PC:  0x00050626

    CFSR: 0x00000000

    BFAR: Not Valid

    MMFAR: Not Valid

    HFSR: 0x40000000

    SFSR: 0x00000000

    SFAR: Not Valid

 

BR, Øyvind Rønningstad