freertos10_xilinx: FreeRTOS tick runs 10x slow when generate_runtime_stats=1 on MicroBlaze + AXI Timer

Aperta Adatta ai principianti
#393 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
embedded-iot

Direzione di ricerca

Leggi Source/portable/GCC/MicroBlazeV9/portmicroblaze.c e confronta il calcolo del periodo di AXI Timer con i percorsi TTCPS e xiltimer, che tengono conto delle statistiche di runtime. Aggiorna il calcolo di AXI Timer per configGENERATE_RUN_TIME_STATS, quindi verifica che il periodo dell’interrupt del timer sia dieci volte la frequenza dei tick quando è abilitato e rimanga pari alla frequenza dei tick altrimenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Environment

  • Vitis Classic 2023.2, freertos10_xilinx v1_14 (FreeRTOS kernel V10.3.0)
  • MicroBlaze (v11.0) + AXI Timer + AXI INTC, no PS, no xiltimer (legacy timer mode)
  • Verified the same code is still present in current embeddedsw master (kernel V10.6.1 file)

Steps to reproduce

  1. Create a FreeRTOS BSP for MicroBlaze with an AXI Timer as tick source.
  2. Enable BSP setting generate_runtime_stats = 1 (generates configGENERATE_RUN_TIME_STATS=1).
  3. configTICK_RATE_HZ = 100, timer clock 125 MHz.

Actual behavior
The FreeRTOS tick runs 10x slow: real tick period is 100 ms instead of 10 ms. vTaskDelay(1000) takes 10 s wall time. No warning is emitted anywhere.

Root cause
Source/portable/GCC/MicroBlazeV9/port.c, vPortTickISR: when configGENERATE_RUN_TIME_STATS == 1, xTaskIncrementTick() is called only every 10th interrupt:

#if (configGENERATE_RUN_TIME_STATS == 1)
	ulHighFrequencyTimerTicks++;
	if (!(ulHighFrequencyTimerTicks % 10))
#endif
	{ xTaskIncrementTick(); ... }

This requires the timer interrupt to be configured at configTICK_RATE_HZ * 10. The TTCPS path and the xiltimer path both implement this (with comments stating the ×10 is required and hard coded). However the AXI Timer path in portmicroblaze.c computes the period unconditionally, with no configGENERATE_RUN_TIME_STATS branch:

const unsigned long ulCounterValue = ( ( XPAR_TMRCTR_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );

(Line ~185 in v1_14; same in master: ThirdParty/bsp/freertos10_xilinx/src/Source/portable/GCC/MicroBlazeV9/portmicroblaze.c)

So the interrupt still fires at tick rate, the ISR divides by 10, and the tick comes out 10x slow.

Suggested fix

#if ( configGENERATE_RUN_TIME_STATS == 1 )
	const unsigned long ulCounterValue = ( ( XPAR_TMRCTR_0_CLOCK_FREQ_HZ / ( configTICK_RATE_HZ * 10UL ) ) - 1UL );
#else
	const unsigned long ulCounterValue = ( ( XPAR_TMRCTR_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );
#endif

Workaround (verified on hardware)
The application overrides the weak vApplicationSetupTimerInterrupt() with a copy of the default implementation using the corrected period above. Tick returns to the correct rate; runtime stats counter then increments at 10x tick rate as intended.

Impact
Any MicroBlaze + AXI Timer design that enables the documented generate_runtime_stats BSP option silently gets 10x-slow system timing. See also a similar user report: reddit.com/r/Xilinx/comments/1m1dz6l

Lingua principale
HTML
Stelle
1.2k
Fork
1.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Xilinx/embeddedsw

Tutte le issue di Xilinx/embeddedsw

Issue simili

Altre issue su Embedded & IoT

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.