Oyvind,

Thanks for putting this together. Looks quite useful, and saves some monotony debugging.

I put together a similar script but as a Python function for GDB: https://gist.github.com/microbuilder/1677a27e4566a28b36a79f954f1dede6 ... having this in C, however, means you don't need to have a Python-enabled version of GDB.

Best regards,
Kevin

On Fri, 29 Jan 2021 at 11:33, Rønningstad, Øyvind via TF-M <tf-m@lists.trustedfirmware.org> wrote:

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

--
TF-M mailing list
TF-M@lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/tf-m