From 85fe8fcfe6f27b16e21fa21d4c6b27ed5b802961 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Tue, 24 Sep 2024 13:13:59 +0300 Subject: [PATCH] arch/risc-v/src/common/riscv_initialstate.c: Fix stack pointer in coloration The logical CPU index should be retrieved with up_cpu_index(); the riscv_mhartid() returns the actual hart id of the SoC. For mpfs target for example, NuttX can run on a single HART, for example on mhartid 2, but there is still just one logical CPU for the NuttX. Signed-off-by: Jukka Laitinen --- arch/risc-v/src/common/riscv_initialstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/risc-v/src/common/riscv_initialstate.c b/arch/risc-v/src/common/riscv_initialstate.c index 014ad62280c3c..95183904ce841 100644 --- a/arch/risc-v/src/common/riscv_initialstate.c +++ b/arch/risc-v/src/common/riscv_initialstate.c @@ -97,7 +97,7 @@ void up_initial_state(struct tcb_s *tcb) if (tcb->pid == IDLE_PROCESS_ID) { - tcb->stack_alloc_ptr = (void *)g_cpux_idlestack(riscv_mhartid()); + tcb->stack_alloc_ptr = (void *)g_cpux_idlestack(up_cpu_index()); tcb->stack_base_ptr = tcb->stack_alloc_ptr; tcb->adj_stack_size = SMP_STACK_SIZE;