Skip to content

feat: add PlatformIO build system support#109

Open
gyengus wants to merge 8 commits intomemovai:mainfrom
gyengus:platformio
Open

feat: add PlatformIO build system support#109
gyengus wants to merge 8 commits intomemovai:mainfrom
gyengus:platformio

Conversation

@gyengus
Copy link
Copy Markdown

@gyengus gyengus commented Feb 28, 2026

  • Add platformio.ini with ESP-IDF framework configuration

    • ESP32-S3 board (16MB flash, 8MB Octal PSRAM)
    • src_dir = main (reuse existing ESP-IDF structure)
    • data_dir = spiffs_data (existing SPIFFS data)
  • Add scripts/build_pio.sh for convenient build/flash/monitor

  • Update .gitignore with PlatformIO output directories

    • .pio/, .pioenvs/, .piolibdeps/
  • Add PlatformIO build documentation to README files

    • English, Chinese, and Japanese versions
    • Note about separate SPIFFS upload requirement
  • Document PlatformIO implementation plan in docs/PLATFORMIO_PLAN.md

    • Dependency analysis (all built-in ESP-IDF components)
    • Version mapping (PlatformIO espressif32 uses ESP-IDF 5.5.x)
    • Operational differences from ESP-IDF native build

Dual build system support: ESP-IDF native (idf.py) and PlatformIO (pio)
can be used interchangeably.

Summary by CodeRabbit

  • New Features

    • Added PlatformIO as an alternative build system alongside native ESP-IDF builds.
  • Documentation

    • Added PlatformIO usage instructions in English, Chinese, and Japanese (prereqs, build/flash, SPIFFS upload, serial monitor, one-liner).
  • Chores

    • Added a strict build/upload helper script and updated ignore rules to exclude PlatformIO artifacts.
  • Other

    • Included a generated ESP32-S3 project configuration snapshot for device/build settings.

  - Add platformio.ini with ESP-IDF framework configuration
    - ESP32-S3 board (16MB flash, 8MB Octal PSRAM)
    - src_dir = main (reuse existing ESP-IDF structure)
    - data_dir = spiffs_data (existing SPIFFS data)

  - Add scripts/build_pio.sh for convenient build/flash/monitor

  - Update .gitignore with PlatformIO output directories
    - .pio/, .pioenvs/, .piolibdeps/

  - Add PlatformIO build documentation to README files
    - English, Chinese, and Japanese versions
    - Note about separate SPIFFS upload requirement

  - Document PlatformIO implementation plan in docs/PLATFORMIO_PLAN.md
    - Dependency analysis (all built-in ESP-IDF components)
    - Version mapping (PlatformIO espressif32 uses ESP-IDF 5.5.x)
    - Operational differences from ESP-IDF native build

  Dual build system support: ESP-IDF native (idf.py) and PlatformIO (pio)
  can be used interchangeably.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 28, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds PlatformIO support and related artifacts: new platformio.ini, a PlatformIO build helper script, PlatformIO entries in .gitignore, README additions in English/Chinese/Japanese, and a full sdkconfig.esp32s3 configuration file.

Changes

Cohort / File(s) Summary
PlatformIO config & SDK
platformio.ini, sdkconfig.esp32s3
Adds a PlatformIO project configuration for ESP32-S3 and a large autogenerated ESP-IDF sdkconfig snapshot (project build/config options).
Build script
scripts/build_pio.sh
New strict shell script that runs pio run, pio run -t upload, pio run -t uploadfs, and pio device monitor with labeled output and immediate-fail behavior.
Ignore rules
.gitignore
Adds PlatformIO artifact ignore entries: .pio/, .pioenvs/, .piolibdeps/.
Documentation — English
README.md
Adds PlatformIO build instructions and usage notes (prereqs, build/flash, SPIFFS upload, serial monitor, one-liner, helper script).
Documentation — Chinese
README_CN.md
Adds a collapsible PlatformIO 构建(替代方案) section with setup and usage instructions.
Documentation — Japanese
README_JA.md
Adds a PlatformIO ビルド(代替案) section describing prerequisites and PlatformIO build/upload/monitor steps.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Script as scripts/build_pio.sh
    participant PIO as PlatformIO CLI
    participant Device as Target Device / Serial

    Script->>PIO: pio run (build)
    PIO-->>Script: build artifacts
    Script->>PIO: pio run -t upload (flash firmware)
    PIO-->>Device: write firmware
    Script->>PIO: pio run -t uploadfs (upload SPIFFS)
    PIO-->>Device: write SPIFFS image
    Script->>PIO: pio device monitor
    PIO-->>Device: open serial monitor
    PIO-->>Script: stream device logs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

documentation

Suggested reviewers

  • crispyberry

Poem

🐰 I nibbled docs and hopped through configs bright,

Wove PlatformIO paths into the night,
Scripts that build and monitors that sing,
A little rabbit dance for every flashing spring.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add PlatformIO build system support' directly and clearly summarizes the main change: adding PlatformIO as a new build system alongside the existing ESP-IDF build.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.gitignore (1)

14-23: Remove duplicated PlatformIO ignore block.

Line 19-Line 22 duplicates Line 14-Line 17 exactly. Keep a single block to avoid redundant churn in future edits.

♻️ Proposed cleanup
 # PlatformIO
 .pio/
 .pioenvs/
 .piolibdeps/
-
-# PlatformIO
-.pio/
-.pioenvs/
-.piolibdeps/
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore around lines 14 - 23, Remove the duplicated PlatformIO ignore
block by keeping only one occurrence of the three patterns ".pio/", ".pioenvs/",
and ".piolibdeps/" in the .gitignore; locate the repeated block containing those
exact patterns and delete the second copy so the file contains a single
PlatformIO ignore block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@platformio.ini`:
- Around line 8-18: The platform in the [env:esp32s3] section is unpinned
(platform = espressif32) which allows framework/toolchain drift; update the
platform declaration to a specific version (e.g., platform =
espressif32@<stable-version>) in the same [env:esp32s3] block so builds use a
fixed espressif32 toolchain and framework; keep the sdkconfig files as-is since
ESP-IDF CMake will auto-discover sdkconfig.defaults and
sdkconfig.defaults.esp32s3.

In `@README_JA.md`:
- Around line 116-190: The README_JA.md contains a duplicated "PlatformIO
ビルド(代替案)" details block (the second block duplicates the first); remove or
consolidate the duplicate so only a single canonical PlatformIO section remains,
keeping the clearer phrasing for build/flash/uploadfs/monitor commands and the
three 注意事項 lines; locate the duplicate by finding the two
<details><summary>PlatformIO ビルド(代替案)</summary> blocks and delete the later one
(or merge any slight wording differences so the remaining block contains the
complete, consistent instructions).

In `@README.md`:
- Around line 116-195: The README contains two duplicated "PlatformIO"
instructions blocks ("Building with PlatformIO" and "PlatformIO Build
(Alternative)"); remove the second duplicate block and ensure any unique notes
(PlatformIO version, SPIFFS upload requirement, and mention that idf.py still
works) are merged into the retained "Building with PlatformIO" details section
so all relevant guidance remains in one place and the summary title is
consistent.

---

Nitpick comments:
In @.gitignore:
- Around line 14-23: Remove the duplicated PlatformIO ignore block by keeping
only one occurrence of the three patterns ".pio/", ".pioenvs/", and
".piolibdeps/" in the .gitignore; locate the repeated block containing those
exact patterns and delete the second copy so the file contains a single
PlatformIO ignore block.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f157111 and 63c6e03.

📒 Files selected for processing (7)
  • .gitignore
  • README.md
  • README_CN.md
  • README_JA.md
  • platformio.ini
  • scripts/build_pio.sh
  • sdkconfig.esp32s3

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
platformio.ini (1)

18-18: ⚠️ Potential issue | 🟠 Major

Pin the PlatformIO platform version for reproducible builds.

At Line 18, platform = espressif32 is still unpinned, so framework/toolchain versions can drift across machines and CI runs.

Proposed fix
-[env:esp32s3]
-platform = espressif32
+[env:esp32s3]
+platform = espressif32@<known-good-version>
#!/bin/bash
set -euo pipefail

# Verify current state
rg -n '^\s*platform\s*=' platformio.ini

# Optional: list all PlatformIO envs to ensure pinning is consistent
rg -n '^\[env:.*\]|\s*platform\s*=' platformio.ini
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@platformio.ini` at line 18, The platform key in platformio.ini is unpinned
(currently "platform = espressif32"); update that line to pin a specific
PlatformIO platform version (for example "platform = espressif32@<version>") so
builds are reproducible across machines/CI, then verify the change by searching
for "platform =" and the [env:*] sections to ensure all envs use the pinned
platform; edit the existing "platform = espressif32" entry rather than adding a
new duplicate.
🧹 Nitpick comments (1)
platformio.ini (1)

28-30: Use canonical -D macro style in build_flags.

At Line 30, prefer -DCONFIG_SPIRAM_CACHE_WORKAROUND over -D CONFIG_SPIRAM_CACHE_WORKAROUND for consistency and to avoid parser/tooling edge cases.

Proposed fix
 build_flags =
     -DBOARD_HAS_PSRAM
-    -D CONFIG_SPIRAM_CACHE_WORKAROUND
+    -DCONFIG_SPIRAM_CACHE_WORKAROUND
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@platformio.ini` around lines 28 - 30, The build_flags entry uses a
non-canonical macro definition "-D CONFIG_SPIRAM_CACHE_WORKAROUND"; update the
build_flags block to use the canonical no-space form
"-DCONFIG_SPIRAM_CACHE_WORKAROUND" (and verify other macros like
"-DBOARD_HAS_PSRAM") so the -D macros are consistently formatted and avoid
tooling/parser issues; edit the build_flags lines accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@platformio.ini`:
- Around line 8-10: The comment says the build overrides the board's
maximum_size to match a 2MB partition but the env block doesn't actually set
board_upload.maximum_size; update the env configuration (the [env:*] block
referenced in the diff) to add board_upload.maximum_size and set it to the 2MB
app partition value (2097152) so PlatformIO's checkprogsize matches the ESP-IDF
partition table.

---

Duplicate comments:
In `@platformio.ini`:
- Line 18: The platform key in platformio.ini is unpinned (currently "platform =
espressif32"); update that line to pin a specific PlatformIO platform version
(for example "platform = espressif32@<version>") so builds are reproducible
across machines/CI, then verify the change by searching for "platform =" and the
[env:*] sections to ensure all envs use the pinned platform; edit the existing
"platform = espressif32" entry rather than adding a new duplicate.

---

Nitpick comments:
In `@platformio.ini`:
- Around line 28-30: The build_flags entry uses a non-canonical macro definition
"-D CONFIG_SPIRAM_CACHE_WORKAROUND"; update the build_flags block to use the
canonical no-space form "-DCONFIG_SPIRAM_CACHE_WORKAROUND" (and verify other
macros like "-DBOARD_HAS_PSRAM") so the -D macros are consistently formatted and
avoid tooling/parser issues; edit the build_flags lines accordingly.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42d3381 and f61abd3.

⛔ Files ignored due to path filters (1)
  • partitions.csv is excluded by !**/*.csv
📒 Files selected for processing (1)
  • platformio.ini

@IRONICBo IRONICBo self-requested a review March 1, 2026 03:40
@IRONICBo IRONICBo self-assigned this Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants