From 040bad042544a8921678cfcc274c29e348cf767d Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 27 Jul 2020 09:42:07 +0200 Subject: [PATCH] cpu/atmega_common: increase stack size with xtimer If a timer triggers while the idle thread is running, previously a stack overflow was triggered. This commit increases the idle threads stack size if xtimer is used. --- cpu/atmega_common/include/cpu_conf.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpu/atmega_common/include/cpu_conf.h b/cpu/atmega_common/include/cpu_conf.h index bd00d7e278..e97dd2fb0d 100644 --- a/cpu/atmega_common/include/cpu_conf.h +++ b/cpu/atmega_common/include/cpu_conf.h @@ -49,8 +49,16 @@ extern "C" { * to avoid not printing of debug in interrupts */ #ifndef THREAD_STACKSIZE_IDLE +#ifdef MODULE_XTIMER +/* xtimer's 64 bit arithmetic doesn't perform well on 8 bit archs. In order to + * prevent a stack overflow when an timer triggers while the idle thread is + * running, we have to increase the stack size then + */ +#define THREAD_STACKSIZE_IDLE (192) +#else #define THREAD_STACKSIZE_IDLE (128) #endif +#endif /** @} */ /**