From 4866a78e634c0bdcec41fcc4447b075264d3f3db Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sat, 14 Dec 2019 06:31:13 -0800 Subject: [PATCH] Re-shrink stacks (#1060) * small stacks * giant servo stack * reclaim ram --- firmware/config/stm32f4ems/chconf.h | 2 +- firmware/config/stm32f7ems/chconf.h | 2 +- firmware/controllers/engine_controller.cpp | 2 +- firmware/hw_layer/servo.cpp | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/firmware/config/stm32f4ems/chconf.h b/firmware/config/stm32f4ems/chconf.h index a3fd922f5d..c9a783c24a 100644 --- a/firmware/config/stm32f4ems/chconf.h +++ b/firmware/config/stm32f4ems/chconf.h @@ -45,7 +45,7 @@ // See global_shared.h notes about stack requirements // see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks -#define PORT_INT_REQUIRED_STACK 400 +#define PORT_INT_REQUIRED_STACK 128 #define CHPRINTF_USE_FLOAT TRUE diff --git a/firmware/config/stm32f7ems/chconf.h b/firmware/config/stm32f7ems/chconf.h index 13b088db86..35a4721ef1 100644 --- a/firmware/config/stm32f7ems/chconf.h +++ b/firmware/config/stm32f7ems/chconf.h @@ -45,7 +45,7 @@ // See global_shared.h notes about stack requirements // see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks -#define PORT_INT_REQUIRED_STACK 400 +#define PORT_INT_REQUIRED_STACK 128 #define CHPRINTF_USE_FLOAT TRUE diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index c682519595..153b3ef331 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -798,7 +798,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) // help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail // linking process which is the way to raise the alarm #ifndef RAM_UNUSED_SIZE -#define RAM_UNUSED_SIZE 10000 +#define RAM_UNUSED_SIZE 14000 #endif #ifndef CCM_UNUSED_SIZE #define CCM_UNUSED_SIZE 4600 diff --git a/firmware/hw_layer/servo.cpp b/firmware/hw_layer/servo.cpp index 191657dd73..0a398eb3f3 100644 --- a/firmware/hw_layer/servo.cpp +++ b/firmware/hw_layer/servo.cpp @@ -20,7 +20,10 @@ EXTERN_ENGINE; -THD_WORKING_AREA(servoThreadStack, UTILITY_THREAD_STACK_SIZE); +// This thread calls scheduleForLater which eventually could trip the main trigger callback +// if self stimulation (heh) is enabled, which uses a TON of stack space. +// So this stack has to be pretty big, unfortunately. +THD_WORKING_AREA(servoThreadStack, UTILITY_THREAD_STACK_SIZE * 3); static OutputPin pins[SERVO_COUNT];