Custom board missing file: pins_arduino.h: No such file or directory

Hi all,
I’ve followed the documentation to create a custom board Custom Embedded Boards — PlatformIO v6.1 documentation My board is based on an existing board that already works and I have not done major changes. I’m using the option to put a “boards” folder within my project (to keep the project portable between machines).

My custom board shows up when I list it with

pio boards --installed

… but when I try to compile my project, it fails to compile since I need to define a pins_arduino.h file as well:

/Users/jensa/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-gpio.h:29:10: fatal error: pins_arduino.h: No such file or directory

I’ve created (or rather duplicated) this file and tried putting this file in several locations in my project with no result. I’ve also tried making a variant-folder with this file within at the location where all the other boards do this (/Users/username/Documents/PlatformIO/Projects/arduino-esp32/variants/myCustomPCB/ on my Mac)

Anyone know how to resolve this?

The pins_arduino.h is usually a part of the variants folder of the framework, that is, if a board declares "variant":"xyz" in its board JSON file, then <package dir>/framework-arduinoespressif32/variants/xyz/pins_arduino.h is expected to exist.

As you can see in

the builder script however also allows a redirection of the variants directory from the framework package to a project-local folder. I.e., if your project has a variants folder, you can do

board_build.variants_dir = variants

to resolve the issue.

This has been discussed before.

Thanks for the swift reply. This almost resolved my problem. Using the “global” variants directory did not work. I then created the “variants” folder and dropped “pins_arduino.h” inside it. That still failed. I then made a subfolder in the “variants” folder with the name of my custom board and then it complied as expected. So in order to use a custom board locally, you’ll need to do the following:

Installing locally (in a single project)

  1. Create boards directory in your project folder (if it doesn’t exist).
  2. Create myboard.json file in this boards directory.
  3. Search available boards via pio boards command. You should see myboard board.
  4. Create variants directory in your project folder (if it doesn’t exist).
  5. Append the following line to your platformio.ini
    board_build.variants_dir = variants

It would be convenient if this was mentioned on the documentation page that lists how to officially add custom boards Custom Embedded Boards — PlatformIO v6.1 documentation

Can I make a PR to with the above instructions added? https://github.com/platformio/platformio-docs/blob/07f966a65c2392cae4bcfc1b0e4f9f8a85b831d0/platforms/creating_board.rst#L22

variants_dir is very Arduino-specific and sometimes not all builder scripts support it. But indeed better documentation is needed.

Go for it, don’t let me restrict you from making a PR, I’m not even staff. The actual devs will judge the PR.

1 Like