Repository navigation
fix(boards): compile Arduino Nano ESP32 (drop BOARD_HAS_PIN_REMAP, unescape extra_flags) - #1764
Merged
Merged
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1760.
A blank sketch for
board = arduino_nano_esp32failed twice; PlatformIO builds the sameproject with the same platform zip. Both failures are in how fbuild turns a board's
extra_flagsinto compiler defines — not in the board data, which deliberately mirrorsupstream PlatformIO (the
validate_boardsCI gate enforces that), so the fixes live in thederive step.
Error 1 —
-DBOARD_HAS_PIN_REMAPmust not reach the compilervariants/arduino_nano_nora/io_pin_remap.cppguards ondefined(BOARD_HAS_PIN_REMAP) && !defined(ARDUINO_CORE_BUILD)and errors out:That pairing is only legal on the core's own translation units, where Arduino's
platform.txtadds-DARDUINO_CORE_BUILD. fbuild never definesARDUINO_CORE_BUILD, so theflag carried by the board manifest tripped the guard.
BoardConfig::get_defines()now dropsBOARD_HAS_PIN_REMAP. That follows the#error's owninstruction and Arduino's default board menu (
PinNumbers=byGPIONumber⇒-UBOARD_HAS_PIN_REMAP), i.e. GPIO-number pin mapping. The newer pioarduino releases expressthe same intent via
-DBOARD_USES_HW_GPIO_NUMBERS; the snapshot is left untouched so thevalidate_boardsgate keeps passing.Error 2 —
extra_flagsstring defines kept their escape backslashesBoard JSON stores
-DUSB_PRODUCT=\"NanoESP32\". PlatformIO feedsextra_flagsthrough Pythonshlex, so\"is an escaped literal quote and the macro body must reach GCC as"NanoESP32".get_defines()tokenized withshell_split, which strips the quotes asdelimiters but keeps the backslashes — the define value became
\NanoESP32\, giving GCC:extra_flagsnow routes through the same INI shell-quote consumer used forbuild_flags(the#947dequoting path,ini_parser::parse_flags, widened topub(crate)). Only this boardships 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 dropBOARD_HAS_PIN_REMAPwhile unrelated snapshot flags survive; escaped quotes survive thedefines map as
"NanoESP32").fbuild-build-esp(248) +fbuild-build-arm(171): green.cargo fmt --all --checkclean;cargo clippy --workspace --all-targets -- -D warningsclean.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.mdsymlink commit injected onto its branchby a repo hook at branch creation; since force-push is not used here, this is a clean branch
from
maininstead.