Skip to content

fix(boards): compile Arduino Nano ESP32 (drop BOARD_HAS_PIN_REMAP, unescape extra_flags) - #1763

Closed
zackees wants to merge 3 commits into
mainfrom
agent/fix-nano-esp32-pin-remap
Closed

zackees wants to merge 3 commits into
mainfrom
agent/fix-nano-esp32-pin-remap

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Fixes #1760.

A blank sketch for board = arduino_nano_esp32 failed twice. Both failures are in how fbuild ingests the board's extra_flags; PlatformIO builds the same project with the same platform zip.

Error 1 — stale -DBOARD_HAS_PIN_REMAP in the bundled snapshot

crates/fbuild-config/assets/boards/json/arduino_nano_esp32.json shipped
-DBOARD_HAS_PIN_REMAP, so variants/arduino_nano_nora/io_pin_remap.cpp tripped its

#error This build system is not supported. Please rebuild without BOARD_HAS_PIN_REMAP

guard. That define is only legal paired with -DARDUINO_CORE_BUILD on core translation
units (Arduino's platform.txt), which fbuild does not set. Upstream pioarduino replaced
the flag with -DBOARD_USES_HW_GPIO_NUMBERS; the snapshot now matches upstream exactly.

Note for the sync tooling: the local ~/.platformio/platforms/espressif32 checkout on
this host is older than upstream and still carries the old flag, so a naive re-run of
enrich_boards would reintroduce it. The active platform cache wants refreshing before
the next enrichment pass.

Error 2 — extra_flags string defines kept their escape backslashes

Board JSON stores -DUSB_PRODUCT=\"NanoESP32\". PlatformIO feeds extra_flags through
Python shlex, so \" is an escaped literal quote and the macro body reaches GCC as
"NanoESP32". BoardConfig::get_defines() tokenized with shell_split, which strips the
quotes as delimiters but keeps the backslashes — yielding a define value of
\NanoESP32\ and GCC's

<command-line>: error: stray '\' in program
<command-line>: error: 'NanoESP32' was not declared in this scope

get_defines() now routes extra_flags through the same INI shell-quote consumer used
for build_flags (the #947 dequoting path, ini_parser::parse_flags), so escaped quotes
survive as a literal string define. Only this board ships escaped quotes in its
extra_flags, and the change is a no-op for flags without quotes.

Tests

  • fbuild-config: 233 passed, 0 failed (adds two regressions: the board defines
    BOARD_USES_HW_GPIO_NUMBERS and not BOARD_HAS_PIN_REMAP; escaped quotes survive the
    defines map).
  • fbuild-build-esp (248) + fbuild-build-arm (171): green.
  • cargo fmt --all --check clean; cargo clippy --workspace --all-targets -- -D warnings clean.

I could not exercise the full Windows build here (this host has no esp32 framework cache);
the unit tests pin the two ingestion behaviours that the reported errors trace to.

Agents that read AGENTS.md now get the same instructions as Claude.
A relative symlink (not a copy) so the two can never drift.
…escape extra_flags)

Two independent failures when building an empty sketch for
board = arduino_nano_esp32 (#1760):

1. The bundled snapshot carried -DBOARD_HAS_PIN_REMAP, so the Arduino
   core's variants/arduino_nano_nora/io_pin_remap.cpp tripped
   `#error This build system is not supported. Please rebuild without
   BOARD_HAS_PIN_REMAP`. That define is only legal alongside
   -DARDUINO_CORE_BUILD on core TUs, which fbuild does not set. Upstream
   pioarduino now ships -DBOARD_USES_HW_GPIO_NUMBERS instead; match it.

2. extra_flags string defines kept their escape backslashes.
   Board JSON stores -DUSB_PRODUCT=\"NanoESP32\"; PlatformIO feeds
   extra_flags through shlex so the macro body is the literal
   "NanoESP32", but get_defines() tokenized with shell_split, which
   strips the quotes as delimiters yet keeps the backslashes -> GCC saw
   -DUSB_PRODUCT=\NanoESP32\ and reported `stray '\\' in program`.
   Route through the same INI shell-quote consumer as build_flags (#947).

Tests: fbuild-config 233 pass; fbuild-build-esp + fbuild-build-arm green;
workspace clippy -D warnings and rustfmt clean.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

…e generation

The board snapshot must mirror upstream PlatformIO verbatim — the
validate_boards CI gate (ci/validate_boards.py) enforces it, so editing
arduino_nano_esp32.json to match a newer pioarduino release fails CI.
Handle the flag at the derive step instead: BoardConfig::get_defines()
now drops BOARD_HAS_PIN_REMAP.

Why: the flag is only legal alongside -DARDUINO_CORE_BUILD on the
Arduino core's own TUs (Arduino platform.txt adds it there). fbuild does
not define ARDUINO_CORE_BUILD, so passing it through makes
variants/<board>/io_pin_remap.cpp trip
`#error ... rebuild without BOARD_HAS_PIN_REMAP` (#1760).
Dropping it matches the #error's own instruction and Arduino's default
board menu (PinNumbers=byGPIONumber => -UBOARD_HAS_PIN_REMAP).
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Superseded by #1764. This branch picked up an unrelated AGENTS.md symlink commit injected by a repo hook at branch creation; since force-push isn't used here, #1764 re-uploads the same change (data layer reverted to upstream parity, both fixes moved into get_defines()) on a clean branch from main.

@zackees zackees closed this Oct 27, 2026
@zackees
zackees deleted the agent/fix-nano-esp32-pin-remap branch October 27, 2026 18:18
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Arduino Nano ESP32 does not compile: BOARD_HAS_PIN_REMAP without ARDUINO_CORE_BUILD, and string defines that keep their backslashes

1 participant