Skip to content

Accept rp2 as a runtime alias of rp2040#1704

Draft
bdraco wants to merge 1 commit into
mainfrom
handle-rp2-platform-rename
Draft

Accept rp2 as a runtime alias of rp2040#1704
bdraco wants to merge 1 commit into
mainfrom
handle-rp2-platform-rename

Conversation

@bdraco

@bdraco bdraco commented Jun 26, 2026

Copy link
Copy Markdown
Member

What does this implement/fix?

ESPHome is renaming the rp2040 target platform to rp2 (esphome/esphome#17145); the Platform enum makes RP2040 a Python alias of RP2, so once a build runs on a newer esphome the platform string everywhere (CORE.target_platform, StorageJSON core_platform) becomes rp2, while the legacy rp2040: YAML key keeps working as a deprecated alias. The dashboard therefore sees both names at runtime: rp2040 from existing devices and YAML, and rp2 from anything compiled or written against a newer esphome.

This teaches the backend to treat rp2 as an alias of rp2040. It is purely additive runtime recognition; the generated catalog, board manifests and capability index stay keyed on rp2040 (no esphome bump, no catalog regen), and the incoming rp2 string is folded onto rp2040 at the boundaries that ingest an external platform name.

  • New RP2_PLATFORM_ALIASES and normalize_platform() in models/boards.py, reused everywhere.
  • Device.target_platform is normalized at load (_loading.py), so the PLATFORM column and MAC derivation stay consistent for a device that reports rp2.
  • The rp2: YAML key is recognized by the platform scanner; MAC derivation, firmware download-type routing, remote-build artifact packing, board lookup and component platform-gating all fold rp2 to rp2040.

The catalog flip to rp2 (regenerating the catalog, board manifests, the Platform enum value) is deferred to the future coordinated esphome bump.

Related issue or feature (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — docs
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Frontend coordination

  • No frontend change needed

A companion frontend PR handles the raw-YAML surfaces (the editor navigator's section categorization and chip icon/label for a user-typed rp2: block); the catalog-driven wizard and validation paths stay consistent because the catalog remains keyed on rp2040 until the future flip.

Checklist

  • The code change is tested and works locally.
  • Pre-commit hooks pass (ruff, codespell, yaml/json/python checks).
  • Tests have been added or updated under tests/ where applicable.
  • components.index.json / definitions/components/*.json have not been hand-edited (regenerate via script/sync_components.py if a sync is needed).
  • Architecture-level changes are reflected in docs/ARCHITECTURE.md and/or docs/API.md.

ESPHome esphome/esphome#17145 renames the rp2040 target platform to rp2;
the Platform enum aliases RP2040 onto RP2, so a newer esphome reports the
platform string as rp2 (StorageJSON core_platform, CORE.target_platform)
while the legacy rp2040: YAML key keeps working. The dashboard sees both
names at runtime.

Fold rp2 onto the catalog's rp2040 at every boundary that ingests an
external platform string: normalize Device.target_platform at load,
recognize the rp2: YAML key, and fold in MAC derivation, firmware
download routing, remote-build artifact packing, board lookup and
component platform-gating. The catalog, manifests and capability index
stay keyed on rp2040 until a coordinated esphome bump.
@github-actions github-actions Bot added the bugfix Bug fix label Jun 26, 2026
@codspeed-hq

codspeed-hq Bot commented Jun 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks


Comparing handle-rp2-platform-rename (8eccc5b) with main (e79ca80)

Open in CodSpeed

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (b09e969) to head (8eccc5b).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1704   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files         227      227           
  Lines       18142    18157   +15     
=======================================
+ Hits        18060    18075   +15     
  Misses         82       82           
Flag Coverage Δ
py3.12 99.52% <100.00%> (+<0.01%) ⬆️
py3.14 99.54% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
esphome_device_builder/controllers/boards.py 100.00% <100.00%> (ø)
...evice_builder/controllers/components/controller.py 99.61% <100.00%> (+<0.01%) ⬆️
...me_device_builder/controllers/firmware/download.py 100.00% <100.00%> (ø)
...ollers/remote_build/artifact_platforms/__init__.py 100.00% <100.00%> (ø)
...ome_device_builder/helpers/device_yaml/_loading.py 100.00% <100.00%> (ø)
...ome_device_builder/helpers/device_yaml/_parsing.py 100.00% <100.00%> (ø)
esphome_device_builder/helpers/mac_addresses.py 100.00% <100.00%> (ø)
esphome_device_builder/models/boards.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rp2040 is being renamed rp2

1 participant