diff --git a/platforms/nuttx/src/px4/microchip/mpfs/board_reset/board_reset.cpp b/platforms/nuttx/src/px4/microchip/mpfs/board_reset/board_reset.cpp index 1a58f128c0e1..dd55627d406d 100644 --- a/platforms/nuttx/src/px4/microchip/mpfs/board_reset/board_reset.cpp +++ b/platforms/nuttx/src/px4/microchip/mpfs/board_reset/board_reset.cpp @@ -96,12 +96,16 @@ static void board_reset_enter_bootloader_and_continue_boot() static int board_reset_enter_app(FAR void *arg) { - uintptr_t hartid = riscv_mhartid(); + uintptr_t hartid; /* Mask local interrupts */ up_irq_save(); + /* It is now safe to read and hold hartid locally (CPU cannot change) */ + + hartid = riscv_mhartid(); + #ifdef CONFIG_SMP /* Notify that this CPU is paused */