Developer 01

Developing PteronautOS

Build, configure, and extend the hermetic firmware. This guide assumes you are comfortable with the command line.

PteronautOS is a fork of ExpressLRS 4.x turned into a flight controller for servo-driven ornithopters, running on the ESP8285 @ 80 MHz / 1 MB flash.

If you only want a local build to flash, skip to the flash.sh guide — it wraps everything below into one command.

1 · Toolchain prerequisites

Follow the ExpressLRS toolchain installation guide first — it is the single authoritative setup for the exact PlatformIO + ESP8266 toolchain this fork uses.

Requirement Notes
PlatformIO Core `pio` on PATH — pulls the ESP8266/Arduino toolchain on first build
Node.js `20.x` (`.nvmrc` pins 20.20.2) — use `nvm use 20`
Git to clone the repository
Python 3 for the image verifier and build scripts

If you already have PlatformIO installed, verify it:

pio --version
node --version   # should print v20.x

Windows setup (no VS Code needed)

On Windows you don't need VS Code — everything runs from the console. Paste this once into PowerShell (or Windows Terminal):

winget install --id Git.Git -e
winget install --id OpenJS.NodeJS.LTS -e
winget install --id Python.Python.3.12 -e
python -m pip install -U platformio

Then open Git Bash (installed with Git) and run every command from there — git, pio, npm and ./scripts/flash.sh all work unchanged. On Windows, skip nvm use 20: Node 20 is already on your PATH, so just run npm run build:pteronautos directly.

No winget? Install Git, Node.js 20 and Python from their official download pages, then run the PlatformIO line above.

2 · Getting the code

git clone https://github.com/dantiel/PteronautOS.git
cd PteronautOS

The project is a self-contained PlatformIO project rooted at `src/`, with no third-party libraries outside the target `lib_deps`.

3 · Repository layout

Path Purpose
src/platformio.ini PlatformIO root — lists the target .ini files
src/targets/pteronautos-rx.ini PteronautOS target definitions (the envs you build)
src/targets/common.ini Shared ELRS / ESP8285 platform config
src/lib/Ornithopter/ Wing / motor mixer — waveform, gearbox, channel filter
src/lib/Zephyrus/ Gyro (MPU6050 / LSM6DS3) + Mesozoic stabilizer
src/lib/ServoOutput/ PWM output synced to the CRSF tick
src/lib/WIFI/ WebUI config server + PteroWebHandlers.cpp
src/lib/Mushin/ EP2 + RP2040 companion bridge
src/html/ WebUI source (Vite + CoffeeScript + Haml/Lithaml)
src/python/ Build / pre-build scripts, image verifier
src/src/rx_main.cpp Entry point (forked ELRS RX loop)
src/user_defines.txt Your compile-time overrides (gitignored)
src/user_defines.txt.example Template for user_defines.txt
scripts/flash.sh One-command build + flash wrapper
hermetic.manifest.md Mission, architecture, and build prohibitions

4 · Build order (the one thing that trips people up)

PteronautOS builds in two stages, and they must run in this order:

Stage Output
WebUI src/html/headers/web-pteronautos-rx-8285.h
Firmware src/.pio/build/<env>/firmware.bin

The firmware build runs copy_html.py as a pre-build step, copying the WebUI header into WebContent.h. Build the WebUI first or you'll bake a stale WebUI into the image.

Build the WebUI

cd src/html
nvm use 20
I18N_LOCALES=en npm run build:pteronautos

I18N_LOCALES selects which languages are baked in:

I18N_LOCALES=en        npm run build:pteronautos   # English only (smallest)
I18N_LOCALES=en,de     npm run build:pteronautos   # English + German
I18N_LOCALES=all       npm run build:pteronautos   # all 11 languages

Build the firmware

cd ../.. && pio run -d src -e PteronautOS_ESP8285_2400_RX

The binary lands in src/.pio/build/PteronautOS_ESP8285_2400_RX/firmware.bin.

5 · Target environments

Defined in src/targets/pteronautos-rx.ini:

Environment Description
PteronautOS_ESP8285_2400_RX PWMP7, no gyro (Mesozoic rate damper compiled but off)
PteronautOS_ESP8285_2400_RX_HORIZON PWMP7, gyro + self-level (HORIZON) + baro
PteronautOS_ESP8285_2400_RX_PWMP5 PWMP5 (5 pads, GPIO5 = radio BUSY)
PteronautOS_ESP8285_2400_RX_PWMP5_HORIZON PWMP5 + gyro + self-level + baro
PteronautOS_ESP8285_2400_RX_BARO Barometer-only (BMP180), no gyro
PteronautOS_ESP8285_2400_RX_GEARBOX Gearbox variant (mixer profile 5)
PteronautOS_ESP8285_EP2_2400_RX EP2 + RP2040 (MUSHIN companion bridge)
PteronautOS_ESP8285_EP2_2400_RX_PWM EP2 standalone, RX/TX as 2 servos

A normal PWMP7 build with no gyro:

pio run -e PteronautOS_ESP8285_2400_RX

To add gyro self-level, build the _HORIZON env (defines ZEPHYRUS_ENABLED + MESOZOIC_HORIZON).

6 · Compile-time configuration

Two ways to pass build flags — they stack.

src/user_defines.txt (your overrides — gitignored)

Copy the template and edit it:

cp src/user_defines.txt.example src/user_defines.txt

It holds the human-tunable knobs — binding phrase, WiFi, gyro, mixer profile, UART baud:

-DAUTO_WIFI_ON_INTERVAL=30
-DLOCK_ON_FIRST_CONNECTION
-DMIXER_PROFILE=1
-DZEPHYRUS_ENABLED=1
-DZEPHYR_IMU=ZEPHYR_IMU_MPU6050
-DMY_BINDING_PHRASE="my-binding-phrase"

PlatformIO picks this up automatically (build_flags.py) — no CLI flags needed. This is exactly what flash.sh writes for you.

One-off flags on the command line

PLATFORMIO_BUILD_FLAGS="-DRegulatory_Domain_EU_CE_2400" \\
  pio run -e PteronautOS_ESP8285_2400_RX

flash.sh uses this channel for the regulatory domain; the rest go through user_defines.txt.

Core tuning headers

For deeper, code-level tuning (channel maps, servo limits, mixer gains), edit the headers directly:

7 · Where to make changes

You want to… Edit
Change wing / motor mixer behaviour src/lib/Ornithopter/OrnithopterGearbox.cpp (gearbox) or Ornithopter.cpp (servo waveform)
Add / tune gyro stabilisation src/lib/Zephyrus/Zephyrus.cpp
Add a WebUI setting src/html/src/pages/*.coffee + *.lithaml + locales/*.js, then the JSON in PteroWebHandlers.cpp
Change PWM output src/lib/ServoOutput/devServoOutput.cpp
Change the RX entry loop src/src/rx_main.cpp

After changing WebUI source, re-run the WebUI build, then the firmware build.

8 · Build rules (non-negotiable)

From hermetic.manifest.md — the target is a 1 MB, 80 MHz ESP8285; every feature pays for itself:

Current ESP8285 builds sit near 65% RAM (ELRS WiFi stack + Ornithopter + Zephyrus). Be mindful of buffers and large tables.

9 · Quick reference

# Fresh clone → first build (PWMP7, no gyro, English WebUI)
cd src/html && nvm use 20 && I18N_LOCALES=en npm run build:pteronautos
cd ../.. && cd src && pio run -e PteronautOS_ESP8285_2400_RX

# Build with gyro self-level
pio run -e PteronautOS_ESP8285_2400_RX_HORIZON

# Build PWMP5
pio run -e PteronautOS_ESP8285_2400_RX_PWMP5

# Inspect the full target list
pio run --list-targets

For the one-command build-and-flash flow (and how --no-build, saved presets, and the bootloader work), read the flash.sh guide .