Me and my friend are attempting to build a drone that goes 200 mph, while designing everything from scratch. I am going to be focusing on the software part of the project, making a real time operating system (RTOS), in order to schedule processes, run PID loops etc.
C
2
24 commits
updated Sep 21, 2026
My friend and I are attempting to build a drone that goes 200 mph while designing everything from scratch. I am going to be focusing on the software part of the project, making a Real-Time Operating System (RTOS), to schedule processes, run PID loops, etc., with minimal latency.
To safely control a quadcopter moving at these extreme velocities, standard cooperative loop structures are not fast enough. A single delayed calculation or blocked process means the drone travels dozens of feet before the next correction can be made. This repository contains a custom-built, hybrid cooperative/preemptive real-time operating system (RTOS) designed from the ground up for the STM32F7 (ARM Cortex-M7) microcontroller to achieve ultra-low latency, deterministic flight control.
At 200 MPH, flight stabilization calculations cannot wait for background tasks like GPS parsing, battery monitoring, or telemetry transmission.
My hybrid RTOS solves this by dividing the execution into two distinct areas:
PendSV exception vector to execute instant, deterministic stack swaps.PendSV_Handler.S) to preserve the entire CPU register set (R4-R11 manually and hardware-stacked registers) during preemptive swaps, preventing task loss and memory corruption.initializeNewTask()) to natively separate SCHEDULED tasks from asynchronous INTERRUPT tasks without relying on "hacky" task parameters (e.g., 0 ms execution time).I have set up an interactive simulation environment using Renode so that reviewers can watch the preemption kernel work in real-time on a virtual STM32F7, without needing physical hardware.
During the simulation, a low-priority background task continuously increments a counter. To simulate real-world asynchronous hardware events, an inline random-number generator inside the SysTick_Handler periodically triggers a high-priority interrupt task. You will see the interrupt seamlessly hijack the CPU, print the perfectly preserved counter state, run a heavy processing delay, and hand control back to the exact instruction where the counter left off.
Disclaimer: I did not write any of the .bat files you see (those were done by AI as I do not have a Windows device)
brew install renode on macOS / sudo apt install renode on Linux).git clone https://github.com/Guag914/200-MPH-Drone-RTOS.git
cd 200-MPH-Drone-RTOS
chmod +x run.sh
./run.sh
run.bat
User_Tasks/user_tasks.cpp, you must install the arm-none-eabi-gcc, and arm-none-eabi-g++ compilers.
Go to https://developer.arm.com/downloads/-/gnu-rm and download the exe
Run the installer, and make sure to check the box that says Add path to envirnment variable
Test the installation with:
arm-none-eabi-gcc --version
Install it with:
brew install armmbed/formulae/arm-none-eabi-gcc
Test the installation with:
arm-none-eabi-gcc --version
Install it with:
sudo apt update
sudo apt install gcc-arm-none-eabi
Test the installation with:
arm-none-eabi-gcc --version
Once you have modified User_Tasks/user_tasks.cpp with your own loops, you must recompile the binary so the simulator can run your updated code.
chmod +x build.sh
./build.sh
build.bat
--debug #ensures methods log to usart1 peripheral (not usable with user mode)
sim #enables sim mode, allowing renode to simulate the hardware
user #disables drone tasks, and allows the user to compile their own tasks via User_Tasks.cpp
./build.sh sim --debug #run this mode to see the drone tasks actively running
./build.sh user #run this mode to compile your own tasks
build.bat sim --debug #run this mode to see the drone tasks actively running
build.bat user #run this mode to compile your own tasks
/src/flight - Core flight controller application code:
Tasks.cpp - Raw IMU processing, CRSF bitwise radio packet parsing, and failsafe logic.BufferPopulation.cpp - Low-level DMA and SPI register config + read and write to populate buffers needed for calculations.src/rtos - The custom RTOS kernel:
Main.cpp / rtos.h - Task control blocks, prioritized scheduler, and overload initializers.PendSV_Handler.S - Core assembly routine saving/restoring CPU context registers (R4-R11).| Phase | Name | Description | Status |
|---|---|---|---|
| #1 | Custom RTOS Kernel | Execute both preemptive and cooperative tasks with a priority-based system | Complete |
| #2 | Flight Dynamics | PT1 Low-Pass Filtering, Axis Alignment Mapping, OSD Warn State Machine | Complete |
| #3 | Controller Loops | High rate PID controller loop and DShot generation | Complete |
| #4 | Hardware Integration | Full Software-In-Loop (SIL) simulation for the ESC and transmitter modules | Complete |
| #5 | User Features | CLI for config, CPP bootloader for microcontrollers, USBC integration for bench testing | Complete |
As for a timeline, I am hoping to get the entire system done before around July 27th. Of course when my friend finishes the hardware portion of the project, we will merge the custom PCBs and the operating system to create a fully functional high-speed drone.
The first version of the drone will likely be done around mid-August, with the final version being completed around the end of August.
Edit: Essentially with school kicking in, it has been super hard to be consistent with work times and everything, however my friend managed to finish a substantial portion of the PCB's, and I managed to get the RTOS booting on an actual STM32 Nucelo board.
Although there are a few bugs still left in the code (mainly having to do with the scheduling of interrupt tasks) I can confidently say that 95% of my code works on actual hardware. With a few more hard weeks of coding, I should be able to completely debug everything, make all the firmware + bootloader for compnents such as the ESC and RM, and test everything that the actual drone will run (by simulating all my peripherals on a second nucleo).
A realistic deadline for all the PCB's (from my friend) and my RTOS being ready to merge is around mid-late November.
C
96.9%
C++
2.3%
Me and my friend are attempting to build a drone that goes 200 mph, while designing everything from scratch. I am going to be focusing on the software part of the project, making a real time operating system (RTOS), in order to schedule processes, run PID loops etc.
C
2
24 commits
updated Sep 21, 2026
My friend and I are attempting to build a drone that goes 200 mph while designing everything from scratch. I am going to be focusing on the software part of the project, making a Real-Time Operating System (RTOS), to schedule processes, run PID loops, etc., with minimal latency.
To safely control a quadcopter moving at these extreme velocities, standard cooperative loop structures are not fast enough. A single delayed calculation or blocked process means the drone travels dozens of feet before the next correction can be made. This repository contains a custom-built, hybrid cooperative/preemptive real-time operating system (RTOS) designed from the ground up for the STM32F7 (ARM Cortex-M7) microcontroller to achieve ultra-low latency, deterministic flight control.
At 200 MPH, flight stabilization calculations cannot wait for background tasks like GPS parsing, battery monitoring, or telemetry transmission.
My hybrid RTOS solves this by dividing the execution into two distinct areas:
PendSV exception vector to execute instant, deterministic stack swaps.PendSV_Handler.S) to preserve the entire CPU register set (R4-R11 manually and hardware-stacked registers) during preemptive swaps, preventing task loss and memory corruption.initializeNewTask()) to natively separate SCHEDULED tasks from asynchronous INTERRUPT tasks without relying on "hacky" task parameters (e.g., 0 ms execution time).I have set up an interactive simulation environment using Renode so that reviewers can watch the preemption kernel work in real-time on a virtual STM32F7, without needing physical hardware.
During the simulation, a low-priority background task continuously increments a counter. To simulate real-world asynchronous hardware events, an inline random-number generator inside the SysTick_Handler periodically triggers a high-priority interrupt task. You will see the interrupt seamlessly hijack the CPU, print the perfectly preserved counter state, run a heavy processing delay, and hand control back to the exact instruction where the counter left off.
Disclaimer: I did not write any of the .bat files you see (those were done by AI as I do not have a Windows device)
brew install renode on macOS / sudo apt install renode on Linux).git clone https://github.com/Guag914/200-MPH-Drone-RTOS.git
cd 200-MPH-Drone-RTOS
chmod +x run.sh
./run.sh
run.bat
User_Tasks/user_tasks.cpp, you must install the arm-none-eabi-gcc, and arm-none-eabi-g++ compilers.
Go to https://developer.arm.com/downloads/-/gnu-rm and download the exe
Run the installer, and make sure to check the box that says Add path to envirnment variable
Test the installation with:
arm-none-eabi-gcc --version
Install it with:
brew install armmbed/formulae/arm-none-eabi-gcc
Test the installation with:
arm-none-eabi-gcc --version
Install it with:
sudo apt update
sudo apt install gcc-arm-none-eabi
Test the installation with:
arm-none-eabi-gcc --version
Once you have modified User_Tasks/user_tasks.cpp with your own loops, you must recompile the binary so the simulator can run your updated code.
chmod +x build.sh
./build.sh
build.bat
--debug #ensures methods log to usart1 peripheral (not usable with user mode)
sim #enables sim mode, allowing renode to simulate the hardware
user #disables drone tasks, and allows the user to compile their own tasks via User_Tasks.cpp
./build.sh sim --debug #run this mode to see the drone tasks actively running
./build.sh user #run this mode to compile your own tasks
build.bat sim --debug #run this mode to see the drone tasks actively running
build.bat user #run this mode to compile your own tasks
/src/flight - Core flight controller application code:
Tasks.cpp - Raw IMU processing, CRSF bitwise radio packet parsing, and failsafe logic.BufferPopulation.cpp - Low-level DMA and SPI register config + read and write to populate buffers needed for calculations.src/rtos - The custom RTOS kernel:
Main.cpp / rtos.h - Task control blocks, prioritized scheduler, and overload initializers.PendSV_Handler.S - Core assembly routine saving/restoring CPU context registers (R4-R11).| Phase | Name | Description | Status |
|---|---|---|---|
| #1 | Custom RTOS Kernel | Execute both preemptive and cooperative tasks with a priority-based system | Complete |
| #2 | Flight Dynamics | PT1 Low-Pass Filtering, Axis Alignment Mapping, OSD Warn State Machine | Complete |
| #3 | Controller Loops | High rate PID controller loop and DShot generation | Complete |
| #4 | Hardware Integration | Full Software-In-Loop (SIL) simulation for the ESC and transmitter modules | Complete |
| #5 | User Features | CLI for config, CPP bootloader for microcontrollers, USBC integration for bench testing | Complete |
As for a timeline, I am hoping to get the entire system done before around July 27th. Of course when my friend finishes the hardware portion of the project, we will merge the custom PCBs and the operating system to create a fully functional high-speed drone.
The first version of the drone will likely be done around mid-August, with the final version being completed around the end of August.
Edit: Essentially with school kicking in, it has been super hard to be consistent with work times and everything, however my friend managed to finish a substantial portion of the PCB's, and I managed to get the RTOS booting on an actual STM32 Nucelo board.
Although there are a few bugs still left in the code (mainly having to do with the scheduling of interrupt tasks) I can confidently say that 95% of my code works on actual hardware. With a few more hard weeks of coding, I should be able to completely debug everything, make all the firmware + bootloader for compnents such as the ESC and RM, and test everything that the actual drone will run (by simulating all my peripherals on a second nucleo).
A realistic deadline for all the PCB's (from my friend) and my RTOS being ready to merge is around mid-late November.
C
96.9%
C++
2.3%