mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Merge branch 'stac/use-malloc-failed-hook' into next
This commit is contained in:
commit
1d77d77832
@ -26,6 +26,7 @@
|
|||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
#define configUSE_IDLE_HOOK 1
|
#define configUSE_IDLE_HOOK 1
|
||||||
#define configUSE_TICK_HOOK 0
|
#define configUSE_TICK_HOOK 0
|
||||||
|
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
|
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
|
||||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||||
|
@ -75,7 +75,8 @@
|
|||||||
static uint32_t idleCounter;
|
static uint32_t idleCounter;
|
||||||
static uint32_t idleCounterClear;
|
static uint32_t idleCounterClear;
|
||||||
static xTaskHandle systemTaskHandle;
|
static xTaskHandle systemTaskHandle;
|
||||||
static int32_t stackOverflow;
|
static bool stackOverflow;
|
||||||
|
static bool mallocFailed;
|
||||||
|
|
||||||
// Private functions
|
// Private functions
|
||||||
static void objectUpdatedCb(UAVObjEvent * ev);
|
static void objectUpdatedCb(UAVObjEvent * ev);
|
||||||
@ -93,7 +94,8 @@ static void updateWDGstats();
|
|||||||
int32_t SystemModStart(void)
|
int32_t SystemModStart(void)
|
||||||
{
|
{
|
||||||
// Initialize vars
|
// Initialize vars
|
||||||
stackOverflow = 0;
|
stackOverflow = false;
|
||||||
|
mallocFailed = false;
|
||||||
// Create system task
|
// Create system task
|
||||||
xTaskCreate(systemTask, (signed char *)"System", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &systemTaskHandle);
|
xTaskCreate(systemTask, (signed char *)"System", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &systemTaskHandle);
|
||||||
// Register task
|
// Register task
|
||||||
@ -417,12 +419,19 @@ static void updateSystemAlarms()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for stack overflow
|
// Check for stack overflow
|
||||||
if (stackOverflow == 1) {
|
if (stackOverflow) {
|
||||||
AlarmsSet(SYSTEMALARMS_ALARM_STACKOVERFLOW, SYSTEMALARMS_ALARM_CRITICAL);
|
AlarmsSet(SYSTEMALARMS_ALARM_STACKOVERFLOW, SYSTEMALARMS_ALARM_CRITICAL);
|
||||||
} else {
|
} else {
|
||||||
AlarmsClear(SYSTEMALARMS_ALARM_STACKOVERFLOW);
|
AlarmsClear(SYSTEMALARMS_ALARM_STACKOVERFLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for malloc failures
|
||||||
|
if (mallocFailed) {
|
||||||
|
AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_CRITICAL);
|
||||||
|
} else {
|
||||||
|
AlarmsClear(SYSTEMALARMS_ALARM_OUTOFMEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_INCLUDE_SDCARD)
|
||||||
// Check for SD card
|
// Check for SD card
|
||||||
if (PIOS_SDCARD_IsMounted() == 0) {
|
if (PIOS_SDCARD_IsMounted() == 0) {
|
||||||
@ -461,9 +470,29 @@ void vApplicationIdleHook(void)
|
|||||||
/**
|
/**
|
||||||
* Called by the RTOS when a stack overflow is detected.
|
* Called by the RTOS when a stack overflow is detected.
|
||||||
*/
|
*/
|
||||||
|
#define DEBUG_STACK_OVERFLOW 0
|
||||||
void vApplicationStackOverflowHook(xTaskHandle * pxTask, signed portCHAR * pcTaskName)
|
void vApplicationStackOverflowHook(xTaskHandle * pxTask, signed portCHAR * pcTaskName)
|
||||||
{
|
{
|
||||||
stackOverflow = 1;
|
stackOverflow = true;
|
||||||
|
#if DEBUG_STACK_OVERFLOW
|
||||||
|
static volatile bool wait_here = true;
|
||||||
|
while(wait_here);
|
||||||
|
wait_here = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the RTOS when a malloc call fails.
|
||||||
|
*/
|
||||||
|
#define DEBUG_MALLOC_FAILURES 0
|
||||||
|
void vApplicationMallocFailedHook(void)
|
||||||
|
{
|
||||||
|
mallocFailed = true;
|
||||||
|
#if DEBUG_MALLOC_FAILURES
|
||||||
|
static volatile bool wait_here = true;
|
||||||
|
while(wait_here);
|
||||||
|
wait_here = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
#define configUSE_IDLE_HOOK 1
|
#define configUSE_IDLE_HOOK 1
|
||||||
#define configUSE_TICK_HOOK 0
|
#define configUSE_TICK_HOOK 0
|
||||||
|
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
|
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
|
||||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user