Skip to content

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

Merged
zackees merged 1 commit into
mainfrom
agent/fix-nano-esp32-pin-remap-v2
Oct 27, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/fix-nano-esp32-pin-remap-v2

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; PlatformIO builds the same
project with the same platform zip. Both failures are in how fbuild turns a board's
extra_flags into compiler defines — not in the board data, which deliberately mirrors
upstream PlatformIO (the validate_boards CI gate enforces that), so the fixes live in the
derive step.

Error 1 — -DBOARD_HAS_PIN_REMAP must not reach the compiler

variants/arduino_nano_nora/io_pin_remap.cpp guards on
defined(BOARD_HAS_PIN_REMAP) && !defined(ARDUINO_CORE_BUILD) and errors out:

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

That pairing is only legal on the core's own translation units, where Arduino's
platform.txt adds -DARDUINO_CORE_BUILD. fbuild never defines ARDUINO_CORE_BUILD, so the
flag carried by the board manifest tripped the guard.

BoardConfig::get_defines() now drops BOARD_HAS_PIN_REMAP. That follows the #error's own
instruction and Arduino's default board menu (PinNumbers=byGPIONumber ⇒
-UBOARD_HAS_PIN_REMAP), i.e. GPIO-number pin mapping. The newer pioarduino releases express
the same intent via -DBOARD_USES_HW_GPIO_NUMBERS; the snapshot is left untouched so the
validate_boards gate keeps passing.

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 must reach GCC as
"NanoESP32". get_defines() tokenized with shell_split, which strips the quotes as
delimiters but keeps the backslashes — the define value became \NanoESP32\, giving GCC:

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

extra_flags now routes through the same INI shell-quote consumer used for build_flags (the
#947 dequoting path, ini_parser::parse_flags, widened to pub(crate)). Only this board
ships escaped quotes in its extra_flags; the change is a no-op for flags without quotes.

Tests

  • fbuild-config: 233 passed, 0 failed (two regressions added: the board's defines drop
    BOARD_HAS_PIN_REMAP while unrelated snapshot flags survive; escaped quotes survive the
    defines map as "NanoESP32").
  • 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 run the full Windows ESP32 build here (no esp32 framework cache on this host);
the unit tests pin the two ingestion behaviours the reported errors trace to.


Supersedes #1763, which had an unrelated AGENTS.md symlink commit injected onto its branch
by a repo hook at branch creation; since force-push is not used here, this is a clean branch
from main instead.

…escape extra_flags)

Fixes #1760. A blank sketch for `board = arduino_nano_esp32` failed
twice; both failures are in how fbuild turns a board's `extra_flags`
into compiler defines. The bundled board snapshot deliberately mirrors
upstream PlatformIO (the CI `validate_boards` gate enforces it), so both
fixes live in the derive step, not the board data.

1. `-DBOARD_HAS_PIN_REMAP` must not reach the compiler.
   The Arduino core's `variants/<board>/io_pin_remap.cpp` guards on
   `defined(BOARD_HAS_PIN_REMAP) && !defined(ARDUINO_CORE_BUILD)` and
   errors out — that pairing is only legal on the core's own TUs, where
   Arduino's `platform.txt` adds `-DARDUINO_CORE_BUILD`. fbuild never
   defines `ARDUINO_CORE_BUILD`, so the flag (carried by the Nano's
   PlatformIO board JSON, and by the newer pioarduino releases'
   equivalent `-DBOARD_USES_HW_GPIO_NUMBERS`) tripped
   `#error This build system is not supported. Please rebuild without
   BOARD_HAS_PIN_REMAP`.
   `BoardConfig::get_defines()` now drops the define. That matches the
   `#error`'s own instruction and Arduino's default board menu
   (`PinNumbers=byGPIONumber` => `-UBOARD_HAS_PIN_REMAP`), i.e.
   GPIO-number pin mapping.

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 must reach GCC as `"NanoESP32"`. `get_defines()`
   tokenized with `shell_split`, which strips the quotes as delimiters but
   keeps the backslashes — yielding the define value `\NanoESP32\` and
   GCC's `stray '\' in program` / `'NanoESP32' was not declared`. It now
   routes `extra_flags` through the same INI shell-quote consumer as
   `build_flags` (the `#947` dequoting path, `ini_parser::parse_flags`,
   now `pub(crate)`).

Tests: fbuild-config 233 pass (adds two regressions); fbuild-build-esp
(248) + fbuild-build-arm (171) green; `cargo fmt --all --check` and
`cargo clippy --workspace --all-targets -- -D warnings` 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.

@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 4086895 Oct 27, 2026
28 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 28, 2026
@zackees
zackees deleted the agent/fix-nano-esp32-pin-remap-v2 branch November 5, 2026 05:51
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