STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
fault.h File Reference

Fault driver: enable the configurable faults and record a fault for the debugger. More...

#include "scb_reg.h"
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for fault.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FaultRecord_t
 What Fault_Handler saw. More...

Typedefs

typedef struct FaultRecord_t FaultRecord_t
 What Fault_Handler saw.

Functions

void faultEnable (ScbRegisters_t *scb)
 Give MemManage, BusFault and UsageFault their own handlers, and trap integer division by zero.
void faultCapture (FaultRecord_t *record, const ScbRegisters_t *scb, const uint32_t *frame, uint32_t exc_return)
 Fill record from the fault status registers and the stacked frame.

Variables

FaultRecord_t faultRecord
 Filled by Fault_Handler; read it from the debugger.

Detailed Description

Fault driver: enable the configurable faults and record a fault for the debugger.

HardFault, MemManage, BusFault and UsageFault all enter Fault_Handler in the startup file. It passes the stacked frame to faultCapture(), which fills faultRecord, then spins. Nothing is returned to: a fault is fatal until the kernel has a policy for it. Halt the core and read the record:

faultEnable(SCB); // once, early in main()
// after a fault, in GDB:
// (gdb) p/x faultRecord
void faultEnable(ScbRegisters_t *scb)
Give MemManage, BusFault and UsageFault their own handlers, and trap integer division by zero.
Definition fault.c:14
#define SCB
The SCB instance.
Definition scb_reg.h:62

Without faultEnable(), MemManage, BusFault and UsageFault escalate to HardFault (HFSR.FORCED). CFSR still names the cause, so the record is just as useful; only the exception number differs.

Definition in file fault.h.