Page 1 of 1

Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Posted: Fri Sep 03, 2021 4:32 pm
by hal
Hello Giovanni.

I have been playing with a demo RT-STM32F303RE-NUCLEO64. Having defined CH_CFG_NO_IDLE_THREAD as TRUE I get compiler warning "chDbgAssert(otp != chSysGetIdleThreadX(), "sleeping in idle thread");" and later linker errors with undefined references to "ch_core0_cfg" and "chSysGetIdleThreadX".

I tried to fix linker errors by wrapping missing symbols into #if CH_CFG_NO_IDLE_THREAD == FALSE

1) in chschd.c
+#if CH_CFG_NO_IDLE_THREAD == FALSE
chDbgAssert(otp != chSysGetIdleThreadX(), "sleeping in idle thread");
chDbgAssert(otp->owner == oip, "invalid core");
+#endif

2) in chsys.c.
#if (CH_CFG_NO_IDLE_THREAD == FALSE) || defined(__DOXYGEN__)
/**
* @brief Working area for core 0 idle thread.
*/
static CH_SYS_CORE0_MEMORY THD_WORKING_AREA(ch_c0_idle_thread_wa,
PORT_IDLE_THREAD_STACK_SIZE);
+#endif // < moved here from after definition of const os_instance_config_t ch_core0_cfg = {};

With that it can be linked, but the program crashes just after entering the main-loop.

hal

ChibiOS: 21.6.x
Kernel: 7.0.0
Compiler: GCC 10.2.1 20201103 (release)
Architecture: ARMv7E-M
Core Variant: Cortex-M4
Port Info: Advanced kernel mode
Platform: STM32F303xE Analog & DSP
Board: STMicroelectronics STM32 Nucleo64-F303RE
Build time: Sep 3 2021 - 16:44:26

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Posted: Fri Sep 03, 2021 5:08 pm
by Giovanni
hi,

Thanks, will be fixed in 21.6.1.

Giovanni

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Posted: Sat Sep 04, 2021 9:02 am
by Giovanni
Hi,

The fix is OK, note that if you disable the idle thread then the main() function IS the idle thread, you cannot perform chThdSleep() in there, you need to create your 1st thread then enter an infinite loop with nothing inside.

Look at NIL demos for this, NIL uses this mode by default.

Giovanni

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Posted: Sat Sep 04, 2021 9:28 am
by Giovanni
Hi,

Fixed as bug #1183.

Giovanni

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Posted: Mon Sep 06, 2021 8:40 am
by hal
Thanks for clarification about the main thread!