RISC-V vPortSetupTimer Bug

bdawood wrote on Tuesday, July 23, 2019:

Hello all,
We have using FreeRTOS for HART 0 in our chips. This has been working fine. When trying to run FreeRTOS on a second HART, non of the threads were invoked. Looking deeper, I think I found a bug in the timer setup function vPortTimerSetup (and also in the timer irq handling). The main source of the bug is this line https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Source/portable/GCC/RISC-V/port.c#l78
This sets to pullMachineTimerCompareRegister always to address of HART 0 compare register (0x2004000). While in a multi-hart core, this should be set to 0x2004000 + HART_ID * 8. Same address is used in the interrupt handler.

I’m attaching a modified port.c with a fix to verify.

rtel wrote on Tuesday, July 23, 2019:

Thanks for taking the time to report. So far we have only run on single
HART devices so this is really good input.