Merge pull request #9998 from mikeller/fix_stack_check

Fixed stack size monitoring.
This commit is contained in:
Michael Keller 2020-07-22 02:12:58 +12:00 committed by GitHub
commit 899cae197c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 95 additions and 27 deletions

View File

@ -4700,7 +4700,7 @@ static void cliStatus(const char *cmdName, char *cmdline)
// Stack and config sizes and usages // Stack and config sizes and usages
cliPrintf("Stack size: %d, Stack address: 0x%x", stackTotalSize(), stackHighMem()); cliPrintf("Stack size: %d, Stack address: 0x%x", stackTotalSize(), stackHighMem());
#ifdef STACK_CHECK #ifdef USE_STACK_CHECK
cliPrintf(", Stack used: %d", stackUsedSize()); cliPrintf(", Stack used: %d", stackUsedSize());
#endif #endif
cliPrintLinefeed(); cliPrintLinefeed();

View File

@ -58,7 +58,7 @@ extern char _Min_Stack_Size; // declared in .LD file
* See the linker scripts for actual stack configuration. * See the linker scripts for actual stack configuration.
*/ */
#ifdef STACK_CHECK #ifdef USE_STACK_CHECK
static uint32_t usedStackSize; static uint32_t usedStackSize;

View File

@ -257,7 +257,7 @@ void tasksInit(void)
const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts || featureIsEnabled(FEATURE_OSD); const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts || featureIsEnabled(FEATURE_OSD);
setTaskEnabled(TASK_BATTERY_ALERTS, (useBatteryVoltage || useBatteryCurrent) && useBatteryAlerts); setTaskEnabled(TASK_BATTERY_ALERTS, (useBatteryVoltage || useBatteryCurrent) && useBatteryAlerts);
#ifdef STACK_CHECK #ifdef USE_STACK_CHECK
setTaskEnabled(TASK_STACK_CHECK, true); setTaskEnabled(TASK_STACK_CHECK, true);
#endif #endif
@ -408,7 +408,7 @@ task_t tasks[TASK_COUNT] = {
[TASK_TRANSPONDER] = DEFINE_TASK("TRANSPONDER", NULL, NULL, transponderUpdate, TASK_PERIOD_HZ(250), TASK_PRIORITY_LOW), [TASK_TRANSPONDER] = DEFINE_TASK("TRANSPONDER", NULL, NULL, transponderUpdate, TASK_PERIOD_HZ(250), TASK_PRIORITY_LOW),
#endif #endif
#ifdef STACK_CHECK #ifdef USE_STACK_CHECK
[TASK_STACK_CHECK] = DEFINE_TASK("STACKCHECK", NULL, NULL, taskStackCheck, TASK_PERIOD_HZ(10), TASK_PRIORITY_IDLE), [TASK_STACK_CHECK] = DEFINE_TASK("STACKCHECK", NULL, NULL, taskStackCheck, TASK_PERIOD_HZ(10), TASK_PRIORITY_IDLE),
#endif #endif

View File

@ -111,7 +111,7 @@ typedef enum {
#ifdef USE_TRANSPONDER #ifdef USE_TRANSPONDER
TASK_TRANSPONDER, TASK_TRANSPONDER,
#endif #endif
#ifdef STACK_CHECK #ifdef USE_STACK_CHECK
TASK_STACK_CHECK, TASK_STACK_CHECK,
#endif #endif
#ifdef USE_OSD #ifdef USE_OSD

View File

@ -129,17 +129,17 @@ LoopFillZerofastram_bss:
bcc FillZerofastram_bss bcc FillZerofastram_bss
/* Mark the heap and stack */ /* Mark the heap and stack */
ldr r2, =_heap_stack_begin ldr r2, =_heap_stack_begin
b LoopMarkHeapStack b LoopMarkHeapStack
MarkHeapStack: MarkHeapStack:
movs r3, 0xa5a5a5a5 movs r3, 0xa5a5a5a5
str r3, [r2], #4 str r3, [r2], #4
LoopMarkHeapStack: LoopMarkHeapStack:
ldr r3, = _heap_stack_end ldr r3, = _heap_stack_end
cmp r2, r3 cmp r2, r3
bcc MarkHeapStack bcc MarkHeapStack
/*FPU settings*/ /*FPU settings*/
ldr r0, =0xE000ED88 /* Enable CP10,CP11 */ ldr r0, =0xE000ED88 /* Enable CP10,CP11 */

View File

@ -104,17 +104,17 @@ LoopFillZerobss:
bcc FillZerobss bcc FillZerobss
/* Mark the heap and stack */ /* Mark the heap and stack */
ldr r2, =_heap_stack_begin ldr r2, =_heap_stack_begin
b LoopMarkHeapStack b LoopMarkHeapStack
MarkHeapStack: MarkHeapStack:
movs r3, 0xa5a5a5a5 movs r3, 0xa5a5a5a5
str r3, [r2], #4 str r3, [r2], #4
LoopMarkHeapStack: LoopMarkHeapStack:
ldr r3, = _heap_stack_end ldr r3, = _heap_stack_end
cmp r2, r3 cmp r2, r3
bcc MarkHeapStack bcc MarkHeapStack
/*FPU settings*/ /*FPU settings*/
ldr r0, =0xE000ED88 /* Enable CP10,CP11 */ ldr r0, =0xE000ED88 /* Enable CP10,CP11 */

View File

@ -104,17 +104,17 @@ LoopFillZerobss:
bcc FillZerobss bcc FillZerobss
/* Mark the heap and stack */ /* Mark the heap and stack */
ldr r2, =_heap_stack_begin ldr r2, =_heap_stack_begin
b LoopMarkHeapStack b LoopMarkHeapStack
MarkHeapStack: MarkHeapStack:
movs r3, 0xa5a5a5a5 movs r3, 0xa5a5a5a5
str r3, [r2], #4 str r3, [r2], #4
LoopMarkHeapStack: LoopMarkHeapStack:
ldr r3, = _heap_stack_end ldr r3, = _heap_stack_end
cmp r2, r3 cmp r2, r3
bcc MarkHeapStack bcc MarkHeapStack
/*FPU settings*/ /*FPU settings*/
ldr r0, =0xE000ED88 /* Enable CP10,CP11 */ ldr r0, =0xE000ED88 /* Enable CP10,CP11 */

View File

@ -138,6 +138,19 @@ LoopFillZerofastram_bss:
cmp r2, r3 cmp r2, r3
bcc FillZerofastram_bss bcc FillZerofastram_bss
/* Mark the heap and stack */
ldr r2, =_heap_stack_begin
b LoopMarkHeapStack
MarkHeapStack:
movs r3, 0xa5a5a5a5
str r3, [r2], #4
LoopMarkHeapStack:
ldr r3, = _heap_stack_end
cmp r2, r3
bcc MarkHeapStack
/* Call the clock system intitialization function.*/ /* Call the clock system intitialization function.*/
bl SystemInit bl SystemInit
/* Call the application's entry point.*/ /* Call the application's entry point.*/

View File

@ -138,6 +138,19 @@ LoopFillZerofastram_bss:
cmp r2, r3 cmp r2, r3
bcc FillZerofastram_bss bcc FillZerofastram_bss
/* Mark the heap and stack */
ldr r2, =_heap_stack_begin
b LoopMarkHeapStack
MarkHeapStack:
movs r3, 0xa5a5a5a5
str r3, [r2], #4
LoopMarkHeapStack:
ldr r3, = _heap_stack_end
cmp r2, r3
bcc MarkHeapStack
/* Call the clock system initialization function.*/ /* Call the clock system initialization function.*/
bl SystemInit bl SystemInit
/* Call the application's entry point.*/ /* Call the application's entry point.*/

View File

@ -138,6 +138,19 @@ LoopFillZerofastram_bss:
cmp r2, r3 cmp r2, r3
bcc FillZerofastram_bss bcc FillZerofastram_bss
/* Mark the heap and stack */
ldr r2, =_heap_stack_begin
b LoopMarkHeapStack
MarkHeapStack:
movs r3, 0xa5a5a5a5
str r3, [r2], #4
LoopMarkHeapStack:
ldr r3, = _heap_stack_end
cmp r2, r3
bcc MarkHeapStack
/* Call the clock system initialization function.*/ /* Call the clock system initialization function.*/
bl SystemInit bl SystemInit
/* Call the application's entry point.*/ /* Call the application's entry point.*/

View File

@ -138,6 +138,19 @@ LoopFillZerofastram_bss:
cmp r2, r3 cmp r2, r3
bcc FillZerofastram_bss bcc FillZerofastram_bss
/* Mark the heap and stack */
ldr r2, =_heap_stack_begin
b LoopMarkHeapStack
MarkHeapStack:
movs r3, 0xa5a5a5a5
str r3, [r2], #4
LoopMarkHeapStack:
ldr r3, = _heap_stack_end
cmp r2, r3
bcc MarkHeapStack
/* Call the clock system initialization function.*/ /* Call the clock system initialization function.*/
bl SystemInit bl SystemInit
/* Call the application's entry point.*/ /* Call the application's entry point.*/

View File

@ -133,6 +133,19 @@ LoopFillZerofastram_bss:
bcc FillZerofastram_bss bcc FillZerofastram_bss
/*-----*/ /*-----*/
/* Mark the heap and stack */
ldr r2, =_heap_stack_begin
b LoopMarkHeapStack
MarkHeapStack:
movs r3, 0xa5a5a5a5
str r3, [r2], #4
LoopMarkHeapStack:
ldr r3, = _heap_stack_end
cmp r2, r3
bcc MarkHeapStack
/* Call the clock system intitialization function.*/ /* Call the clock system intitialization function.*/
bl SystemInit bl SystemInit
/* Call static constructors */ /* Call static constructors */

View File

@ -90,7 +90,7 @@
#define USE_PARAMETER_GROUPS #define USE_PARAMETER_GROUPS
#undef STACK_CHECK // I think SITL don't need this #undef USE_STACK_CHECK // I think SITL don't need this
#undef USE_DASHBOARD #undef USE_DASHBOARD
#undef USE_TELEMETRY_LTM #undef USE_TELEMETRY_LTM
#undef USE_ADC #undef USE_ADC

View File

@ -23,7 +23,10 @@
#define TARGET_BOARD_IDENTIFIER "SDF4" #define TARGET_BOARD_IDENTIFIER "SDF4"
#define USBD_PRODUCT_STRING "STM32F4DISCOVERY" #define USBD_PRODUCT_STRING "STM32F4DISCOVERY"
// These features are in here to get coverage in CI builds
#define USE_SPI_TRANSACTION #define USE_SPI_TRANSACTION
#define USE_STACK_CHECK
//LEDs //LEDs
#define LED0_PIN PD12 #define LED0_PIN PD12