BAREMETAL↗Source code ↗
ARMAN ISLAM / SUMMER 2025

A lot to understand

A drone built from scratch, right down to the code that talks to the hardware.

How does code make it move? ↓
CONTROLLERSTM32F103RB
CORE CLOCK72 MHz
MOTOR PWM20 kHz
APPROACHZero HAL
01 / THE IDEA

How much of a flying
machine can you build yourself?

That question became a summer project.

Over summer break in 2025, I set out to build a drone and understand the system beneath it. The firmware is written from scratch, including the peripheral drivers. Only the startup and linker files are reused.

This is the record of that process: a bare-metal quadcopter, from the first register writes to the motor-control loop.

ARMAN ISLAM / BUILDER & DEVELOPER
02 / THE HARDWARE

Built on the bench.

The actual prototype with STM32 board, breadboard, motor drivers, and jumper wiring on the workbench
THE FIRST CONNECTIONSPROJECT PHOTO ↗

A compact frame. Four brushed motors. A controller with nothing hidden behind a library.

Microcontroller
STM32F103RB
Motion sensor
MPU6050 · I²C
Motor drivers
LP9110s
Propellers
DJI Tello
Motor type
Brushed DC
Frame dimensions
12 × 12 × 3 in
Open the wiring schematic ↗
03 / TALKING TO THE HARDWARE

Code goes in.
Something real happens.

A driver is the translator between software and electronics. In this project, I wrote that translator myself: C code writes directly to the STM32’s hardware registers, which configure the peripherals connected to the drone.

01 / YOUR C CODE
motor_set(0, 500);

Ask motor 0 for 50% PWM duty.

02 / STM32 REGISTERTIM2 → CCR1

Write 1800 into the timer’s compare register.

03 / THE REAL WORLDMotor driver → motor

The timer produces a 20 kHz waveform. The motor driver switches power to the motor.

This is what “bare metal” means: the driver touches the hardware registers directly. There’s no HAL doing the register configuration for you.

REAL SOURCE, SIMPLIFIED EXAMPLE

This diagram explains the signal path; it does not control a drone. Actual motors stay off in the default firmware build.

See this driver on GitHub ↗
04 / WORK IN PROGRESS

Engineering is iteration.

The current firmware supports an opt-in timed attitude-control run. Sensor errors, excessive tilt or rotation, and late loop iterations stop the motors. Controller gains still need bench tuning.

CURRENT LIMITATIONS

Still a prototype.

No RC control, altitude sensor, battery monitor, or independent motor kill input. A timed PWM ramp cannot guarantee a controlled landing.

WHAT'S NEXT

More control. More checks.

RC control and additional assertions and safety cases are planned. Validation starts with propellers removed, followed by a restrained rig and external power cutoff.

FOLLOW THE BUILD

The details are
in the source.

Explore the repository ↗

Firmware, wiring, frame files, and project notes.