Skip to content

refactor platformio.ini to eliminate copy-paste duplication#5544

Open
netmindz wants to merge 1 commit intowled:mainfrom
netmindz:platformio-de-duplication
Open

refactor platformio.ini to eliminate copy-paste duplication#5544
netmindz wants to merge 1 commit intowled:mainfrom
netmindz:platformio-de-duplication

Conversation

@netmindz
Copy link
Copy Markdown
Member

@netmindz netmindz commented Apr 26, 2026

Centralise platform, platform_packages, build_unflags, lib_deps and monitor_filters into the per-chipset abstract sections ([esp8266], [esp32], [esp32s2], [esp32c3], [esp32s3]) and have concrete envs inherit via extends rather than repeating the same values.

  • [esp8266]: add platform, platform_packages, monitor_filters
  • [esp32]: add monitor_filters
  • [esp32s2]: add monitor_filters
  • [esp32c3]: add monitor_filters
  • [esp32s3]: add upload_speed, monitor_filters
  • esp8266 envs (nodemcuv2, esp8266_2m, esp01_1m_full): extends = esp8266
  • esp32dev: extends = esp32
  • esp32dev_8M, esp32dev_16M: extends = env:esp32dev
  • esp32_eth, usermods: extends = esp32 / env:esp32dev
  • esp32_wrover: drop redundant build_unflags, lib_deps (already extends esp32_idf_V4)
  • esp32c3dev: drop redundant platform, platform_packages, framework, build_unflags, lib_deps, board_build.partitions (already extends esp32c3)
  • esp32s3 envs: extends = esp32s3
  • lolin_s2_mini: extends = esp32s2

No functional changes. Verified with pio run across all five chipset families (ESP8266, ESP32, C3, S3, S2).

Summary by CodeRabbit

  • Refactor
    • Reorganized and consolidated build environment configurations across all supported device variants (ESP8266, ESP32, ESP32-S2, ESP32-S3, and ESP32-C3).
    • Increased upload speed for ESP32-S3 devices.
    • Centralized monitor filter settings to reduce configuration duplication.

Centralise platform, platform_packages, build_unflags, lib_deps and
monitor_filters into the per-chipset abstract sections ([esp8266],
[esp32], [esp32s2], [esp32c3], [esp32s3]) and have concrete envs
inherit via extends rather than repeating the same values.

- [esp8266]: add platform, platform_packages, monitor_filters
- [esp32]: add monitor_filters
- [esp32s2]: add monitor_filters
- [esp32c3]: add monitor_filters
- [esp32s3]: add upload_speed, monitor_filters
- esp8266 envs (nodemcuv2, esp8266_2m, esp01_1m_full): extends = esp8266
- esp32dev: extends = esp32
- esp32dev_8M, esp32dev_16M: extends = env:esp32dev
- esp32_eth, usermods: extends = esp32 / env:esp32dev
- esp32_wrover: drop redundant build_unflags, lib_deps (already extends esp32_idf_V4)
- esp32c3dev: drop redundant platform, platform_packages, framework,
  build_unflags, lib_deps, board_build.partitions (already extends esp32c3)
- esp32s3 envs: extends = esp32s3
- lolin_s2_mini: extends = esp32s2

No functional changes. Verified with pio run across all five chipset
families (ESP8266, ESP32, C3, S3, S2).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 987c1bee-2a9e-4201-a288-df84a3f869dd

📥 Commits

Reviewing files that changed from the base of the PR and between 02e593d and e37707d.

📒 Files selected for processing (1)
  • platformio.ini

Walkthrough

PlatformIO configuration refactored to centralize platform settings and monitor filters at the platform group level (esp8266, esp32, esp32s2, esp32c3, esp32s3), with multiple build environments updated to inherit from these groups using extends to eliminate duplicate declarations.

Changes

Cohort / File(s) Summary
Platform Group Definitions
platformio.ini ([esp8266], [esp32], [esp32s2], [esp32c3], [esp32s3] sections)
Added centralized monitor_filters = esp32_exception_decoder to all platform groups; set upload_speed = 921600 for esp32s3 group.
ESP8266 Environments
platformio.ini ([env:nodemcuv2], [env:esp8266_2m], [env:esp01_1m_full])
Added extends = esp8266; removed duplicate platform, platform_packages, build_unflags, lib_deps, and per-env monitor_filters.
ESP32 Classic Environments
platformio.ini ([env:esp32dev], [env:esp32_eth])
Added extends = esp32; removed duplicate platform, platform_packages, build_unflags, lib_deps, and per-env monitor_filters.
ESP32 Memory Variants
platformio.ini ([env:esp32dev_8M], [env:esp32dev_16M], [env:usermods])
Added extends = env:esp32dev; removed duplicate platform, platform_packages, build_unflags, lib_deps, monitor_filters, and board-specific flags.
ESP32-S3 Environments
platformio.ini ([env:esp32s3dev_16MB_opi], [env:esp32s3dev_8MB_opi], [env:esp32S3_wroom2], [env:esp32s3_4M_qspi])
Added extends = esp32s3; removed duplicate platform, platform_packages, upload_speed, build_unflags, lib_deps, monitor_filters, and board configuration options.
ESP32-S2 Environments
platformio.ini ([env:lolin_s2_mini])
Added extends = esp32s2; removed duplicate platform, platform_packages, build_unflags, lib_deps, and partition configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • willmmiles
  • blazoncek
  • DedeHai
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: refactoring platformio.ini to eliminate copy-paste duplication through centralization and inheritance of common settings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

Comment thread platformio.ini
lib_deps =
${esp32_idf_V4.lib_deps}
board_build.partitions = ${esp32.large_partitions} ;; default partioning for 8MB flash - can be overridden in build envs
upload_speed = 921600
Copy link
Copy Markdown
Member

@softhack007 softhack007 Apr 27, 2026

Choose a reason for hiding this comment

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

maybe comment out the upload speed flag. 920kbaud might be too much for boards where the UART-to-USB module gets connected by flimsy dupond wires only.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My $0.02, but I'd prefer to default to the higher speed -- it's much more convenient and failures are easily caught. If a user is doing a custom build and needs to lower the speed, it's straightforward to do in the override file. Try the fast speed first and lower if you have to, instead of the other way around.

(AFAIK these settings don't affect users using the web installer or the like -- just people doing custom builds.)

@softhack007
Copy link
Copy Markdown
Member

softhack007 commented Apr 27, 2026

@netmindz I generally like the idea to use "extends = " for reducing the number of copied entries in buildenvs. Actually, I've proposed a similar approach some time ago, but then there was user feedback that people prefer to see "full entries", and "extends = " also created new pitfalls and makes it harder to understand which flags are actually passed to the compiler.

Not sure if this has changed in the meantime?

Comment thread platformio.ini
Comment on lines +195 to +196
platform = ${common.platform_wled_default}
platform_packages = ${common.platform_packages}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should move all the ESP8266 platform definitions in to this section instead of common, since they're not common for all environments. Yes, this will potentially be a breaking change for user platformio_override.ini files for anyone building custom ESP8266 environments; I think that's reasonable for 17.0, to keep our definitions clean (and prepare for a proper HAL).

Comment thread platformio.ini
lib_deps =
${esp32_idf_V4.lib_deps}
board_build.partitions = ${esp32.large_partitions} ;; default partioning for 8MB flash - can be overridden in build envs
upload_speed = 921600
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My $0.02, but I'd prefer to default to the higher speed -- it's much more convenient and failures are easily caught. If a user is doing a custom build and needs to lower the speed, it's straightforward to do in the override file. Try the fast speed first and lower if you have to, instead of the other way around.

(AFAIK these settings don't affect users using the web installer or the like -- just people doing custom builds.)

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.

3 participants