os/rt/src/chsys.c has
Code: Select all
void chSysInit(void) {
/* OS library modules.*/
__oslib_init();
/* Initializing default OS instance.*/
{
extern stkalign_t __main_thread_stack_base__,
__main_thread_stack_end__;
static const os_instance_config_t default_cfg = {
.name = "c0",
.mainthread_base = &__main_thread_stack_base__,
.mainthread_end = &__main_thread_stack_end__,
#if CH_CFG_NO_IDLE_THREAD == FALSE
.idlethread_base = THD_WORKING_AREA_BASE(ch_idle_thread_wa),
.idlethread_end = THD_WORKING_AREA_END(ch_idle_thread_wa)
#endif
};
chSchObjectInit(&ch, &default_cfg);
}
/* It is alive now.*/
chSysUnlock();
}
but os/rt/include/chobjects.h has
Code: Select all
/**
* @brief Type of an system instance configuration.
*/
typedef struct ch_os_instance_config {
/**
* @brief Instance name.
*/
const char *name;
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) || \
defined(__DOXYGEN__)
/**
* @brief Lower limit of the main function thread stack.
*/
stkalign_t *mainthread_base;
/**
* @brief Upper limit of the main function thread stack.
*/
stkalign_t *mainthread_end;
#endif
#if (CH_CFG_NO_IDLE_THREAD == FALSE) || defined(__DOXYGEN__)
/**
* @brief Lower limit of the dedicated idle thread stack.
*/
stkalign_t *idlethread_base;
/**
* @brief Upper limit of the dedicated idle thread stack.
*/
stkalign_t *idlethread_end;
#endif
} os_instance_config_t;
it seems
Code: Select all
.mainthread_base = &__main_thread_stack_base__,
.mainthread_end = &__main_thread_stack_end__,
as well as
Code: Select all
extern stkalign_t __main_thread_stack_base__,
__main_thread_stack_end__;
from os/rt/src/chsys.c should be wrapped into
Code: Select all
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
#endif
as well. otherwise it may fail to compile when CH_CFG_USE_DYNAMIC and CH_DBG_ENABLE_STACK_CHECK are set to FALSE.