Significantly stylistic changes required after review of last PR
This commit is contained in:
parent
725a16d033
commit
c74269ced6
@ -88,7 +88,9 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get aligned addresses of the top and bottom of the stack */
|
||||
|
||||
#ifdef CONFIG_TLS
|
||||
/* Skip over the TLS data structure at the bottom of the stack */
|
||||
|
||||
@ -126,7 +128,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
|
||||
#if 0
|
||||
if (mark + 16 > nwords)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
ptr = (FAR uint32_t *)start;
|
||||
for (i = 0; i < size; i += 4*64)
|
||||
|
@ -1196,8 +1196,8 @@ config STM32F7_QUADSPI
|
||||
default n
|
||||
|
||||
config STM32F7_PWR
|
||||
bool "PWR"
|
||||
default n
|
||||
bool "PWR"
|
||||
default n
|
||||
|
||||
config STM32F7_RNG
|
||||
bool "RNG"
|
||||
@ -1801,57 +1801,57 @@ endmenu # "SDMMC2 Configuration"
|
||||
if STM32F7_BKPSRAM
|
||||
|
||||
config STM32F7_BBSRAM
|
||||
bool "BBSRAM File Support"
|
||||
default n
|
||||
bool "BBSRAM File Support"
|
||||
default n
|
||||
|
||||
config STM32F7_BBSRAM_FILES
|
||||
int "Max Files to support in BBSRAM"
|
||||
default 4
|
||||
int "Max Files to support in BBSRAM"
|
||||
default 4
|
||||
|
||||
config STM32F7_SAVE_CRASHDUMP
|
||||
bool "Enable Saving Panic to BBSRAM"
|
||||
default n
|
||||
bool "Enable Saving Panic to BBSRAM"
|
||||
default n
|
||||
|
||||
endif # STM32F7_BKPSRAM
|
||||
|
||||
config STM32F7_HAVE_RTC_COUNTER
|
||||
bool
|
||||
default n
|
||||
bool
|
||||
default n
|
||||
|
||||
config STM32F7_HAVE_RTC_SUBSECONDS
|
||||
bool
|
||||
default n
|
||||
bool
|
||||
default n
|
||||
|
||||
config RTC_MAGIC_REG
|
||||
int "The BKP register used to store/check the Magic value to determine if RTC is set already"
|
||||
default 0
|
||||
range 0 31
|
||||
depends on RTC && !STM32F7_HAVE_RTC_COUNTER
|
||||
int "The BKP register used to store/check the Magic value to determine if RTC is set already"
|
||||
default 0
|
||||
range 0 31
|
||||
depends on RTC && !STM32F7_HAVE_RTC_COUNTER
|
||||
|
||||
config RTC_MAGIC
|
||||
hex "Value used as Magic to determine if RTC is set already"
|
||||
default 0xfacefeee
|
||||
depends on RTC && !STM32F7_HAVE_RTC_COUNTER
|
||||
hex "Value used as Magic to determine if RTC is set already"
|
||||
default 0xfacefeee
|
||||
depends on RTC && !STM32F7_HAVE_RTC_COUNTER
|
||||
|
||||
choice
|
||||
prompt "RTC clock source"
|
||||
default STM32F7_RTC_LSECLOCK
|
||||
depends on RTC
|
||||
prompt "RTC clock source"
|
||||
default STM32F7_RTC_LSECLOCK
|
||||
depends on RTC
|
||||
|
||||
config STM32F7_RTC_HSECLOCK
|
||||
bool "HSE clock"
|
||||
---help---
|
||||
Drive the RTC with the HSE clock, divided down to 1MHz.
|
||||
bool "HSE clock"
|
||||
---help---
|
||||
Drive the RTC with the HSE clock, divided down to 1MHz.
|
||||
|
||||
config STM32F7_RTC_LSECLOCK
|
||||
bool "LSE clock"
|
||||
---help---
|
||||
Drive the RTC with the LSE clock
|
||||
bool "LSE clock"
|
||||
---help---
|
||||
Drive the RTC with the LSE clock
|
||||
|
||||
config STM32F7_RTC_LSICLOCK
|
||||
bool "LSI clock"
|
||||
---help---
|
||||
Drive the RTC with the LSI clock
|
||||
bool "LSI clock"
|
||||
---help---
|
||||
Drive the RTC with the LSI clock
|
||||
|
||||
endchoice #"RTC clock source"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/************************************************************************************
|
||||
* arch/arm/src/stm32f7/chip/stm32_rtcc.h.h
|
||||
* arch/arm/src/stm32f7/chip/stm32_rtcc.h
|
||||
*
|
||||
* Copyright (C) 2011-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
@ -52,10 +52,6 @@
|
||||
|
||||
#if defined(CONFIG_STM32F7_PWR)
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
@ -277,7 +277,6 @@ int stm32_sdio_initialize(void);
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
|
||||
#ifdef CONFIG_STM32F7_OTGFS
|
||||
void stm32_usbinitialize(void);
|
||||
#endif
|
||||
@ -285,8 +284,10 @@ void stm32_usbinitialize(void);
|
||||
/************************************************************************************
|
||||
* Name: stm32_bbsram_int
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32F7_BBSRAM
|
||||
int stm32_bbsram_int(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_NUCLEO_144_SRC_NUCLEO_144_H */
|
||||
|
@ -101,7 +101,10 @@ int board_app_initialize(uintptr_t arg)
|
||||
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32F7_BBSRAM
|
||||
/* Initialize battery-backed RAM */
|
||||
|
||||
(void)stm32_bbsram_int();
|
||||
#endif
|
||||
|
||||
|
@ -64,186 +64,208 @@
|
||||
|
||||
/* Configuration ********************************************************************/
|
||||
/* The path to the Battery Backed up SRAM */
|
||||
|
||||
#define BBSRAM_PATH "/bbr"
|
||||
#define HARDFAULT_FILENO 3
|
||||
#define HARDFAULT_PATH "/bbr3"
|
||||
|
||||
/* The sizes of the files to create (-1) use rest of BBSRAM memory */
|
||||
#define BSRAM_FILE_SIZES { \
|
||||
256, \
|
||||
256, \
|
||||
1024, \
|
||||
-1, \
|
||||
0 \
|
||||
}
|
||||
|
||||
#define BSRAM_FILE_SIZES \
|
||||
{ \
|
||||
256, \
|
||||
256, \
|
||||
1024, \
|
||||
-1, \
|
||||
0 \
|
||||
}
|
||||
|
||||
#define MAX_FILE_PATH_LENGTH 40
|
||||
#define CONFIG_ISTACK_SIZE 800
|
||||
#define CONFIG_USTACK_SIZE 800
|
||||
|
||||
#define arraySize(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
typedef uint32_t stack_word_t;
|
||||
|
||||
/* Used for stack frame storage */
|
||||
|
||||
typedef uint32_t stack_word_t;
|
||||
|
||||
/* Stack related data */
|
||||
|
||||
typedef struct {
|
||||
uint32_t sp;
|
||||
uint32_t top;
|
||||
uint32_t size;
|
||||
typedef struct
|
||||
{
|
||||
uint32_t sp;
|
||||
uint32_t top;
|
||||
uint32_t size;
|
||||
|
||||
} _stack_s;
|
||||
} _stack_t;
|
||||
|
||||
typedef struct {
|
||||
_stack_s user;
|
||||
typedef struct
|
||||
{
|
||||
_stack_t user;
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
_stack_s interrupt;
|
||||
_stack_t interrupt;
|
||||
#endif
|
||||
|
||||
} stack_t;
|
||||
|
||||
/* Not Used for reference only */
|
||||
|
||||
typedef struct {
|
||||
uint32_t r0;
|
||||
uint32_t r1;
|
||||
uint32_t r2;
|
||||
uint32_t r3;
|
||||
uint32_t r4;
|
||||
uint32_t r5;
|
||||
uint32_t r6;
|
||||
uint32_t r7;
|
||||
uint32_t r8;
|
||||
uint32_t r9;
|
||||
uint32_t r10;
|
||||
uint32_t r11;
|
||||
uint32_t r12;
|
||||
uint32_t sp;
|
||||
uint32_t lr;
|
||||
uint32_t pc;
|
||||
uint32_t xpsr;
|
||||
uint32_t d0;
|
||||
uint32_t d1;
|
||||
uint32_t d2;
|
||||
uint32_t d3;
|
||||
uint32_t d4;
|
||||
uint32_t d5;
|
||||
uint32_t d6;
|
||||
uint32_t d7;
|
||||
uint32_t d8;
|
||||
uint32_t d9;
|
||||
uint32_t d10;
|
||||
uint32_t d11;
|
||||
uint32_t d12;
|
||||
uint32_t d13;
|
||||
uint32_t d14;
|
||||
uint32_t d15;
|
||||
uint32_t fpscr;
|
||||
uint32_t sp_main;
|
||||
uint32_t sp_process;
|
||||
uint32_t apsr;
|
||||
uint32_t ipsr;
|
||||
uint32_t epsr;
|
||||
uint32_t primask;
|
||||
uint32_t basepri;
|
||||
uint32_t faultmask;
|
||||
uint32_t control;
|
||||
uint32_t s0;
|
||||
uint32_t s1;
|
||||
uint32_t s2;
|
||||
uint32_t s3;
|
||||
uint32_t s4;
|
||||
uint32_t s5;
|
||||
uint32_t s6;
|
||||
uint32_t s7;
|
||||
uint32_t s8;
|
||||
uint32_t s9;
|
||||
uint32_t s10;
|
||||
uint32_t s11;
|
||||
uint32_t s12;
|
||||
uint32_t s13;
|
||||
uint32_t s14;
|
||||
uint32_t s15;
|
||||
uint32_t s16;
|
||||
uint32_t s17;
|
||||
uint32_t s18;
|
||||
uint32_t s19;
|
||||
uint32_t s20;
|
||||
uint32_t s21;
|
||||
uint32_t s22;
|
||||
uint32_t s23;
|
||||
uint32_t s24;
|
||||
uint32_t s25;
|
||||
uint32_t s26;
|
||||
uint32_t s27;
|
||||
uint32_t s28;
|
||||
uint32_t s29;
|
||||
uint32_t s30;
|
||||
uint32_t s31;
|
||||
} proc_regs_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t r0;
|
||||
uint32_t r1;
|
||||
uint32_t r2;
|
||||
uint32_t r3;
|
||||
uint32_t r4;
|
||||
uint32_t r5;
|
||||
uint32_t r6;
|
||||
uint32_t r7;
|
||||
uint32_t r8;
|
||||
uint32_t r9;
|
||||
uint32_t r10;
|
||||
uint32_t r11;
|
||||
uint32_t r12;
|
||||
uint32_t sp;
|
||||
uint32_t lr;
|
||||
uint32_t pc;
|
||||
uint32_t xpsr;
|
||||
uint32_t d0;
|
||||
uint32_t d1;
|
||||
uint32_t d2;
|
||||
uint32_t d3;
|
||||
uint32_t d4;
|
||||
uint32_t d5;
|
||||
uint32_t d6;
|
||||
uint32_t d7;
|
||||
uint32_t d8;
|
||||
uint32_t d9;
|
||||
uint32_t d10;
|
||||
uint32_t d11;
|
||||
uint32_t d12;
|
||||
uint32_t d13;
|
||||
uint32_t d14;
|
||||
uint32_t d15;
|
||||
uint32_t fpscr;
|
||||
uint32_t sp_main;
|
||||
uint32_t sp_process;
|
||||
uint32_t apsr;
|
||||
uint32_t ipsr;
|
||||
uint32_t epsr;
|
||||
uint32_t primask;
|
||||
uint32_t basepri;
|
||||
uint32_t faultmask;
|
||||
uint32_t control;
|
||||
uint32_t s0;
|
||||
uint32_t s1;
|
||||
uint32_t s2;
|
||||
uint32_t s3;
|
||||
uint32_t s4;
|
||||
uint32_t s5;
|
||||
uint32_t s6;
|
||||
uint32_t s7;
|
||||
uint32_t s8;
|
||||
uint32_t s9;
|
||||
uint32_t s10;
|
||||
uint32_t s11;
|
||||
uint32_t s12;
|
||||
uint32_t s13;
|
||||
uint32_t s14;
|
||||
uint32_t s15;
|
||||
uint32_t s16;
|
||||
uint32_t s17;
|
||||
uint32_t s18;
|
||||
uint32_t s19;
|
||||
uint32_t s20;
|
||||
uint32_t s21;
|
||||
uint32_t s22;
|
||||
uint32_t s23;
|
||||
uint32_t s24;
|
||||
uint32_t s25;
|
||||
uint32_t s26;
|
||||
uint32_t s27;
|
||||
uint32_t s28;
|
||||
uint32_t s29;
|
||||
uint32_t s30;
|
||||
uint32_t s31;
|
||||
} proc_regs_t;
|
||||
|
||||
/* Flags to identify what is in the dump */
|
||||
typedef enum {
|
||||
eRegsPresent = 0x01,
|
||||
eUserStackPresent = 0x02,
|
||||
eIntStackPresent = 0x04,
|
||||
eInvalidUserStackPtr = 0x20,
|
||||
eInvalidIntStackPrt = 0x40,
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eRegsPresent = 0x01,
|
||||
eUserStackPresent = 0x02,
|
||||
eIntStackPresent = 0x04,
|
||||
eInvalidUserStackPtr = 0x20,
|
||||
eInvalidIntStackPrt = 0x40,
|
||||
} fault_flags_t;
|
||||
|
||||
typedef struct {
|
||||
fault_flags_t flags; /* What is in the dump */
|
||||
uintptr_t current_regs; /* Used to validate the dump */
|
||||
int lineno; /* __LINE__ to up_assert */
|
||||
int pid; /* Process ID */
|
||||
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save
|
||||
* area */
|
||||
stack_t stacks; /* Stack info */
|
||||
typedef struct
|
||||
{
|
||||
fault_flags_t flags; /* What is in the dump */
|
||||
uintptr_t current_regs; /* Used to validate the dump */
|
||||
int lineno; /* __LINE__ to up_assert */
|
||||
int pid; /* Process ID */
|
||||
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
|
||||
stack_t stacks; /* Stack info */
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
|
||||
* terminator) */
|
||||
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
|
||||
* terminator) */
|
||||
#endif
|
||||
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
|
||||
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
|
||||
* __FILE__ to up_assert */
|
||||
} info_s;
|
||||
} info_t;
|
||||
|
||||
typedef struct {
|
||||
info_s info; /* The info */
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3 /* The amount of stack data is compile time
|
||||
* sized backed on what is left after the
|
||||
* other BBSRAM files are defined
|
||||
* The order is such that only the
|
||||
* ustack should be truncated
|
||||
*/
|
||||
stack_word_t istack[CONFIG_USTACK_SIZE];
|
||||
typedef struct
|
||||
{
|
||||
info_t info; /* The info */
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3 /* The amount of stack data is compile time
|
||||
* sized backed on what is left after the
|
||||
* other BBSRAM files are defined
|
||||
* The order is such that only the
|
||||
* ustack should be truncated
|
||||
*/
|
||||
stack_word_t istack[CONFIG_USTACK_SIZE];
|
||||
#endif
|
||||
stack_word_t ustack[CONFIG_ISTACK_SIZE];
|
||||
} fullcontext_s;
|
||||
stack_word_t ustack[CONFIG_ISTACK_SIZE];
|
||||
} fullcontext_t;
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
static uint8_t sdata[STM32F7_BBSRAM_SIZE];
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
/****************************************************************************
|
||||
* hardfault_get_desc
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: hardfault_get_desc
|
||||
************************************************************************************/
|
||||
|
||||
static int hardfault_get_desc(struct bbsramd_s *desc)
|
||||
{
|
||||
int ret = -ENOENT;
|
||||
int fd = open(HARDFAULT_PATH, O_RDONLY);
|
||||
int rv;
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
syslog(LOG_INFO, "stm32 bbsram: Failed to open Fault Log file [%s] (%d)\n", HARDFAULT_PATH, fd);
|
||||
|
||||
syslog(LOG_INFO, "stm32 bbsram: Failed to open Fault Log file [%s] (%d)\n",
|
||||
HARDFAULT_PATH, fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -EIO;
|
||||
int rv = ioctl(fd, STM32F7_BBSRAM_GETDESC_IOCTL, (unsigned long)((uintptr_t)desc));
|
||||
rv = ioctl(fd, STM32F7_BBSRAM_GETDESC_IOCTL,
|
||||
(unsigned long)((uintptr_t)desc));
|
||||
|
||||
if (rv >= 0)
|
||||
{
|
||||
@ -251,49 +273,17 @@ static int hardfault_get_desc(struct bbsramd_s *desc)
|
||||
}
|
||||
else
|
||||
{
|
||||
syslog(LOG_INFO, "stm32 bbsram: Failed to get Fault Log descriptor (%d)\n", rv);
|
||||
syslog(LOG_INFO, "stm32 bbsram: Failed to get Fault Log descriptor (%d)\n",
|
||||
rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
* Name: copy_reverse
|
||||
************************************************************************************/
|
||||
int stm32_bbsram_int(void)
|
||||
{
|
||||
|
||||
|
||||
/* Using Battery Backed Up SRAM */
|
||||
|
||||
int filesizes[CONFIG_STM32F7_BBSRAM_FILES + 1] = BSRAM_FILE_SIZES;
|
||||
int rv;
|
||||
struct bbsramd_s desc;
|
||||
stm32_bbsraminitialize(BBSRAM_PATH, filesizes);
|
||||
|
||||
#if defined(CONFIG_STM32F7_SAVE_CRASHDUMP)
|
||||
|
||||
/* Panic Logging in Battery Backed Up Files */
|
||||
|
||||
/* Do we have an hard fault in BBSRAM?
|
||||
*/
|
||||
rv = hardfault_get_desc(&desc);
|
||||
|
||||
if (rv >= OK)
|
||||
{
|
||||
printf("There is a hard fault logged.\n");
|
||||
|
||||
rv = unlink(HARDFAULT_PATH);
|
||||
if (rv < 0)
|
||||
{
|
||||
syslog(LOG_INFO, "stm32 bbsram: Failed to unlink Fault Log file [%s] (%d)\n", HARDFAULT_PATH, rv);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif // CONFIG_STM32_SAVE_CRASHDUMP
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_STM32F7_SAVE_CRASHDUMP)
|
||||
static void copy_reverse(stack_word_t *dest, stack_word_t *src, int size)
|
||||
@ -303,146 +293,199 @@ static void copy_reverse(stack_word_t *dest, stack_word_t *src, int size)
|
||||
*dest++ = *src--;
|
||||
}
|
||||
}
|
||||
uint8_t sdata[STM32F7_BBSRAM_SIZE];
|
||||
void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint8_t *filename, int lineno)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_bbsram_int
|
||||
************************************************************************************/
|
||||
|
||||
int stm32_bbsram_int(void)
|
||||
{
|
||||
fullcontext_s *pdump = (fullcontext_s *)&sdata;
|
||||
int filesizes[CONFIG_STM32F7_BBSRAM_FILES + 1] = BSRAM_FILE_SIZES;
|
||||
struct bbsramd_s desc;
|
||||
int rv;
|
||||
|
||||
(void)enter_critical_section();
|
||||
/* Using Battery Backed Up SRAM */
|
||||
|
||||
struct tcb_s *rtcb = (struct tcb_s *)tcb;
|
||||
stm32_bbsraminitialize(BBSRAM_PATH, filesizes);
|
||||
|
||||
/* Zero out everything */
|
||||
#if defined(CONFIG_STM32F7_SAVE_CRASHDUMP)
|
||||
/* Panic Logging in Battery Backed Up Files */
|
||||
/* Do we have an hard fault in BBSRAM? */
|
||||
|
||||
memset(pdump, 0, sizeof(fullcontext_s));
|
||||
rv = hardfault_get_desc(&desc);
|
||||
if (rv >= OK)
|
||||
{
|
||||
printf("There is a hard fault logged.\n");
|
||||
|
||||
/* Save Info */
|
||||
rv = unlink(HARDFAULT_PATH);
|
||||
if (rv < 0)
|
||||
{
|
||||
syslog(LOG_INFO, "stm32 bbsram: Failed to unlink Fault Log file [%s] (%d)\n", HARDFAULT_PATH, rv);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_STM32_SAVE_CRASHDUMP */
|
||||
|
||||
pdump->info.lineno = lineno;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
/************************************************************************************
|
||||
* Name: board_crashdump
|
||||
************************************************************************************/
|
||||
|
||||
int offset = 0;
|
||||
unsigned int len = strlen((char *)filename) + 1;
|
||||
void board_crashdump(uintptr_t currentsp, FAR void *tcb,
|
||||
FAR const uint8_t *filename, int lineno)
|
||||
{
|
||||
fullcontext_t *pdump = (fullcontext_t *)&sdata;
|
||||
FAR struct tcb_s *rtcb;
|
||||
int rv;
|
||||
|
||||
if (len > sizeof(pdump->info.filename)) {
|
||||
offset = len - sizeof(pdump->info.filename) ;
|
||||
(void)enter_critical_section();
|
||||
|
||||
rtcb = (FAR struct tcb_s *)tcb;
|
||||
|
||||
/* Zero out everything */
|
||||
|
||||
memset(pdump, 0, sizeof(fullcontext_t));
|
||||
|
||||
/* Save Info */
|
||||
|
||||
pdump->info.lineno = lineno;
|
||||
|
||||
if (filename)
|
||||
{
|
||||
int offset = 0;
|
||||
unsigned int len = strlen((char *)filename) + 1;
|
||||
|
||||
if (len > sizeof(pdump->info.filename))
|
||||
{
|
||||
offset = len - sizeof(pdump->info.filename);
|
||||
}
|
||||
|
||||
strncpy(pdump->info.filename, (char *)&filename[offset], sizeof(pdump->info.filename));
|
||||
strncpy(pdump->info.filename, (char *)&filename[offset],
|
||||
sizeof(pdump->info.filename));
|
||||
}
|
||||
|
||||
/* Save the value of the pointer for current_regs as debugging info.
|
||||
* It should be NULL in case of an ASSERT and will aid in cross
|
||||
* checking the validity of system memory at the time of the
|
||||
* fault.
|
||||
*/
|
||||
/* Save the value of the pointer for current_regs as debugging info.
|
||||
* It should be NULL in case of an ASSERT and will aid in cross
|
||||
* checking the validity of system memory at the time of the
|
||||
* fault.
|
||||
*/
|
||||
|
||||
pdump->info.current_regs = (uintptr_t) CURRENT_REGS;
|
||||
|
||||
/* Save Context */
|
||||
pdump->info.current_regs = (uintptr_t) CURRENT_REGS;
|
||||
|
||||
/* Save Context */
|
||||
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
strncpy(pdump->info.name, rtcb->name, CONFIG_TASK_NAME_SIZE);
|
||||
strncpy(pdump->info.name, rtcb->name, CONFIG_TASK_NAME_SIZE);
|
||||
#endif
|
||||
|
||||
pdump->info.pid = rtcb->pid;
|
||||
pdump->info.pid = rtcb->pid;
|
||||
|
||||
/* If current_regs is not NULL then we are in an interrupt context
|
||||
* and the user context is in current_regs else we are running in
|
||||
* the users context
|
||||
*/
|
||||
|
||||
/* If current_regs is not NULL then we are in an interrupt context
|
||||
* and the user context is in current_regs else we are running in
|
||||
* the users context
|
||||
*/
|
||||
if (CURRENT_REGS)
|
||||
{
|
||||
pdump->info.stacks.interrupt.sp = currentsp;
|
||||
pdump->info.flags |= (eRegsPresent | eUserStackPresent | eIntStackPresent);
|
||||
memcpy(pdump->info.regs, (void *)CURRENT_REGS, sizeof(pdump->info.regs));
|
||||
pdump->info.stacks.user.sp = pdump->info.regs[REG_R13];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* users context */
|
||||
|
||||
if (CURRENT_REGS) {
|
||||
pdump->info.stacks.interrupt.sp = currentsp;
|
||||
|
||||
pdump->info.flags |= (eRegsPresent | eUserStackPresent | eIntStackPresent);
|
||||
memcpy(pdump->info.regs, (void *)CURRENT_REGS, sizeof(pdump->info.regs));
|
||||
pdump->info.stacks.user.sp = pdump->info.regs[REG_R13];
|
||||
|
||||
} else {
|
||||
|
||||
/* users context */
|
||||
pdump->info.flags |= eUserStackPresent;
|
||||
|
||||
pdump->info.stacks.user.sp = currentsp;
|
||||
pdump->info.flags |= eUserStackPresent;
|
||||
pdump->info.stacks.user.sp = currentsp;
|
||||
}
|
||||
|
||||
if (pdump->info.pid == 0) {
|
||||
|
||||
pdump->info.stacks.user.top = g_idle_topstack - 4;
|
||||
pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE;
|
||||
|
||||
} else {
|
||||
pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr;
|
||||
pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size;;
|
||||
if (pdump->info.pid == 0)
|
||||
{
|
||||
pdump->info.stacks.user.top = g_idle_topstack - 4;
|
||||
pdump->info.stacks.user.size = CONFIG_IDLETHREAD_STACKSIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdump->info.stacks.user.top = (uint32_t) rtcb->adj_stack_ptr;
|
||||
pdump->info.stacks.user.size = (uint32_t) rtcb->adj_stack_size;;
|
||||
}
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
pdump->info.stacks.interrupt.top = (uint32_t)&g_intstackbase;
|
||||
pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
||||
|
||||
pdump->info.stacks.interrupt.top = (uint32_t)&g_intstackbase;
|
||||
pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
||||
/* If In interrupt Context save the interrupt stack data centered
|
||||
* about the interrupt stack pointer
|
||||
*/
|
||||
|
||||
/* If In interrupt Context save the interrupt stack data centered
|
||||
* about the interrupt stack pointer
|
||||
*/
|
||||
|
||||
if ((pdump->info.flags & eIntStackPresent) != 0) {
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse(pdump->istack, &ps[arraySize(pdump->istack) / 2], arraySize(pdump->istack));
|
||||
if ((pdump->info.flags & eIntStackPresent) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse(pdump->istack, &ps[arraySize(pdump->istack) / 2], arraySize(pdump->istack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
/* Is it Invalid? */
|
||||
|
||||
if (!(pdump->info.stacks.interrupt.sp <= pdump->info.stacks.interrupt.top &&
|
||||
pdump->info.stacks.interrupt.sp > pdump->info.stacks.interrupt.top - pdump->info.stacks.interrupt.size)) {
|
||||
pdump->info.flags |= eInvalidIntStackPrt;
|
||||
if (!(pdump->info.stacks.interrupt.sp <= pdump->info.stacks.interrupt.top &&
|
||||
pdump->info.stacks.interrupt.sp > pdump->info.stacks.interrupt.top -
|
||||
pdump->info.stacks.interrupt.size))
|
||||
{
|
||||
pdump->info.flags |= eInvalidIntStackPrt;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* If In interrupt context or User save the user stack data centered
|
||||
* about the user stack pointer
|
||||
*/
|
||||
|
||||
/* If In interrupt context or User save the user stack data centered
|
||||
* about the user stack pointer
|
||||
*/
|
||||
if ((pdump->info.flags & eUserStackPresent) != 0) {
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse(pdump->ustack, &ps[arraySize(pdump->ustack) / 2], arraySize(pdump->ustack));
|
||||
if ((pdump->info.flags & eUserStackPresent) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse(pdump->ustack, &ps[arraySize(pdump->ustack) / 2],
|
||||
arraySize(pdump->ustack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
/* Is it Invalid? */
|
||||
|
||||
if (!(pdump->info.stacks.user.sp <= pdump->info.stacks.user.top &&
|
||||
pdump->info.stacks.user.sp > pdump->info.stacks.user.top - pdump->info.stacks.user.size)) {
|
||||
pdump->info.flags |= eInvalidUserStackPtr;
|
||||
if (!(pdump->info.stacks.user.sp <= pdump->info.stacks.user.top &&
|
||||
pdump->info.stacks.user.sp > pdump->info.stacks.user.top -
|
||||
pdump->info.stacks.user.size))
|
||||
{
|
||||
pdump->info.flags |= eInvalidUserStackPtr;
|
||||
}
|
||||
|
||||
int rv = stm32_bbsram_savepanic(HARDFAULT_FILENO, (uint8_t *)pdump, sizeof(fullcontext_s));
|
||||
rv = stm32_bbsram_savepanic(HARDFAULT_FILENO, (uint8_t *)pdump, sizeof(fullcontext_t));
|
||||
|
||||
/* Test if memory got wiped because of using _sdata */
|
||||
/* Test if memory got wiped because of using _sdata */
|
||||
|
||||
if (rv == -ENXIO) {
|
||||
char *dead = "Memory wiped - dump not saved!";
|
||||
if (rv == -ENXIO)
|
||||
{
|
||||
char *dead = "Memory wiped - dump not saved!";
|
||||
|
||||
while (*dead) {
|
||||
up_lowputc(*dead++);
|
||||
while (*dead)
|
||||
{
|
||||
up_lowputc(*dead++);
|
||||
}
|
||||
|
||||
} else if (rv == -ENOSPC) {
|
||||
|
||||
/* hard fault again */
|
||||
|
||||
up_lowputc('!');
|
||||
}
|
||||
else if (rv == -ENOSPC)
|
||||
{
|
||||
/* hard fault again */
|
||||
|
||||
up_lowputc('!');
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BOARD_RESET_ON_CRASH)
|
||||
up_systemreset();
|
||||
up_systemreset();
|
||||
#endif
|
||||
}
|
||||
#endif // CONFIG_STM32_SAVE_CRASHDUMP
|
||||
#endif /* CONFIG_STM32_SAVE_CRASHDUMP */
|
||||
|
||||
#endif /* CONFIG_STM32_BBSRAM */
|
||||
|
Loading…
x
Reference in New Issue
Block a user