Skip to content

Commit a048951

Browse files
tmlemankv2019i
authored andcommitted
zephyr: cpu: secondary core idle thread init
Idle thread should be initialize only when core it booting for the first time. Doing this again would overwrite the kernel structs and the idle thread stack. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 4123f95 commit a048951

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

zephyr/lib/cpu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ int cpu_enable_core(int id)
7979
return 0;
8080

8181
#if ZEPHYR_VERSION(3, 0, 99) <= ZEPHYR_VERSION_CODE
82-
z_init_cpu(id);
82+
/* During kernel initialization, the next pm state is set to ACTIVE. By checking this
83+
* value, we determine if this is the first core boot, if not, we need to skip idle thread
84+
* initialization. By reinitializing the idle thread, we would overwrite the kernel structs
85+
* and the idle thread stack.
86+
*/
87+
if (pm_state_next_get(id)->state == PM_STATE_ACTIVE)
88+
z_init_cpu(id);
8389
#endif
8490

8591
atomic_clear(&start_flag);

0 commit comments

Comments
 (0)