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

Implementation:78 Xiaozhi esp32 config json

From Leeroopedia
Knowledge Sources
Domains Build_Systems, Configuration_Management
Last Updated 2026-10-17 00:00 GMT

Overview

Concrete tool for board build declaration provided by the XiaoZhi firmware, defining a JSON manifest schema that specifies the chip target, build variants, and sdkconfig overrides consumed by scripts/build.py.

Description

config.json is a Pattern Doc — it documents a file convention. Each board directory contains a config.json that scripts/build.py parses to configure the build. The JSON schema includes:

  • target: The ESP32 chip target (e.g., "esp32s3", "esp32c3", "esp32p4")
  • builds: An array of build variants, each with:
    • name: Variant name (used with --name flag)
    • sdkconfig_append: List of KEY=y strings that select Kconfig options (e.g., "CONFIG_BOARD_TYPE_BREAD=y")
  • manufacturer (optional): Manufacturer name for documentation
  • preview (optional): Boolean indicating a preview/incomplete board

The name field in builds becomes the board identity that the server uses for OTA compatibility. Changing this name after deployment breaks OTA updates for existing devices.

Usage

Reference this implementation when:

  • Adding a new board's build configuration
  • Understanding how build.py discovers and selects boards
  • Configuring multiple build variants for one board (e.g., WiFi vs cellular)
  • Understanding sdkconfig_append options

Code Reference

Source Location

  • Repository: XiaoZhi ESP32
  • Files: main/boards/*/config.json (one per board), scripts/build.py (parser)

Signature

{
    "target": "esp32s3",
    "builds": [
        {
            "name": "wifi",
            "sdkconfig_append": [
                "CONFIG_BOARD_TYPE_BREAD_COMPACT_WIFI=y"
            ]
        }
    ]
}

Import

# Parsed by scripts/build.py:
import json
with open(config_path) as f:
    config = json.load(f)
target = config["target"]
builds = config["builds"]

I/O Contract

Inputs

Name Type Required Description
target string ESP32 chip target (e.g., "esp32s3")
builds array Build variant definitions
builds[].name string Variant name (board identity for OTA)
builds[].sdkconfig_append string[] Kconfig options to append
manufacturer string Manufacturer name
preview boolean Marks as preview/incomplete

Outputs

Name Type Description
(parsed by build.py) Python dict with target, builds, and sdkconfig options
idf.py set-config Each sdkconfig_append entry becomes an idf.py set-config call

Usage Examples

Single-Variant Board (WiFi only)

{
    "target": "esp32s3",
    "builds": [
        {
            "name": "wifi",
            "sdkconfig_append": [
                "CONFIG_BOARD_TYPE_MY_BOARD=y"
            ]
        }
    ]
}

Multi-Variant Board (WiFi + Cellular)

{
    "target": "esp32s3",
    "builds": [
        {
            "name": "wifi",
            "sdkconfig_append": [
                "CONFIG_BOARD_TYPE_DUAL_BOARD_WIFI=y"
            ]
        },
        {
            "name": "ml307",
            "sdkconfig_append": [
                "CONFIG_BOARD_TYPE_DUAL_BOARD_ML307=y"
            ]
        }
    ]
}

Building

# Discover available boards
python3 scripts/build.py --list-boards

# Build a specific variant
python3 scripts/build.py main/boards/my-board --name wifi

# Build with zip output
python3 scripts/build.py main/boards/my-board --name wifi --zip

Related Pages

Implements Principle

Requires Environment

Page Connections

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