Skip to content

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

Closed

Description

@stevenmunn312-tech

Summary

A blank sketch for board = arduino_nano_esp32 fails while fbuild builds the
core. PlatformIO builds the same project. There are two separate errors:

  1. variants/arduino_nano_nora/io_pin_remap.cpp: #error This build system is not supported. Please rebuild without BOARD_HAS_PIN_REMAP. fbuild defines
    BOARD_HAS_PIN_REMAP, which PlatformIO does not, and does not define the
    ARDUINO_CORE_BUILD the core then requires.
  2. cores/esp32/USB.cpp: USB_PRODUCT and USB_MANUFACTURER are not string
    literals. The board manifest declares them as escaped string defines, and
    the backslashes reach GCC.

Error 1 stops the build first. Error 2 appears once Error 1 is out of the way
(build_flags = -DARDUINO_CORE_BUILD, as a diagnostic only).

Environment

  • fbuild 2.5.45 (PyPI wheel, win_amd64) on Windows 11, and on GitHub Actions
    windows-latest
  • pioarduino platform 55.03.312-1 (Arduino core 3.3.12, ESP-IDF 5.5.5);
    the same errors on 55.03.311 (core 3.3.11) and on the default stable
  • Toolchain xtensa-esp-elf-14.2.0_20260121
  • Compared with PlatformIO Core 6.2.0, same platform zip, same project

Steps to reproduce

platformio.ini:

[env:nano]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312-1/platform-espressif32.zip
board = arduino_nano_esp32
framework = arduino

src/main.ino:

void setup() {}
void loop() {}
fbuild build -e nano

Result

fbuild, as above:

build error: build failed: compilation failed for ...\esp32-core-3.3.12\variants\arduino_nano_nora\io_pin_remap.cpp:
...\variants\arduino_nano_nora\io_pin_remap.cpp:6:2: error: #error This build system is not supported. Please rebuild without BOARD_HAS_PIN_REMAP.

fbuild with build_flags = -DARDUINO_CORE_BUILD added:

build error: build failed: compilation failed for ...\esp32-core-3.3.12\cores\esp32\USB.cpp:
<command-line>: error: stray '\' in program
...\cores\esp32\USB.cpp:133:46: note: in expansion of macro 'USB_PRODUCT'
<command-line>: error: stray '\' in program
...\cores\esp32\USB.cpp:133:78: note: in expansion of macro 'USB_MANUFACTURER'
<command-line>: error: 'NanoESP32' was not declared in this scope
<command-line>: error: 'Arduino' was not declared in this scope; did you mean 'Arduino_h'?

Expected

The build succeeds. PlatformIO 6.2.0 builds the same project with the same
platform zip ([SUCCESS], core 3.3.12, flash 360,206 B), and Arduino CLI 1.5.1
builds the board on core 3.3.12 (esp32:esp32:nano_nora:PinNumbers=byGPIONumber).

Causes, as far as we can tell

Error 1. The board manifest does not set BOARD_HAS_PIN_REMAP, and nothing in
the core defines it. Under PlatformIO it stays undefined: io_pin_remap.cpp
compiles with the variant's own
#warning The build system forces the Arduino API to use GPIO numbers on a board that has custom pin mapping., the branch for !defined(BOARD_HAS_PIN_REMAP).
Under fbuild it is defined. The only source we found is the core's boards.txt:

nano_nora.build.defines=-DBOARD_HAS_PIN_REMAP {build.disable_pin_remap} -DBOARD_HAS_PSRAM '-DUSB_MANUFACTURER="Arduino"' '-DUSB_PRODUCT="Nano ESP32"'

so fbuild seems to take build.defines from boards.txt for this board.
Arduino's own builds pair that define with -DARDUINO_CORE_BUILD on core
translation units (platform.txt), and its PinNumbers=byGPIONumber menu sets
build.disable_pin_remap=-UBOARD_HAS_PIN_REMAP, which turns remapping off. We
could not see fbuild's compile command lines, so where the define comes from is
inference; that it is defined under fbuild and not under PlatformIO is not.

Error 2. boards/arduino_nano_esp32.json in pioarduino's platform has:

"extra_flags": [
  "-DUSB_MANUFACTURER=\\\"Arduino\\\"",
  "-DUSB_PRODUCT=\\\"NanoESP32\\\"",

Decoded from JSON, each flag is -DUSB_PRODUCT=\"NanoESP32\". PlatformIO splits
extra_flags the way a shell would, so \" becomes " and GCC gets
-DUSB_PRODUCT="NanoESP32". fbuild appears to pass the decoded text through
unchanged, so the macro body is \"NanoESP32\". Any board manifest that uses
this escaping would fail the same way.

Suggested fixes

  1. Match PlatformIO's flags for this board: leave BOARD_HAS_PIN_REMAP out when
    the board manifest does not set it, or, where it is set, also define
    ARDUINO_CORE_BUILD for core and variant translation units as Arduino's
    platform.txt does.
  2. Apply PlatformIO's shell-style unescaping to board extra_flags (and
    probably build_flags), so \" yields ".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions