Skip to content

Key nRF52 logger defaults by chip, like esp32 - #3015

Merged
J. Nick Koston (bdraco) merged 6 commits into
mainfrom
logger-skip-nrf52-variant-defaults
Nov 5, 2026
Merged

J. Nick Koston (bdraco) merged 6 commits into
mainfrom
logger-skip-nrf52-variant-defaults

Conversation

@bdraco

@bdraco J. Nick Koston (bdraco) commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

What does this implement/fix?

The dashboard now keys nRF52 logger defaults by chip, resolved from the board like esp32, so esphome/esphome#22173 (nrf52_54l15=UART0, nrf52_54lm20=UART0) syncs and an nRF54 device shows UART0.

# before
key = resolve_esp32_variant(...) if platform == "esp32" else platform
# after
if platform == "esp32":
    key = resolve_esp32_variant(config, extra_substitutions, storage_variant)
elif platform == "nrf52":
    variant = resolve_nrf52_variant(config, extra_substitutions)
    if variant in caps.logger_interface_defaults:
        key = variant
  • The sync maps nrf52_54l15 to nrf54l15, accepts the chips ESPHome knows, and snapshots nrf52_board_variants ({board: variant}) using ESPHome's own board rule, like esp32_board_variants.
  • A chip without its own row (nRF52840) keeps the nrf52 default, as SplitDefault does. With an ESPHome that predates the variants, both stay empty.
  • Fixes the Test downstream esphome/device-builder job on [nrf52] Add nRF54LM20/NRF54L15 support and J-Link upload esphome#22173.

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
  • Companion frontend PR: esphome/device-builder-frontend#

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.

@bdraco

Copy link
Copy Markdown
Member Author

@codspeed

codspeed Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing logger-skip-nrf52-variant-defaults (da4e188) with main (04a6207)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.76%. Comparing base (04a6207) to head (da4e188).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3015   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files         300      300           
  Lines       26388    26403   +15     
=======================================
+ Hits        26326    26341   +15     
  Misses         62       62           
Flag Coverage Δ
py3.12 99.72% <100.00%> (-0.01%) ⬇️
py3.14 99.61% <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/definitions/__init__.py 100.00% <100.00%> (ø)
...ome_device_builder/helpers/device_yaml/_parsing.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.

@bdraco J. Nick Koston (bdraco) changed the title Skip nRF52 per-chip logger defaults in the component sync Key nRF52 logger defaults by chip, like esp32 Nov 5, 2026
@bdraco

Copy link
Copy Markdown
Member Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The board snapshot omits fully qualified alias targets, causing affected configurations to report USB_CDC instead of UART0 after syncing.

1 open issue
What changed in this PR

This PR extends the dashboard’s logger-default resolution to use nRF52 chip variants, following the existing ESP32 approach and supporting upstream nRF54 UART defaults.

Changes:

  • Normalize nRF52 chip-specific logger defaults and snapshot board-to-chip mappings.
  • Resolve logger defaults by chip, retaining the platform fallback.
  • Add tests for snapshot normalization, board resolution, and substitutions.
File Description
tests/​test_platform_capabilities.py Tests nRF52 snapshot compatibility and logger-key normalization.
tests/​test_device_yaml.py Tests chip-specific defaults, fallbacks, and board substitutions.
script/​sync_components.py Generates nRF52 board variants and normalizes logger-default keys.
esphome_device_builder/​helpers/​device_yaml/​_parsing.py Resolves nRF52 chips from boards when selecting logger defaults.
esphome_device_builder/​definitions/​platform_capabilities.index.json Adds an empty board-variant map for the current snapshot.
esphome_device_builder/​definitions/​__init__.py Adds and loads the nRF52 board-variant capability field.

Review effort: Balanced

Comment thread script/sync_components.py Resolved
@bluetoothbot

Bluetooth Devices Bot (bluetoothbot) commented Nov 5, 2026 •

Copy link
Copy Markdown

Previous review — superseded by a newer review below.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tip

No blocking issues found — ready to merge.

@bdraco

Copy link
Copy Markdown
Member Author

@bluetoothbot

Bluetooth Devices Bot (bluetoothbot) commented Nov 5, 2026 •

Copy link
Copy Markdown

Previous review — superseded by a newer review below.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tip

No blocking issues found — ready to merge.

@bdraco

Copy link
Copy Markdown
Member Author

@bluetoothbot

Bluetooth Devices Bot (bluetoothbot) commented Nov 5, 2026 •

Copy link
Copy Markdown

Previous review — superseded by a newer review below.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tip

No blocking issues found — ready to merge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Missing per-chip UART option rows for the new logger defaults cause the shipped-catalog key-equality test to fail.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread script/sync_components.py Resolved
@bdraco

Copy link
Copy Markdown
Member Author

@bluetoothbot

Bluetooth Devices Bot (bluetoothbot) commented Nov 5, 2026 •

Copy link
Copy Markdown

Previous review — superseded by a newer review below.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tip

No blocking issues found — ready to merge.

@bdraco

Copy link
Copy Markdown
Member Author

@bluetoothbot

Copy link
Copy Markdown

PR Review — Key nRF52 logger defaults by chip, like esp32

Ready to merge. The last open suggestion is fixed and nothing new turned up.

What the PR does well:

  • extract_logger_interface uses the chip key only when that chip has its own default row. nRF52840, custom boards and boards it can't resolve keep the nrf52 default, as SplitDefault does.
  • The board snapshot includes the alias targets (3991e84). A test checks that each full Zephyr name gives the same chip as its short alias.
  • Each per-chip default gets its own options row (bf5dd57). A chip in VARIANTS_WITHOUT_USB is offered UART0 only, which matches upstream.
  • da4e188 fixes the earlier suggestion. Both the options builder (script/sync_components.py:8337) and its test now use _logger_default_key(key).upper(), so the key-to-chip mapping is written in one place.
  • If ESPHome names nRF52 chips but has no board rule, the sync now fails loudly. With an older ESPHome, both maps stay empty and behaviour is unchanged.

No open issues.


✅ Resolved since last review (1)

Previously-flagged issues verified fixed
  • script/sync_components.py:8336 The nrf52_ key to chip mapping is written twice


Checklist

  • No hardcoded secrets
  • Backward-compatible capabilities index (empty map falls back to platform default)
  • Per-chip logger defaults have matching options rows
  • Single source of truth for nRF52 key to chip mapping
  • New branches covered by tests

Automated review by Kōan (Claude) HEAD=da4e188 17s

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tip

No blocking issues found — ready to merge.

@bdraco
J. Nick Koston (bdraco) marked this pull request as ready for review November 5, 2026 03:06
@bdraco
J. Nick Koston (bdraco) merged commit cbc3c99 into main Nov 5, 2026
27 checks passed
@bdraco
J. Nick Koston (bdraco) deleted the logger-skip-nrf52-variant-defaults branch November 5, 2026 03:06
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants