Skip to content
php-baremetal REGISTRY
Publish a package

php-baremetal/boards-arduino

bm-boards MIT

Board files of the Arduino boards for php-baremetal: chip, memory, console, pin names and the on-board peripherals with their pins.

needs no platform HAL

Package · Boards

Arduino boards

The board file of the Arduino Nano ESP32, with its pin names, read by the esp32 SDK from boards/esp32/ once the package is installed. No code, no requirements.

boards-arduino is a board package (Composer type bm-boards): a set of board files and nothing else. A project that requires it can name its board in extra.baremetal.board, as it names a board of the SDK. The esp32 SDK reads the files in boards/esp32/ and checks each one against its chips, exactly as it checks its own boards.

The package describes the Arduino® Nano ESP32. Arduino® is a trademark of Arduino S.r.l.; this package is not made or endorsed by Arduino.

Requirements

None. The package requires neither the SDK nor any driver, and its composer.json has no extra.baremetal. Whether a board fits the SDK in use is decided when the SDK loads it: a board that names a chip, a PSRAM type or a block type the SDK does not support stops the build with a message that starts with the package and the file (php-baremetal/boards-arduino: boards/esp32/<file>.json: ...). The pins key of the board file needs an SDK that reads board files of spec 1.5 or later (esp32 SDK 2.0).

Install

bash in the project folder
composer require php-baremetal/boards-arduino

phpbm init lists this board next to the SDK's (the SDK names this package in board-packages of its sdk.json) and, when you pick it, writes the package into the project's require and proposes the drivers of the board's blocks. The conductor installs the package into .phpbm/packages/ and writes it into the manifest; the build compiles nothing of it.

json composer.json
{
  "name": "acme/nano-blink",
  "type": "project",
  "repositories": [
    { "type": "composer", "url": "https://repository.php-baremetal.com", "canonical": true }
  ],
  "require": {
    "php-baremetal/conductor": "^1.0",
    "php-baremetal/boards-arduino": "^1.0",
    "php-baremetal/ext-sys": "^1.0",
    "php-baremetal/ext-gpio": "^1.0"
  },
  "config": {
    "allow-plugins": { "php-baremetal/conductor": true },
    "platform": { "php": "8.5.13" }
  },
  "extra": {
    "baremetal": {
      "sdk": "esp32@^2.0",
      "board": "arduino-nano-esp32",
      "runtime": "init-loop",
      "storage": "embedded"
    }
  }
}

Boards

Board id Product Chip PSRAM Flash Blocks
arduino-nano-esp32 Arduino Nano ESP32 (ABX00083) ESP32-S3 octal 16 MB network wifi, i2c i2c

The board is built on the u-blox NORA-W106-10B module (ESP32-S3, 8 MB of octal PSRAM) with 16 MB of flash, and has the console on the native USB port behind the USB-C connector (usb-jtag).

Pin names

The board file has a pins key: the names printed on the board (D0–D13, A0–A7) and the names of the Arduino core (LED_BUILTIN, LED_RED, SDA, SCK, ...), each with its GPIO number. Two things use them:

  • PHP. The firmware registers the class Baremetal\Board\Pin with one integer constant per name: Pin::D13 is 48, Pin::A3 is 4. With the SDK option board-constants set to global, the same names are also global constants (D13, A3). Any function that takes a GPIO number takes them, for example gpio_mode() and gpio_write() of ext-gpio.
  • Blocks. A block value of the same file can name a pin instead of a number: the i2c block says "sda": "A4", and the SDK reads GPIO 11. Values of board overrides are resolved with the same names.
php main.php
<?php
use Baremetal\Board\Pin;

function setup(): void
{
    gpio_mode(Pin::LED_BUILTIN, GPIO_OUTPUT);
}

function loop(int $tick): void
{
    gpio_write(Pin::LED_BUILTIN, $tick % 2);
    delay(500); // ext-sys
}
json composer.json, extra.baremetal, with global names
{
  "sdk": "esp32@^2.0",
  "board": "arduino-nano-esp32",
  "runtime": "init-loop",
  "storage": "embedded",
  "options": {
    "board-constants": "global"
  }
}

With that option the script writes gpio_mode(LED_BUILTIN, GPIO_OUTPUT). The full table of names is on the board page.

Catalog

boards/catalog.json gives, for each board, the Arduino documentation page (docs) and a product photo (photo) from the Arduino store, both online URLs, grouped by SDK name and keyed by board id. The package registry site uses it to link and show the boards; the build does not read it, and it sits outside boards/esp32/, so the SDK does not take it for a board.

Blocks and their drivers

A board's network block is handled by the SDK itself; the script connects to Wi-Fi with ext-wifi. The i2c block is read by a driver package, which the project requires itself: a block without its driver is left alone. The drivers name the blocks they handle in extra.baremetal.board-blocks.

Block Type Package Boards
network wifi ext-wifi (to connect from PHP) Arduino Nano ESP32
i2c i2c ext-i2c Arduino Nano ESP32

The pin names need no driver: Baremetal\Board\Pin is registered by the firmware for every board.

Board ids

The id is the file name without .json. If another source installed in the project (the SDK or another board package) defines the same id, the short id is refused and the message names both sources; the long form picks this package: "board": "php-baremetal/boards-arduino:arduino-nano-esp32".

A project changes the pins of a block, or adds a block, with board overrides, without editing the file. Overrides cannot add or change pin names.

Related