Skip to content

Commit 5d32e80

Browse files
committed
freertos: ensure interrupts are disabled before enabling tick timer
xPortStartScheduler calls vPortSetupTimer -> _frxt_tick_timer_init, which enables tick timer interrupt and sets up the first timeout. From that point on, the interrupt can fire. If the interrupt happens while _frxt_dispatch is running, the scheduler will enter an infinite loop. This is because _frxt_dispatch isn't supposed to be preemptable, and the tick interrupt will overwrite some of the registers used by _frxt_dispatch. Note that this situation doesn't practically occur on the real hardware, where the execution of vPortSetupTimer and _frxt_dispatch happens quickly enough. However it can be reproduced on an emulator if the tick period is set to 1ms. Add an explicit call to portDISABLE_INTERRUPTS in xPortStartScheduler to guarantee that _frxt_dispatch doesn't run with interrupts enabled. This is similar to the esprv_intc_int_set_threshold(1); call in RISC-V version of port.c.
1 parent 2a8ef21 commit 5d32e80

File tree

1 file changed

+1
-0
lines changed
  • components/freertos/FreeRTOS-Kernel/portable/xtensa

1 file changed

+1
-0
lines changed

components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ extern void _xt_coproc_init(void);
9494

9595
BaseType_t xPortStartScheduler( void )
9696
{
97+
portDISABLE_INTERRUPTS();
9798
// Interrupts are disabled at this point and stack contains PS with enabled interrupts when task context is restored
9899

99100
#if XCHAL_CP_NUM > 0

0 commit comments

Comments
 (0)