Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:78 Xiaozhi esp32 Board Identity Immutability

From Leeroopedia
Knowledge Sources
Domains Embedded, Build_System
Last Updated 2026-10-17 00:00 GMT

Overview

Board names and pin assignments are immutable once released — changing them breaks OTA compatibility and orphanes existing devices on the old firmware branch.

Description

Each board has a unique identity defined by its directory name in `main/boards/`, its `config.json` board type, and its `config.h` pin assignments. This identity is baked into the firmware binary and used by the OTA server to determine which firmware image to serve to which device. The `User-Agent` header sent during OTA version check includes the board type. If a board's name or pin map changes, the OTA server treats it as a different device — existing devices running the old firmware will no longer receive updates for the "new" board.

When adding support for different hardware, you must create a new board with a unique name rather than modifying an existing board's pins. This is codified in the project's AGENTS.md: "Never alter an existing board's pins to support different hardware. Add a uniquely named board or release variant."

Usage

Use this heuristic when supporting new hardware variants. Always create a new board directory with a unique name. If the hardware is a minor variation of an existing board (e.g., different display, different flash size), create a release variant using `--name` in `scripts/build.py` rather than modifying the original board.

The Insight (Rule of Thumb)

  • Action: Never modify an existing board's name, pin assignments, or partition table. Create a new board or a release variant instead.
  • Value: Board identity = directory name + `config.json` board type + `DECLARE_BOARD` class. These three must be unique and stable.
  • Trade-off: Creates more board directories (138+ currently) but preserves OTA compatibility for every device ever shipped. The maintenance cost is bounded by `scripts/build.py` which auto-discovers boards.
  • Compatibility: The board identity chain: `config.json` → `scripts/build.py` → `main/Kconfig.projbuild` → `main/CMakeLists.txt` → board source + `config.h`. All links must be updated when adding a new board.

Reasoning

The OTA server uses the board type (from `User-Agent` header) and firmware version to select the correct firmware binary. If board "waveshare-esp32-s3-touch-lcd-2.8" has its pins changed to support a new display revision, all existing devices with the old display will receive the new firmware and fail — the pin map won't match their hardware. By creating a new board ("waveshare-esp32-s3-touch-lcd-2.8-v2"), old devices continue to receive updates compatible with their hardware, and new devices get the correct pin map.

The same principle applies to partition tables — changing the partition layout on an existing board means the OTA can't write to the expected partitions, potentially corrupting NVS or the app partition.

Code Evidence

Board identity macro from `main/boards/common/board.h:87-90`:

#define DECLARE_BOARD(BOARD_CLASS_NAME) \
void* create_board() { \
    return new BOARD_CLASS_NAME(); \
}

Board type reported via User-Agent from `main/ota.cc:69-77`:

    auto user_agent = SystemInfo::GetUserAgent();
    http->SetHeader("Activation-Version", has_serial_number_ ? "2" : "1");
    http->SetHeader("Device-Id", SystemInfo::GetMacAddress().c_str());
    http->SetHeader("Client-Id", board.GetUuid());
    http->SetHeader("User-Agent", user_agent);

Project rule from `AGENTS.md`:

Never alter an existing board's pins to support different hardware. Add a uniquely
named board or release variant; board identity affects OTA compatibility.

Board build chain from `AGENTS.md`:

config.json -> scripts/build.py -> main/Kconfig.projbuild -> main/CMakeLists.txt
-> board source and config.h.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment