CMSIS-View  
Record program events, display status information, and analyze execution faults
 
Loading...
Searching...
No Matches
Fault Storage

Functions that store the Cortex-M Exception Fault information into memory. More...

Content

 Macros
 Fault Storage macro definitions.
 

Data Structures

struct  ARM_FaultInfo_t
 Fault information structure type definition. More...
 
struct  ARM_FaultInfo_t.Version
 
struct  ARM_FaultInfo_t.Content
 
struct  ARM_FaultInfo_t.Registers
 
struct  ARM_FaultInfo_t.ExceptionState
 
struct  ARM_FaultInfo_t.FaultRegisters
 

Functions

void ARM_FaultClear (void)
 Clear the saved fault information.
 
uint32_t ARM_FaultOccurred (void)
 Check if the fault occurred and if the fault information was saved properly.
 
void ARM_FaultSave (void)
 Save the fault information.
 
void ARM_FaultExit (void)
 Callback function called after fault information was saved.
 
void ARM_FaultPrint (void)
 Output decoded fault information via STDIO.
 

Variables

ARM_FaultInfo_t ARM_FaultInfo
 Fault Information.
 
const char ARM_FaultVersion []
 Fault component version information.
 

Description

Functions that store the Cortex-M Exception Fault information into memory.

For an overview see Exception Fault Analysis.

This section contains the functions of the component CMSIS-View:Fault:Storage that store the Cortex-M Exception Fault information in uninitialized RAM memory and auxiliary functions.


Data Structure Documentation

◆ ARM_FaultInfo_t

struct ARM_FaultInfo_t

Fault information structure type definition.

Structure for storing fault information. Exposed via ARM_FaultInfo.

Data Fields
uint32_t MagicNumber Magic number (ASCII "FltR")
uint32_t CRC32 CRC32 of the structure content (excluding MagicNumber and CRC32 fields)
uint32_t Count Saved faults counter.
struct ARM_FaultInfo_t.Version Version
struct ARM_FaultInfo_t.Content Content
struct ARM_FaultInfo_t.Registers Registers
struct ARM_FaultInfo_t.ExceptionState ExceptionState
struct ARM_FaultInfo_t.FaultRegisters FaultRegisters

◆ ARM_FaultInfo_t.Version

struct ARM_FaultInfo_t.Version
Data Fields
uint8_t Minor Fault information structure version: Minor, see ARM_FAULT_FAULT_INFO_VER_MINOR.
uint8_t Major Fault information structure version: Major, see ARM_FAULT_FAULT_INFO_VER_MAJOR.

◆ ARM_FaultInfo_t.Content

struct ARM_FaultInfo_t.Content
Data Fields
uint16_t FaultRegsExist: 1 Fault registers: 0 - absent; 1 - available.
uint16_t Armv8xM_Main: 1 Armv8/8.1-M Mainline information: 0 - absent; 1 - available.
uint16_t TZ_Enabled: 1 TrustZone (Cortex-M security extensions): 0 - not enabled; 1 - enabled.
uint16_t TZ_SaveMode: 1 Fault information was saved in: 0 - TrustZone-disabled or non-secure mode; 1 - secure mode.
uint16_t TZ_FaultMode: 1 Fault happened in: 0 - TrustZone-disabled or non-secure mode; 1 - secure mode.
uint16_t StateContext: 1 State Context: 0 - was not saved; 1 - was saved.
uint16_t AdditionalContext: 1 Additional State Context: 0 - was not saved; 1 - was saved.
uint16_t LimitRegs: 1 MSPLIM and PSPLIM: 0 - were not saved; 1 - were saved.
uint16_t FaultRegs: 1 Fault registers: 0 - were not saved; 1 - were saved.
uint16_t SecureFaultRegs: 1 Secure Fault registers: 0 - were not saved; 1 - were saved.
uint16_t RAS_FaultReg: 1 RAS Fault register: 0 - was not saved; 1 - was saved.
uint16_t Reserved: 5 Reserved (0)

◆ ARM_FaultInfo_t.Registers

struct ARM_FaultInfo_t.Registers
Data Fields
uint32_t R0 R0 Register value.
uint32_t R1 R1 Register value.
uint32_t R2 R2 Register value.
uint32_t R3 R3 Register value.
uint32_t R4 R4 Register value.
uint32_t R5 R5 Register value.
uint32_t R6 R6 Register value.
uint32_t R7 R7 Register value.
uint32_t R8 R8 Register value.
uint32_t R9 R9 Register value.
uint32_t R10 R10 Register value.
uint32_t R11 R11 Register value.
uint32_t R12 R12 Register value.
uint32_t LR Link Register (R14) value.
uint32_t ReturnAddress Return address from exception.
uint32_t xPSR Program Status Register value.
uint32_t MSP Main Stack Pointer value.
uint32_t PSP Process Stack Pointer value.
uint32_t MSPLIM Main Stack Pointer Limit Register value (only for Armv8/8.1-M arch)
uint32_t PSPLIM Process Stack Pointer Limit Register value (only for Armv8/8.1-M arch)

◆ ARM_FaultInfo_t.ExceptionState

struct ARM_FaultInfo_t.ExceptionState
Data Fields
uint32_t xPSR Program Status Register value, in exception handler.
uint32_t EXC_RETURN Exception Return code (LR), in exception handler.

◆ ARM_FaultInfo_t.FaultRegisters

struct ARM_FaultInfo_t.FaultRegisters
Data Fields
uint32_t CFSR System Control Block - Configurable Fault Status Register value.
uint32_t HFSR System Control Block - HardFault Status Register value.
uint32_t DFSR System Control Block - Debug Fault Status Register value.
uint32_t MMFAR System Control Block - MemManage Fault Address Register value.
uint32_t BFAR System Control Block - BusFault Address Register value.
uint32_t AFSR System Control Block - Auxiliary Fault Status Register value.
uint32_t SFSR System Control Block - Secure Fault Status Register value.
uint32_t SFAR System Control Block - Secure Fault Address Register value.
uint32_t RFSR System Control Block - RAS Fault Status Register value.

Function Documentation

◆ ARM_FaultClear()

ARM_FaultClear ( void  )

Clear the saved fault information.

Code Example

#include "ARM_Fault.h"
int main (void) {
ARM_FaultClear(); // Clear fault information
// ...
}

◆ ARM_FaultOccurred()

ARM_FaultOccurred ( void  )

Check if the fault occurred and if the fault information was saved properly.

Returns
status (1 = fault occurred and valid fault information exists, 0 = no fault information saved yet or fault information is invalid)

Call during startup to check if a fault occurred and if fault information is available, for example decode the fault information using ARM_FaultPrint or ARM_FaultRecord functions.

Code Example

#include "EventRecorder.h"
#include "ARM_Fault.h"
int main() {
EventRecorderInitialize (EventRecordAll, 1U); // Initialize and start Event Recorder
if (ARM_FaultOccurred() != 0U) { // If fault information exists
ARM_FaultPrint(); // Output decoded fault information via STDIO
ARM_FaultRecord(); // Output decoded fault information via Event Recorder
EventRecorderStop(); // Stop Event Recorder
}
// ...
}

◆ ARM_FaultSave()

ARM_FaultSave ( void  )

Save the fault information.

Call from a fault handler to save current fault information into uninitialized RAM memory.

Make sure that function is called without changing the Stack Pointer (SP) and Link Register (LR) registers. This is usually done by branching directly to this function from the fault handler.

This function does not use stack or heap memories.

Code Example

#include "ARM_Fault.h"
__attribute__((naked)) void HardFault_Handler (void) {
__ASM volatile (
"b ARM_FaultSave\n"
);
}
__attribute__((naked)) void MemManage_Handler (void) {
__ASM volatile (
"b ARM_FaultSave\n"
);
}
__attribute__((naked)) void BusFault_Handler (void) {
__ASM volatile (
"b ARM_FaultSave\n"
);
}
__attribute__((naked)) void UsageFault_Handler (void) {
__ASM volatile (
"b ARM_FaultSave\n"
);
}

◆ ARM_FaultExit()

ARM_FaultExit ( void  )

Callback function called after fault information was saved.

The default implementation will do a system reset.

If a system reset is not desired, you need to provide a custom implementation of this function with the desired functionality.

Code Example of overriding ARM_FaultExit function not to reset the system but to loop endlessly:

#include "ARM_Fault.h"
__attribute__((naked)) void ARM_FaultExit (void) {
__ASM volatile (
"b .\n"
);
}

◆ ARM_FaultPrint()

ARM_FaultPrint ( void  )

Output decoded fault information via STDIO.

To use ARM_FaultPrint, add the ARM_FaultPrint template implementation to the project.

Code Example

#include <stdio.h>
#include "ARM_Fault.h"
int main() {
if (ARM_FaultOccurred() != 0U) { // If fault information exists
ARM_FaultPrint(); // Output decoded fault information via STDIO
}
// ...
}

Variable Documentation

◆ ARM_FaultInfo

ARM_FaultInfo_t ARM_FaultInfo

Fault Information.

Variable for storing fault information.

◆ ARM_FaultVersion

const char ARM_FaultVersion[]

Fault component version information.

Variable for storing Arm Fault component version.