Skip to main content
This guide covers CI/CD for firmware projects that use PlatformIO — projects with a platformio.ini at the repository root (or in a known subdirectory checked out by your workflow). The firmngin/ota action auto-detects PlatformIO when platformio.ini is present and platform is auto (default).

When to use PlatformIO CI/CD

Project requirements

Your repository should include: Example minimal platformio.ini:

How auto-detection works

When platform: auto (default):
  1. The action checks for platformio.ini in the repository root.
  2. If found, PlatformIO is selected.
  3. If platformio-env is empty, the action resolves the environment in this order:
    • default_envs from platformio.ini
    • First [env:name] block in the file
  4. Runs pio run --environment <env>.
  5. Uploads the compiled firmware to firmngin.
Always set platformio-env explicitly in production workflows to avoid surprises when you add new environments to platformio.ini.

Basic workflow

Firmware in a subdirectory

If platformio.ini is not at the repo root:
The action runs from the job working directory, so platformio.ini must be inside firmware/.

Multiple environments

Upload one artifact per hardware target:
Define one template variable per fleet in GitHub Variables.

Option B: Single environment per workflow file

Maintain separate workflow files per product line, each with a fixed platformio-env.

Board and model alignment

firmngin uses board name and board model to match firmware artifacts to devices. Your PlatformIO board setting must correspond to the values configured on:
  • The device template (fleet OTA), or
  • The device (single-device OTA), or
  • The target-board / target-model inputs (artifact-only upload).
If upload fails with a target mismatch error, compare your template or device board fields with the values sent by CI/CD.

Optimizing binary size

CI/CD uploads are limited to 10 MB. Common PlatformIO optimizations:
Additional tips:
  • Disable verbose logging in release builds.
  • Remove unused libraries from lib_deps.
  • Use partition schemes appropriate for your flash size.

Build flags per environment

Use environment-specific sections for release vs debug:
Point CI/CD at the release environment only:

Caching PlatformIO dependencies (optional)

Speed up builds by caching PlatformIO packages:
The firmngin/ota action installs PlatformIO on each run; caching reduces download time for platforms and libraries.

Local verification before CI/CD

Run a local PlatformIO build with the same environment before pushing:
Fix compile errors locally first — CI will fail on the same issues.

PlatformIO + single device

For one device without a template:
Ensure the device has board name and model set in the dashboard to match your PlatformIO target.

Common issues