PX4 Firmware
PX4 Autopilot Software http://px4.io
hardfault_log.h File Reference
#include <px4_platform_common/px4_config.h>
#include <systemlib/px4_macros.h>
Include dependency graph for hardfault_log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _stack_s
 
struct  stack_t
 
struct  proc_regs_s
 
struct  info_s
 
struct  fullcontext_s
 

Macros

#define HARDFAULT_REBOOT_FILENO   0
 
#define HARDFAULT_REBOOT_PATH   BBSRAM_PATH "" STRINGIFY(HARDFAULT_REBOOT_FILENO)
 
#define HARDFAULT_ULOG_FILENO   3
 
#define HARDFAULT_ULOG_PATH   BBSRAM_PATH "" STRINGIFY(HARDFAULT_ULOG_FILENO)
 
#define HARDFAULT_FILENO   4
 
#define HARDFAULT_PATH   BBSRAM_PATH "" STRINGIFY(HARDFAULT_FILENO)
 
#define HARDFAULT_MAX_ULOG_FILE_LEN   64 /* must be large enough to store the full path to the log file */
 
#define BBSRAM_SIZE_FN0   (sizeof(int))
 
#define BBSRAM_SIZE_FN1   384 /* greater then 2.5 times the size of vehicle_status_s */
 
#define BBSRAM_SIZE_FN2   384 /* greater then 2.5 times the size of vehicle_status_s */
 
#define BBSRAM_SIZE_FN3   HARDFAULT_MAX_ULOG_FILE_LEN
 
#define BBSRAM_SIZE_FN4   -1
 
#define BBSRAM_HEADER_SIZE   20 /* This is an assumption */
 
#define BBSRAM_USED   ((5*BBSRAM_HEADER_SIZE)+(BBSRAM_SIZE_FN0+BBSRAM_SIZE_FN1+BBSRAM_SIZE_FN2+BBSRAM_SIZE_FN3))
 
#define BBSRAM_REAMINING   (PX4_BBSRAM_SIZE-BBSRAM_USED)
 
#define BBSRAM_NUMBER_STACKS   1
 
#define BBSRAM_FIXED_ELEMENTS_SIZE   (sizeof(info_s))
 
#define BBSRAM_LEFTOVER   (BBSRAM_REAMINING-BBSRAM_FIXED_ELEMENTS_SIZE)
 
#define CONFIG_ISTACK_SIZE   (BBSRAM_LEFTOVER/BBSRAM_NUMBER_STACKS/sizeof(stack_word_t))
 
#define CONFIG_USTACK_SIZE   (BBSRAM_LEFTOVER/BBSRAM_NUMBER_STACKS/sizeof(stack_word_t))
 
#define BBSRAM_PATH   "/fs/bbr"
 
#define BSRAM_FILE_SIZES
 
#define MAX_FILE_PATH_LENGTH   40
 
#define LOG_PATH_BASE   "/fs/microsd/"
 
#define LOG_PATH_BASE_LEN   ((arraySize(LOG_PATH_BASE))-1)
 
#define LOG_NAME_FMT   "fault_%s.log"
 
#define LOG_NAME_NUM   ( -2 )
 
#define LOG_NAME_LEN   ((arraySize(LOG_NAME_FMT)-1) + LOG_NAME_NUM)
 
#define TIME_FMT   "%Y_%m_%d_%H_%M_%S"
 
#define TIME_FMT_NUM   (2+ 0+ 0+ 0+ 0+ 0)
 
#define TIME_FMT_LEN   (((arraySize(TIME_FMT)-1) + TIME_FMT_NUM))
 
#define LOG_PATH_LEN   ((LOG_PATH_BASE_LEN + LOG_NAME_LEN + TIME_FMT_LEN))
 
#define HEADER_TIME_FMT   "%Y-%m-%d-%H:%M:%S"
 
#define HEADER_TIME_FMT_NUM   (2+ 0+ 0+ 0+ 0+ 0)
 
#define HEADER_TIME_FMT_LEN   (((arraySize(HEADER_TIME_FMT)-1) + HEADER_TIME_FMT_NUM))
 
#define HARDFAULT_DISPLAY_FORMAT   1
 
#define HARDFAULT_FILE_FORMAT   0
 

Typedefs

typedef uint32_t stack_word_t
 

Enumerations

enum  fault_flags_t {
  eRegsPresent = 0x01, eUserStackPresent = 0x02, eIntStackPresent = 0x04, eInvalidUserStackPtr = 0x20,
  eInvalidIntStackPrt = 0x40
}
 

Functions

__BEGIN_DECLS int hardfault_check_status (char *caller) weak_function
 
int hardfault_write (char *caller, int fd, int format, bool rearm) weak_function
 
int hardfault_rearm (char *caller) weak_function
 
int hardfault_increment_reboot (char *caller, bool reset) weak_function
 

Macro Definition Documentation

◆ BBSRAM_FIXED_ELEMENTS_SIZE

#define BBSRAM_FIXED_ELEMENTS_SIZE   (sizeof(info_s))

Definition at line 72 of file hardfault_log.h.

◆ BBSRAM_HEADER_SIZE

#define BBSRAM_HEADER_SIZE   20 /* This is an assumption */

Definition at line 64 of file hardfault_log.h.

◆ BBSRAM_LEFTOVER

#define BBSRAM_LEFTOVER   (BBSRAM_REAMINING-BBSRAM_FIXED_ELEMENTS_SIZE)

Definition at line 73 of file hardfault_log.h.

◆ BBSRAM_NUMBER_STACKS

#define BBSRAM_NUMBER_STACKS   1

Definition at line 68 of file hardfault_log.h.

◆ BBSRAM_PATH

#define BBSRAM_PATH   "/fs/bbr"

Definition at line 79 of file hardfault_log.h.

◆ BBSRAM_REAMINING

#define BBSRAM_REAMINING   (PX4_BBSRAM_SIZE-BBSRAM_USED)

Definition at line 66 of file hardfault_log.h.

◆ BBSRAM_SIZE_FN0

#define BBSRAM_SIZE_FN0   (sizeof(int))

Definition at line 53 of file hardfault_log.h.

◆ BBSRAM_SIZE_FN1

#define BBSRAM_SIZE_FN1   384 /* greater then 2.5 times the size of vehicle_status_s */

Definition at line 54 of file hardfault_log.h.

◆ BBSRAM_SIZE_FN2

#define BBSRAM_SIZE_FN2   384 /* greater then 2.5 times the size of vehicle_status_s */

Definition at line 55 of file hardfault_log.h.

◆ BBSRAM_SIZE_FN3

#define BBSRAM_SIZE_FN3   HARDFAULT_MAX_ULOG_FILE_LEN

Definition at line 56 of file hardfault_log.h.

◆ BBSRAM_SIZE_FN4

#define BBSRAM_SIZE_FN4   -1

Definition at line 57 of file hardfault_log.h.

◆ BBSRAM_USED

Definition at line 65 of file hardfault_log.h.

◆ BSRAM_FILE_SIZES

#define BSRAM_FILE_SIZES
Value:
{ \
BBSRAM_SIZE_FN0, /* For Time stamp only */ \
BBSRAM_SIZE_FN1, /* For Current Flight Parameters Copy A */ \
BBSRAM_SIZE_FN2, /* For Current Flight Parameters Copy B */ \
BBSRAM_SIZE_FN3, /* For the latest ULog file path */ \
BBSRAM_SIZE_FN4, /* For the Panic Log use rest of space */ \
0 /* End of table marker */ \
}

Definition at line 81 of file hardfault_log.h.

◆ CONFIG_ISTACK_SIZE

#define CONFIG_ISTACK_SIZE   (BBSRAM_LEFTOVER/BBSRAM_NUMBER_STACKS/sizeof(stack_word_t))

Definition at line 75 of file hardfault_log.h.

Referenced by write_intterupt_stack().

◆ CONFIG_USTACK_SIZE

#define CONFIG_USTACK_SIZE   (BBSRAM_LEFTOVER/BBSRAM_NUMBER_STACKS/sizeof(stack_word_t))

Definition at line 76 of file hardfault_log.h.

Referenced by write_user_stack().

◆ HARDFAULT_DISPLAY_FORMAT

#define HARDFAULT_DISPLAY_FORMAT   1

Definition at line 119 of file hardfault_log.h.

Referenced by hardfault_dowrite(), and hardfault_write().

◆ HARDFAULT_FILE_FORMAT

#define HARDFAULT_FILE_FORMAT   0

Definition at line 120 of file hardfault_log.h.

Referenced by hardfault_commit(), hardfault_dowrite(), and hardfault_write().

◆ HARDFAULT_FILENO

#define HARDFAULT_FILENO   4

Definition at line 48 of file hardfault_log.h.

◆ HARDFAULT_MAX_ULOG_FILE_LEN

#define HARDFAULT_MAX_ULOG_FILE_LEN   64 /* must be large enough to store the full path to the log file */

◆ HARDFAULT_PATH

#define HARDFAULT_PATH   BBSRAM_PATH "" STRINGIFY(HARDFAULT_FILENO)

◆ HARDFAULT_REBOOT_FILENO

#define HARDFAULT_REBOOT_FILENO   0

Definition at line 44 of file hardfault_log.h.

◆ HARDFAULT_REBOOT_PATH

#define HARDFAULT_REBOOT_PATH   BBSRAM_PATH "" STRINGIFY(HARDFAULT_REBOOT_FILENO)

Definition at line 45 of file hardfault_log.h.

Referenced by hardfault_increment_reboot().

◆ HARDFAULT_ULOG_FILENO

#define HARDFAULT_ULOG_FILENO   3

Definition at line 46 of file hardfault_log.h.

◆ HARDFAULT_ULOG_PATH

#define HARDFAULT_ULOG_PATH   BBSRAM_PATH "" STRINGIFY(HARDFAULT_ULOG_FILENO)

◆ HEADER_TIME_FMT

#define HEADER_TIME_FMT   "%Y-%m-%d-%H:%M:%S"

Definition at line 112 of file hardfault_log.h.

Referenced by hardfault_check_status(), write_dump_info(), and write_dump_time().

◆ HEADER_TIME_FMT_LEN

#define HEADER_TIME_FMT_LEN   (((arraySize(HEADER_TIME_FMT)-1) + HEADER_TIME_FMT_NUM))

Definition at line 114 of file hardfault_log.h.

Referenced by genfault().

◆ HEADER_TIME_FMT_NUM

#define HEADER_TIME_FMT_NUM   (2+ 0+ 0+ 0+ 0+ 0)

Definition at line 113 of file hardfault_log.h.

◆ LOG_NAME_FMT

#define LOG_NAME_FMT   "fault_%s.log"

Definition at line 102 of file hardfault_log.h.

Referenced by format_fault_file_name().

◆ LOG_NAME_LEN

#define LOG_NAME_LEN   ((arraySize(LOG_NAME_FMT)-1) + LOG_NAME_NUM)

Definition at line 104 of file hardfault_log.h.

Referenced by format_fault_file_name().

◆ LOG_NAME_NUM

#define LOG_NAME_NUM   ( -2 )

Definition at line 103 of file hardfault_log.h.

◆ LOG_PATH_BASE

#define LOG_PATH_BASE   "/fs/microsd/"

Definition at line 99 of file hardfault_log.h.

Referenced by format_fault_file_name().

◆ LOG_PATH_BASE_LEN

#define LOG_PATH_BASE_LEN   ((arraySize(LOG_PATH_BASE))-1)

Definition at line 100 of file hardfault_log.h.

Referenced by format_fault_file_name().

◆ LOG_PATH_LEN

#define LOG_PATH_LEN   ((LOG_PATH_BASE_LEN + LOG_NAME_LEN + TIME_FMT_LEN))

Definition at line 110 of file hardfault_log.h.

Referenced by format_fault_file_name(), and hardfault_commit().

◆ MAX_FILE_PATH_LENGTH

#define MAX_FILE_PATH_LENGTH   40

Definition at line 91 of file hardfault_log.h.

◆ TIME_FMT

#define TIME_FMT   "%Y_%m_%d_%H_%M_%S"

Definition at line 106 of file hardfault_log.h.

Referenced by format_fault_file_name().

◆ TIME_FMT_LEN

◆ TIME_FMT_NUM

#define TIME_FMT_NUM   (2+ 0+ 0+ 0+ 0+ 0)

Definition at line 107 of file hardfault_log.h.

Typedef Documentation

◆ stack_word_t

typedef uint32_t stack_word_t

Definition at line 127 of file hardfault_log.h.

Enumeration Type Documentation

◆ fault_flags_t

Enumerator
eRegsPresent 
eUserStackPresent 
eIntStackPresent 
eInvalidUserStackPtr 
eInvalidIntStackPrt 

Definition at line 228 of file hardfault_log.h.

Function Documentation

◆ hardfault_check_status()

__BEGIN_DECLS int hardfault_check_status ( char *  caller)

Definition at line 985 of file hardfault_log.c.

References arraySize, fd, format_fault_time(), hardfault_get_desc(), HARDFAULT_PATH, hardfault_rearm(), HEADER_TIME_FMT, identify(), OK, state, and TIME_FMT_LEN.

Referenced by hardfault_log_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hardfault_increment_reboot()

int hardfault_increment_reboot ( char *  caller,
bool  reset 
)

Definition at line 1038 of file hardfault_log.c.

References fd, HARDFAULT_REBOOT_PATH, identify(), OK, read(), and write().

Referenced by hardfault_log_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hardfault_rearm()

int hardfault_rearm ( char *  caller)

Definition at line 964 of file hardfault_log.c.

References HARDFAULT_PATH, identify(), and OK.

Referenced by hardfault_check_status(), hardfault_log_main(), and hardfault_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hardfault_write()

int hardfault_write ( char *  caller,
int  fd,
int  format,
bool  rearm 
)

Definition at line 1085 of file hardfault_log.c.

References HARDFAULT_DISPLAY_FORMAT, hardfault_dowrite(), HARDFAULT_FILE_FORMAT, hardfault_get_desc(), hardfault_rearm(), identify(), and OK.

Referenced by hardfault_commit().

Here is the call graph for this function:
Here is the caller graph for this function: