Build Flags
Every OpenSkyhawk firmware project is configured by -D flags in its platformio.ini. There are
63 of them, and they come from three different places. That mixed provenance is the first
thing to understand, because it decides who you have to convince before you change one:
| Group | Count | Changing one is… |
|---|---|---|
| Ours — behavioural | 16 | a local decision — we own the code that reads it |
| PDU node settings | 24 | a local decision, for the power-distribution node only |
| Third-party, set by us | 7 | not a local decision — STM32duino, arduino-pico, and DCS-BIOS own these |
| Test seams | 16 | bench-only — 14 seams plus 2 test-sketch pin values, never present in a shipped build |
This page is an inventory: what each flag defaults to, where it's set, and where it's read. Deep
per-flag semantics live in the library READMEs under Firmware/Libraries/ and in
Firmware/ScratchPad/TechSpec/. When a table here and a header disagree, the header wins —
and the grep recipe at the bottom will tell you which.
For a working platformio.ini with the common flags in context, see
PlatformIO Setup. If you are building a panel right now, start with the
next section instead — the tables below are reference, not a checklist.
Starting a new panel
You copied Firmware/Templates/PanelGroup/ and you're looking at its build_flags. Here is what
to do with each line. The walkthrough covers the surrounding steps;
this is just the flags.
Required — set these or the build fails
| Flag | What to set |
|---|---|
NODE_ID |
Your board's unique CAN address, 1–63, claimed from the registry in Firmware/NODE_IDS.md — see NODE_ID & CAN Addressing. No default. Omitting it is a compile error, not a silent fallback. |
HAL_CAN_MODULE_ENABLED |
Nothing — keep it as-is. STM32duino does not enable the bxCAN HAL driver by default, so without this line there is no CAN driver to link against. |
Already correct in the template — keep, don't tune
| Flag | Why to leave it alone |
|---|---|
HSE_VALUE=8000000 |
Already matches both your board's crystal and the framework's own F1 default. Change it only if your board genuinely carries a different crystal — and if you do, get it right first time: a wrong value is undetectable at runtime (see the warning below). |
USB_NONE |
Inert. It documents that CAN owns PA11/PA12; it does not enforce it. Harmless to keep, harmless to drop. |
Add only if your panel needs them
| Flag | Add when |
|---|---|
I2C_TIMEOUT_TICK=10 |
Your panel has I²C devices (MCP23017, ADS1115, OLEDs) — shortens the stall when one is absent or miswired. |
SHIFTBUS_SCK / MISO / MOSI / LOAD / LATCH |
You are relocating the shift-register bus off its default pins. Otherwise leave all five out. |
SHIFTBUS_ISR_HZ |
You want timer-ISR sampling for encoder feel instead of polled sampling. |
SERIAL_RX_BUFFER_SIZE=256 |
PanelBridge only. A PanelGroup has no use for it. |
NODE_HEALTH_TELEM=0 |
You specifically want health telemetry off. It is on by default — omitting the line does not disable it. |
PANELBRIDGE_NODE_STATUS=0 |
PanelBridge only. You specifically want node reporting to the host off — the client then shows no boards. On by default. |
Never in a panel
FORCE_CLOCK_FALLBACK, PINREF_DEBUG, NODE_OVERHEAT_C, and any *_TEST seam. These are bench
and debug instruments. If one appears in a panel's platformio.ini, it is a mistake — see
Test seams and Deliberate non-defaults for what each
actually does.
Ours — behavioural
| Flag | Default | Set where | Read at |
|---|---|---|---|
NODE_ID |
none — omitting it fails to compile | every STM32 env that links our libraries; WiringCheck omits it deliberately |
CANProtocol.cpp:297, PanelGroup.cpp:304, STM32Board.h:29, FirmwareImage.h:61 (the image identity block) |
PANELBRIDGE_NODE_STATUS |
on | =0 in Tests/PanelBridge test_input_dispatch_dcs / _hid |
PanelBridge.h:38 (default), PanelBridge.cpp:47 + ~10 more |
NODE_HEALTH_TELEM |
on | never set | CANProtocol.cpp:587 (serviceNodeStatus, every node) |
NODE_OVERHEAT_C |
unset — by design | bench envs only | CANProtocol.cpp:518, CANProtocol.cpp:604 |
FORCE_CLOCK_FALLBACK |
off | Tests/STM32Board env test_adc_clock_fallback |
STM32Board.cpp:180 |
PINREF_DEBUG |
off | never set | PinRef.cpp:8 + ~9 more |
SHIFTBUS_SCK |
PB3 |
never set | ShiftBus.cpp:13 |
SHIFTBUS_MISO |
PB4 |
never set | ShiftBus.cpp:16 |
SHIFTBUS_MOSI |
PB5 |
never set | ShiftBus.cpp:19 |
SHIFTBUS_LOAD |
PB8 |
never set | ShiftBus.cpp:22 |
SHIFTBUS_LATCH |
PB9 |
never set | ShiftBus.cpp:25 |
SHIFTBUS_ISR_HZ |
unset → polled sampling | Tests/ShiftBus, =1000 |
PanelGroup.cpp:116,231 |
SHIFTBUS_ISR_TIM |
TIM2 |
never set | PanelGroup.cpp:232 |
CAN_TX_RING_SIZE |
64 frames on PanelBridge, 16 on a node | never set | CANProtocol.cpp:37 |
CAN_RX_RING_SIZE |
128 frames on PanelBridge, 8 on a node | never set | CANProtocol.cpp:43 |
OSH_BOOT_BRIDGE |
off — the CAN bootloader | Firmware/Bootloader env bridge |
Bootloader/src/main.cpp:77 |
What they do, briefly. NODE_ID is the board's CAN address — see
NODE_ID & CAN Addressing. PANELBRIDGE_NODE_STATUS makes PanelBridge report which
nodes it can see — with their health and board kind, and itself — up to the host over DCS-BIOS.
NODE_HEALTH_TELEM is the periodic health frame (die temperature, fault, board kind) at half the
heartbeat rate.
FORCE_CLOCK_FALLBACK exercises the dead-crystal fault path without a dead crystal; the
test_adc_clock_fallback env uses it to prove SystemClock_Config sets the ADC prescaler on its
fault path as well as its verified-72 MHz path (#263).
PINREF_DEBUG adds assertions to the pin abstraction. The SHIFTBUS_* pin flags relocate the
shift-register bus off its default SPI1-remap pins; SHIFTBUS_ISR_HZ switches that bus from
polled to timer-ISR sampling (encoder feel) on the timer named by SHIFTBUS_ISR_TIM.
CAN_TX_RING_SIZE / CAN_RX_RING_SIZE size CANProtocol's software queues (2–255 frames); PanelBridge
gets the deep ones because it sends the whole export stream and hears every node. OSH_BOOT_BRIDGE
builds the bootloader for the Gateway's PanelBridge chip, which takes updates over the link to the
Gateway's USB chip instead of CAN; bootstrap and the release files pick the right build for you.
Set NODE_ID in platformio.ini, never in main.cpp
A #define NODE_ID in a sketch is invisible to library translation units — CANProtocol and
PanelGroup are compiled separately. That mistake is caught at build time rather than
shipped: those TUs include STM32Board.h, whose file-scope static_assert fails with
error: 'NODE_ID' was not declared in this scope. There is no default and no silent
fallback — the undefined-evaluates-to-zero rule applies inside #if, not in a
static_assert expression.
Sketches that link none of those libraries are the only exception: the standalone
Examples/E2E_DCS_Test/WiringCheck env omits -DNODE_ID deliberately, because it is a raw
GPIO/ADC diagnostic with no OpenSkyhawk libraries at all.
Note that 0 is a legal value — it is PanelBridge's reserved address. It is just never
correct for a PanelGroup node.
Deliberate non-defaults
Three of the above look like oversights and are not. They are choices, and this is the record of them:
NODE_OVERHEAT_C is unset on purpose — OVERHEAT never raises in a shipped build
The STM32's internal die-temperature sensor is uncalibrated. Rather than ship a threshold
nobody has field data for, the overheat bit is computed only when a build defines
NODE_OVERHEAT_C — and no shipped environment defines it: not the templates, not
the PDU sketches, not the E2E examples. The OVERHEAT flag in the node-health frame is
therefore never set on any real cockpit node.
Two bench environments force it deliberately, and only to exercise the path:
Tests/CANProtocol sets =0 (any reading trips it, to test overheat and degraded coexisting)
and Tests/PanelGroup sets =20 (a room-temperature node reports overheat, to test the
client's rendering). Enabling it for real is a one-line -DNODE_OVERHEAT_C=N once someone has
calibration data. See FirmwarePlan/00-decisions.md.
NODE_HEALTH_TELEM and PANELBRIDGE_NODE_STATUS are ON by default — disable with =0, not by omission
They're the two flags in this group that are on when absent. Leaving them out gets you health
telemetry and the bridge's node reporting; you need an explicit =0 to turn either off. The
client depends on both, so a shipped build keeps them on.
PDU node settings (PDU_*)
The power-distribution node (PowerMonitor library, Panels/PDU_*) takes its ADC pins and every
limit as a PDU_* macro with a default in Firmware/Libraries/PowerMonitor/PduConfig.h. The defaults are
starting points to tune on the bench against the real load; override one per build, e.g.
-DPDU_12V_UV_MV=11200, with no code change.
| Flag | Default | What it sets |
|---|---|---|
PDU_PIN_V12 / PDU_PIN_V5 / PDU_PIN_I12 / PDU_PIN_I5 / PDU_PIN_NTC |
PA0 / PA1 / PA2 / PA3 / PA6 |
ADC pins, as wired on the PDU board; change them only for a board wired differently |
PDU_12V_UV_MV / PDU_12V_OV_MV |
11400 / 13200 | 12 V under / over-voltage |
PDU_5V_UV_MV / PDU_5V_OV_MV |
4750 / 5500 | 5 V under / over-voltage |
PDU_12V_OC_MA / PDU_5V_OC_MA |
4500 / 1800 | over-current, 90 % of the 5 A / 2 A fuse |
PDU_FUSE_OPEN_MV |
1000 | 12 V below this while the node runs → fuse open |
PDU_V_HYST_MV |
100 | voltage hysteresis |
PDU_V_SET_MS / PDU_OC_SET_MS / PDU_CLEAR_MS |
50 / 100 / 500 | how long a condition must hold to set / clear |
PDU_TEMP_WARN_DC / PDU_TEMP_CRIT_DC / PDU_TEMP_HYST_DC |
600 / 750 / 30 | board temperature, tenths of °C |
PDU_BOOT_BLANK_MS |
500 | faults ignored after power-up (rail ramp, inrush) |
PDU_SAMPLE_US |
1000 | rail scan period (1 kHz) |
PDU_ZERO_GUARD_12V_MA / PDU_ZERO_GUARD_5V_MA |
75 / 120 | CAL ZERO refuses above this — load still connected |
PDU_CAL_PAGE_ADDR |
0x0800FC00 |
calibration flash page; the PDU builds cap the image at 63 KB (board_upload.maximum_size) to keep code out of it |
PANELBRIDGE_NODE_STATUS (above) also gates the bridge's _NODE_TELEM forwarding of these
readings to the host.
Third-party, set by us
These belong to STM32duino, arduino-pico, and the DCS-BIOS library. We only set them — we don't own the code that reads them, and a framework update can move a default out from under us. Two of these have already cost real debugging time.
| Flag | Framework default | Set where | Read at |
|---|---|---|---|
HAL_CAN_MODULE_ENABLED |
not enabled | every STM32 env that links our libraries; WiringCheck omits it deliberately |
stm32f1xx_hal_conf_default.h:321 |
HSE_VALUE |
already 8000000U on F1 |
=8000000 in all templates, panels and examples, plus the CAN/board tests; 13 library-test envs omit it — harmlessly, since it equals the default |
stm32f1xx_hal_conf_default.h:86 |
SERIAL_RX_BUFFER_SIZE |
64 |
PanelBridge envs, =256 |
Serial.h:44 |
I2C_TIMEOUT_TICK |
100 |
one E2E PanelGroup env, =10 |
Wire/src/utility/twi.c:51 |
USB_NONE |
no such macro | 10 platformio.ini files |
nowhere — see below |
USE_TINYUSB |
off | every RP2040 env | arduino-pico platformio-build.py:242,325 |
DCSBIOS_DEFAULT_SERIAL |
off | #define in the sketch, not -D |
PanelBridge.cpp:11 |
HAL_CAN_MODULE_ENABLED is genuinely required: CAN is absent from STM32duino's default-enabled
HAL module list, so without our -D there is no bxCAN driver to link against.
SERIAL_RX_BUFFER_SIZE=256 gives PanelBridge room for DCS-BIOS export bursts on UART2.
I2C_TIMEOUT_TICK=10 shortens the Wire library's stall when an I²C device is absent.
DCSBIOS_DEFAULT_SERIAL is the odd one out — it's #defined at the top of the sketch's
main.cpp rather than passed as -D, because PanelBridge.cpp has to include DcsBios.h
without it and then restore it, to avoid an ODR violation.
HSE_VALUE does not select HSE — and it already matches the framework default
-DHSE_VALUE=8000000 tells HAL what the crystal is. It does not switch the clock tree to
it, and 8000000U is already what STM32duino defaults the F1 to, so the flag changes nothing
on its own. What actually selects HSE is STM32Board's strong override of
SystemClock_Config (STM32Board.cpp:165), which every OpenSkyhawk STM32 node links.
Without it, the variant runs HSI-PLL at 64 MHz → APB1 32 MHz → CAN at 444 kbps against a
500 kbps bus.
The corollary: a wrong-value crystal is undetectable at runtime. HAL_RCC_Get*Freq()
derives from the compile-time HSE_VALUE, not from a measurement, so a 12 MHz part would
compute as 72 MHz while really running 108. Correct crystal value is a BOM guarantee.
USE_TINYUSB is required for HID — omitting it silently builds the wrong USB stack
On RP2040 this selects TinyUSB in place of the default Pico stack. Adafruit_TinyUSB.h and
SimGateway's whole HID backend depend on it. The arduino-pico builder branches on it in two
places; without it the project still compiles, which is what makes it expensive to diagnose.
USB_NONE is inert — nothing reads it
It appears on 25 lines across 10 platformio.ini files and has no effect. STM32duino has
no such macro: its "USB support: None" board option sets nothing at all, and only the CDC and
HID options add defines. Nothing in the framework, the PlatformIO builder, or our code reads
USB_NONE.
The intent behind it is real, though. On the F103, USB D+/D− are PA11/PA12 — exactly the pins
the CAN transceiver uses, so CAN genuinely does own them and USB must stay off. What keeps
it off is that USBCON is never defined, and no build config or source under Firmware/
defines it. The flag documents the decision; it does not enforce it.
Test seams
Each of these widens a library's visibility so its on-target tests can assert against internal
state. A seam never changes shipped behaviour, and no shipped environment defines one — each
is set only by its own Firmware/Tests/<Library>/platformio.ini.
| Flag | Library it opens | First read at |
|---|---|---|
ANALOGINPUT_TEST |
AnalogInput | Inputs/AnalogInput/AnalogInput.h:104 |
ANALOGMULTIPOS_TEST |
AnalogMultiPos | Inputs/AnalogMultiPos/AnalogMultiPos.h:93 |
DIMMER_TEST |
Dimmer | Outputs/Dimmer/Dimmer.h:71 |
DRUMDISPLAY_TEST |
DrumDisplay | DrumDisplay/DrumDisplay.h:278 |
LED_TEST |
LED | Outputs/LED/LED.h:67 |
MULTIPOS_TEST |
MultiPosInput | Inputs/MultiPosInput/MultiPosInput.h:59 |
NEEDLEGAUGE_TEST |
NeedleGauge | Outputs/NeedleGauge/NeedleGauge.h:77 |
PANELBRIDGE_TEST |
PanelBridge | PanelBridge/PanelBridge.h:96 |
ROTARYENCODER_TEST |
RotaryEncoder | Inputs/RotaryEncoder/RotaryEncoder.h:108 |
SHIFTBUS_TEST |
ShiftBus | Helpers/ShiftBus/ShiftBus.h:141 |
SIMGATEWAY_TEST |
SimGateway | SimGateway/SimGateway.cpp:13 (no-op HID stubs) |
STEPPERMOTOR_TEST |
StepperMotor | Drivers/StepperMotor/StepperMotor.h:151 |
STM32BOARD_TEST |
STM32Board | STM32Board/STM32Board.h:31 |
SWITCHWITHCOVER_TEST |
SwitchWithCover2Pos | Inputs/SwitchWithCover2Pos/SwitchWithCover2Pos.h:62 |
Paths are relative to Firmware/Libraries/, and the PanelGroup ones to
Firmware/Libraries/PanelGroup/. Most seams are read in several places; the column gives the
first, which is where the guarded block starts.
Several test projects set another library's seam because they drive or extend it — for example
Tests/NeedleGauge also sets STEPPERMOTOR_TEST, Tests/CANProtocol sets STM32BOARD_TEST, and the
MultiPosInput family's tests set MULTIPOS_TEST. Seven test projects set no seam at all and test
through the public API: Tests/ActionButton, Tests/IntegerOutput, Tests/NodeStatus,
Tests/PanelGroup, Tests/PinRef, Tests/PowerMonitor and Tests/Switch2Pos.
Two more flags are bench values rather than seams: I2C_TEST_SCL / I2C_TEST_SDA (PB10 / PB11)
pick the I²C pins for the test sketches in Tests/PinRef, Tests/PanelGroup, Tests/StepperMotor
and Tests/DrumDisplay. No library reads them.
SIMGATEWAY_TEST is the one that does more than widen visibility: it swaps the real HID backend
for no-op stubs so SimGateway logic can be tested without a USB host.
Re-verifying this page
Rather than trust the tables, re-derive them. Run both blocks from the repo root — their union must be 63. If it isn't, this page is stale.
Be clear about what that proves. Both lists come from greps of the same shape, so the union
check catches drift — a flag added, removed, or renamed after this page was written. It does
not prove the inventory is complete: a flag consumed in some way neither grep looks for would
be missed by the check exactly as it was missed by the page. Treat 63 as the current count, not a
guarantee. Knobs that a single test sketch defines for itself and no environment sets (such as
STALL_MS in the ShiftBus encoder bench gate) are not counted: the read grep covers
Firmware/Libraries only.
grep -rhE '^[^;#]*-D[A-Za-z_]' --include=platformio.ini Firmware | sed -E 's/[;#].*//' | grep -oE '[[:space:]]-D[A-Za-z_][A-Za-z0-9_]*' | sed 's/.*-D//' | sort -u
That's every flag set by some environment — 28 of them.
grep -rhoE '#[[:space:]]*(ifdef|ifndef|if|elif)[^A-Za-z_]*defined[^A-Za-z_]*[A-Za-z_][A-Za-z0-9_]*|#[[:space:]]*(ifdef|ifndef)[[:space:]]+[A-Za-z_][A-Za-z0-9_]*' --include='*.h' --include='*.cpp' Firmware/Libraries | grep -oE '[A-Za-z_][A-Za-z0-9_]*$' | sort -u | grep -vE '^(ARDUINO_ARCH_|STM32F1xx$|ATEMP$|guard$|_)'
That's every flag read by a library conditional — 53 of them. The trailing filter drops
architecture macros, the ATEMP pin macro, and internal include guards; none are build flags.
The two lists deliberately don't match, and the differences are the interesting part:
- Set but not read —
NODE_ID(used as a value,canIdEvt(NODE_ID), never in a conditional), the six framework flags, which are read inside STM32duino and arduino-pico rather than in our tree,OSH_BOOT_BRIDGE, which is read by the bootloader outsideFirmware/Libraries, and the twoI2C_TEST_*pins, which are read as values in test sketches. - Read but never set — the 34 flags whose defaults always apply in every committed
environment (the five ShiftBus pins,
SHIFTBUS_ISR_TIM,NODE_HEALTH_TELEM,PINREF_DEBUG, the two CAN ring sizes and all 24PDU_*flags), plusDCSBIOS_DEFAULT_SERIAL, which is#defined in sketch source instead of passed as-D.
To check the USB_NONE claim specifically, both of these must return nothing:
grep -rn 'USBCON\|USBD_USE_' Firmware
grep -rn 'USB_NONE' ~/.platformio/platforms ~/.platformio/packages/framework-arduinoststm32