This Thesis belongs to the field of real-time embedded systems, and more precisely to the study of the data flow inside a microcontroller running a real-time operating system. The work was carried out on a motorsport lap timer, in which a Global Navigation Satellite System (GNSS) receiver sends position, speed and time to the Microcontroller Unit (MCU) over a serial line. The firmware of the MCU runs on FreeRTOS, a widely used open-source Real-Time Operating System (RTOS) for microcontrollers. The purpose of this Thesis is the optimization of the chain of software stages that carries these messages inside the firmware, called here the Global Positioning System (GPS) pipeline. The goal is to keep the message rate as stable as possible while other tasks put load on the MCU. To do that the problem is first defined clearly, then the means to measure it are built, and the work closes with solutions and a quantification of what each one brings. The main measurement instrument is a data logger developed for this work inside the firmware. It timestamps every message on its way through the pipeline and saves the records to the internal memory of the device, where they are read back and analysed on a computer. The work started from a simple implementation issue on the GPS pipeline. It grew into a quantification of the irregularities in the message rate. The goal was to explore the different solutions that could stabilise this pipeline under external load on the board. The first step was to map the task architecture of the device. The pipeline was then instrumented with the data logger and the different measurement variables were quantified. In the end the possible solutions were explored and the efficiency of each one was discussed. Most of the effort went into making the data logger as accurate as possible, in order to evaluate whether optimization is needed at all, rather than into optimizing the pipeline in a predefined way. For this reason the document focuses mainly on how the data is gathered and validated, and on what this data shows about the pipeline. The main experimental result of this work is that the biggest source of measured jitter was the data logger itself. Two defects were found in it, a blocking display loop in the logger startup and an unsealed ring buffer read at the same time by the Interrupt Service Routine (ISR) and the flush task. Together they explained every overflow event and every latency spike in the first data set. Once they were corrected, the baseline pipeline shows an end-to-end latency of 8.90 µs mean and 20.3 µs at the 99th percentile, a standard deviation of 2.08 ms on the period of the Recommended Minimum Specific GNSS Data (RMC) message, which carries position, speed and time, no queue backlog and no dropped message across fourteen consecutive five-minute runs. When the campaign was extended to recording load and then to a full stress condition with Bluetooth and sensor traffic active, mean latency rose to 10.35 and 12.32 µs. Every reliability metric stayed the same: across 277 372 messages spanning all three conditions the queue never held a pending message and no sentence was ever dropped. A second finding concerns the 1 ms system tick counter used by the original firmware. It cannot resolve this latency at all, reading zero for 99.0 % of messages, and in one run it fabricated ±15 ms of apparent jitter on a signal that had not moved. For the latency measurement it was replaced with the cycle counter of the ARM Data Watchpoint and Trace (DWT) unit, which improved the resolution by a factor of 6 × 10⁵ and made the pipeline measurable for the first time.

La presente Tesi si colloca nell'ambito dei sistemi embedded real-time e, più precisamente, nello studio del flusso dei dati all'interno di un microcontrollore (Microcontroller Unit, MCU) su cui è in esecuzione un sistema operativo real-tim. Il lavoro è stato svolto su un cronometro per motorsport (lap timer), nel quale un ricevitore Global Navigation Satellite System (GNSS) invia posizione, velocità e tempo all'unità microcontrollore tramite linea seriale. Il firmware della MCU si basa su FreeRTOS (Real-Time Operating System, RTOS), un sistema operativo real-time open source ampiamente diffuso per microcontrollori. Lo scopo di questa Tesi è l'ottimizzazione della catena software che trasporta l’informazione GNSS all'interno del firmware, qui denominata pipeline GPS (Global Positioning System). L'obiettivo è mantenere la frequenza dei messaggi il più stabile possibile mentre altri task impongono un carico sulla MCU. A tal fine, il problema viene innanzitutto definito con chiarezza, successivamente vengono realizzati gli strumenti per misurarlo e, infine, il lavoro si conclude con la presentazione delle soluzioni e con la quantificazione del contributo di ciascuna. Il principale strumento di misura è un data logger sviluppato appositamente all'interno del firmware. Esso associa un timestamp a ogni messaggio lungo il suo percorso nella pipeline e salva i record nella memoria interna del dispositivo, da cui vengono successivamente letti e analizzati su un computer. Il lavoro è nato da un semplice problema implementativo nella pipeline GPS e si è poi sviluppato in una quantificazione delle irregolarità nella frequenza dei messaggi. L'obiettivo era esplorare le diverse soluzioni in grado di stabilizzare la pipeline in presenza di un carico esterno sulla scheda. Il primo passo è stato mappare l'architettura dei task del dispositivo. La pipeline è stata quindi strumentata con il data logger e sono state quantificate le diverse variabili di misura. Infine, sono state esplorate le possibili soluzioni ed è stata discussa l'efficacia di ciascuna. La maggior parte dell'impegno è stata dedicata a rendere il data logger il più accurato possibile. Lo scopo era valutare se un'ottimizzazione fosse effettivamente necessaria, anziché ottimizzare la pipeline secondo un approccio predefinito. Per questo motivo, il documento si concentra principalmente sulle modalità di raccolta e di validazione dei dati e su ciò che tali dati rivelano riguardo alla pipeline. Il principale risultato sperimentale di questo lavoro è che la maggiore sorgente del jitter misurato è dovuta al data logger stesso. In esso sono stati individuati due difetti. Il primo è un ciclo bloccante di gestione del display nella fase di avvio. Il secondo è un buffer circolare non protetto, letto contemporaneamente dalla routine di servizio dell'interrupt (Interrupt Service Routine, ISR) e dal task di scrittura (flush). Una volta corretti, la pipeline nella configurazione di base presenta una latenza end-to-end media di 8,90 µs e di 20,3 µs al 99° percentile. Il periodo del messaggio RMC (Recommended Minimum Specific GNSS Data), che contiene posizione, velocità e tempo, ha un jitter di 2,08 ms. Nell'arco di quattordici acquisizioni consecutive da cinque minuti non si osservano né accumuli di messaggi in coda né messaggi persi. Quando la campagna di misura è stata estesa a una condizione con carico di registrazione e, successivamente, a una condizione di stress completo con traffico Bluetooth e sensori attivi, la latenza media è salita rispettivamente a 10,35 e 12,32 µs. Tutte le metriche di affidabilità sono rimaste invariate: su 277 372 messaggi, relativi a tutte e tre le condizioni, la coda non ha mai contenuto messaggi in attesa e nessun messaggio è mai andato perso. Un secondo risultato riguarda il contatore del tick di sistema a 1 ms utilizzato nel firmware originale. Esso non è in grado di risolvere tale latenza, poiché restituisce un valore nullo per il 99,0 % dei messaggi. Inoltre, in un'acquisizione ha generato un jitter apparente di ±15 ms su un segnale rimasto invariato. Per la misura della latenza è stato quindi sostituito con il contatore di cicli dell'unità DWT (Data Watchpoint and Trace) dei processori ARM. Questa sostituzione ha migliorato la risoluzione di un fattore 6 × 10⁵ e ha reso la pipeline misurabile per la prima volta.

Experimental analysis and optimization of real-time data flow on FreeRTOS using a GPS UART pipeline

TODO, ELIOT OLIVIER
2025/2026

Abstract

This Thesis belongs to the field of real-time embedded systems, and more precisely to the study of the data flow inside a microcontroller running a real-time operating system. The work was carried out on a motorsport lap timer, in which a Global Navigation Satellite System (GNSS) receiver sends position, speed and time to the Microcontroller Unit (MCU) over a serial line. The firmware of the MCU runs on FreeRTOS, a widely used open-source Real-Time Operating System (RTOS) for microcontrollers. The purpose of this Thesis is the optimization of the chain of software stages that carries these messages inside the firmware, called here the Global Positioning System (GPS) pipeline. The goal is to keep the message rate as stable as possible while other tasks put load on the MCU. To do that the problem is first defined clearly, then the means to measure it are built, and the work closes with solutions and a quantification of what each one brings. The main measurement instrument is a data logger developed for this work inside the firmware. It timestamps every message on its way through the pipeline and saves the records to the internal memory of the device, where they are read back and analysed on a computer. The work started from a simple implementation issue on the GPS pipeline. It grew into a quantification of the irregularities in the message rate. The goal was to explore the different solutions that could stabilise this pipeline under external load on the board. The first step was to map the task architecture of the device. The pipeline was then instrumented with the data logger and the different measurement variables were quantified. In the end the possible solutions were explored and the efficiency of each one was discussed. Most of the effort went into making the data logger as accurate as possible, in order to evaluate whether optimization is needed at all, rather than into optimizing the pipeline in a predefined way. For this reason the document focuses mainly on how the data is gathered and validated, and on what this data shows about the pipeline. The main experimental result of this work is that the biggest source of measured jitter was the data logger itself. Two defects were found in it, a blocking display loop in the logger startup and an unsealed ring buffer read at the same time by the Interrupt Service Routine (ISR) and the flush task. Together they explained every overflow event and every latency spike in the first data set. Once they were corrected, the baseline pipeline shows an end-to-end latency of 8.90 µs mean and 20.3 µs at the 99th percentile, a standard deviation of 2.08 ms on the period of the Recommended Minimum Specific GNSS Data (RMC) message, which carries position, speed and time, no queue backlog and no dropped message across fourteen consecutive five-minute runs. When the campaign was extended to recording load and then to a full stress condition with Bluetooth and sensor traffic active, mean latency rose to 10.35 and 12.32 µs. Every reliability metric stayed the same: across 277 372 messages spanning all three conditions the queue never held a pending message and no sentence was ever dropped. A second finding concerns the 1 ms system tick counter used by the original firmware. It cannot resolve this latency at all, reading zero for 99.0 % of messages, and in one run it fabricated ±15 ms of apparent jitter on a signal that had not moved. For the latency measurement it was replaced with the cycle counter of the ARM Data Watchpoint and Trace (DWT) unit, which improved the resolution by a factor of 6 × 10⁵ and made the pipeline measurable for the first time.
ING - Scuola di Ingegneria Industriale e dell'Informazione
21-ott-2026
2025/2026
La presente Tesi si colloca nell'ambito dei sistemi embedded real-time e, più precisamente, nello studio del flusso dei dati all'interno di un microcontrollore (Microcontroller Unit, MCU) su cui è in esecuzione un sistema operativo real-tim. Il lavoro è stato svolto su un cronometro per motorsport (lap timer), nel quale un ricevitore Global Navigation Satellite System (GNSS) invia posizione, velocità e tempo all'unità microcontrollore tramite linea seriale. Il firmware della MCU si basa su FreeRTOS (Real-Time Operating System, RTOS), un sistema operativo real-time open source ampiamente diffuso per microcontrollori. Lo scopo di questa Tesi è l'ottimizzazione della catena software che trasporta l’informazione GNSS all'interno del firmware, qui denominata pipeline GPS (Global Positioning System). L'obiettivo è mantenere la frequenza dei messaggi il più stabile possibile mentre altri task impongono un carico sulla MCU. A tal fine, il problema viene innanzitutto definito con chiarezza, successivamente vengono realizzati gli strumenti per misurarlo e, infine, il lavoro si conclude con la presentazione delle soluzioni e con la quantificazione del contributo di ciascuna. Il principale strumento di misura è un data logger sviluppato appositamente all'interno del firmware. Esso associa un timestamp a ogni messaggio lungo il suo percorso nella pipeline e salva i record nella memoria interna del dispositivo, da cui vengono successivamente letti e analizzati su un computer. Il lavoro è nato da un semplice problema implementativo nella pipeline GPS e si è poi sviluppato in una quantificazione delle irregolarità nella frequenza dei messaggi. L'obiettivo era esplorare le diverse soluzioni in grado di stabilizzare la pipeline in presenza di un carico esterno sulla scheda. Il primo passo è stato mappare l'architettura dei task del dispositivo. La pipeline è stata quindi strumentata con il data logger e sono state quantificate le diverse variabili di misura. Infine, sono state esplorate le possibili soluzioni ed è stata discussa l'efficacia di ciascuna. La maggior parte dell'impegno è stata dedicata a rendere il data logger il più accurato possibile. Lo scopo era valutare se un'ottimizzazione fosse effettivamente necessaria, anziché ottimizzare la pipeline secondo un approccio predefinito. Per questo motivo, il documento si concentra principalmente sulle modalità di raccolta e di validazione dei dati e su ciò che tali dati rivelano riguardo alla pipeline. Il principale risultato sperimentale di questo lavoro è che la maggiore sorgente del jitter misurato è dovuta al data logger stesso. In esso sono stati individuati due difetti. Il primo è un ciclo bloccante di gestione del display nella fase di avvio. Il secondo è un buffer circolare non protetto, letto contemporaneamente dalla routine di servizio dell'interrupt (Interrupt Service Routine, ISR) e dal task di scrittura (flush). Una volta corretti, la pipeline nella configurazione di base presenta una latenza end-to-end media di 8,90 µs e di 20,3 µs al 99° percentile. Il periodo del messaggio RMC (Recommended Minimum Specific GNSS Data), che contiene posizione, velocità e tempo, ha un jitter di 2,08 ms. Nell'arco di quattordici acquisizioni consecutive da cinque minuti non si osservano né accumuli di messaggi in coda né messaggi persi. Quando la campagna di misura è stata estesa a una condizione con carico di registrazione e, successivamente, a una condizione di stress completo con traffico Bluetooth e sensori attivi, la latenza media è salita rispettivamente a 10,35 e 12,32 µs. Tutte le metriche di affidabilità sono rimaste invariate: su 277 372 messaggi, relativi a tutte e tre le condizioni, la coda non ha mai contenuto messaggi in attesa e nessun messaggio è mai andato perso. Un secondo risultato riguarda il contatore del tick di sistema a 1 ms utilizzato nel firmware originale. Esso non è in grado di risolvere tale latenza, poiché restituisce un valore nullo per il 99,0 % dei messaggi. Inoltre, in un'acquisizione ha generato un jitter apparente di ±15 ms su un segnale rimasto invariato. Per la misura della latenza è stato quindi sostituito con il contatore di cicli dell'unità DWT (Data Watchpoint and Trace) dei processori ARM. Questa sostituzione ha migliorato la risoluzione di un fattore 6 × 10⁵ e ha reso la pipeline misurabile per la prima volta.
File allegati
File Dimensione Formato  
2026_10_Todo.pdf

non accessibile

Descrizione: Full thesis file
Dimensione 5.18 MB
Formato Adobe PDF
5.18 MB Adobe PDF   Visualizza/Apri

I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10589/265419