diff --git a/src/drivers/nuttx/lv_nuttx_entry.c b/src/drivers/nuttx/lv_nuttx_entry.c index f1c212ef4..cb5505e54 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.c +++ b/src/drivers/nuttx/lv_nuttx_entry.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "lv_nuttx_cache.h" #include "lv_nuttx_image_cache.h" #include "lv_nuttx_profiler.h" @@ -23,7 +24,15 @@ /********************* * DEFINES *********************/ + #define nuttx_ctx_p (LV_GLOBAL_DEFAULT()->nuttx_ctx) + +#if (LV_USE_FREETYPE || LV_USE_THORVG) + #define LV_NUTTX_MIN_STACK_SIZE (32 * 1024) +#else + #define LV_NUTTX_MIN_STACK_SIZE (8 * 1024) +#endif + /********************** * TYPEDEFS **********************/ @@ -36,6 +45,7 @@ static uint32_t millis(void); #if LV_USE_LOG static void syslog_print(lv_log_level_t level, const char * buf); #endif +static void check_stack_size(void); /********************** * STATIC VARIABLES @@ -102,6 +112,8 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result) #endif lv_tick_set_cb(millis); + check_stack_size(); + lv_nuttx_cache_init(); lv_nuttx_image_cache_init(); @@ -234,4 +246,16 @@ static void syslog_print(lv_log_level_t level, const char * buf) } #endif +static void check_stack_size(void) +{ + pthread_t tid = pthread_self(); + ssize_t stack_size = pthread_get_stacksize_np(tid); + LV_LOG_USER("tid: %d, Stack size : %zd", (int)tid, stack_size); + + if(stack_size < LV_NUTTX_MIN_STACK_SIZE) { + LV_LOG_ERROR("Stack size is too small. Please increase it to %d bytes or more.", + LV_NUTTX_MIN_STACK_SIZE); + } +} + #endif /*LV_USE_NUTTX*/