Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
hal
Posts: 8
Joined: Fri Nov 02, 2012 3:07 pm
Has thanked: 2 times
Been thanked: 1 time

Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE  Topic is solved

Postby hal » Fri Sep 03, 2021 4:32 pm

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

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Postby Giovanni » Fri Sep 03, 2021 5:08 pm

hi,

Thanks, will be fixed in 21.6.1.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Postby Giovanni » Sat Sep 04, 2021 9:02 am

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

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Postby Giovanni » Sat Sep 04, 2021 9:28 am

Hi,

Fixed as bug #1183.

Giovanni

hal
Posts: 8
Joined: Fri Nov 02, 2012 3:07 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Linker errors on #define CH_CFG_NO_IDLE_THREAD TRUE

Postby hal » Mon Sep 06, 2021 8:40 am

Thanks for clarification about the main thread!


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 7 guests