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 Kconfig Board Selection

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

Overview

Concrete tool for Kconfig-based board selection provided by the XiaoZhi firmware, defining a choice BOARD_TYPE block in main/Kconfig.projbuild that maps each board to a Kconfig symbol and its chip target.

Description

main/Kconfig.projbuild contains a Pattern Doc — the Kconfig choice BOARD_TYPE block. It is a critical link in the build configuration chain. Each board has one config BOARD_TYPE_<NAME> entry inside the choice block:

  • The entry's bool prompt is the board's human-readable name
  • select IDF_TARGET_<CHIP> sets the chip target
  • Only one board can be selected (Kconfig choice ensures exclusivity)
  • scripts/build.py sets the CONFIG_BOARD_TYPE_<NAME> symbol via idf.py set-config
  • main/CMakeLists.txt uses if(CONFIG_BOARD_TYPE_<NAME>) to select source files

Usage

Reference this implementation when:

  • Adding a new board to the Kconfig choice
  • Understanding how board selection maps to chip target
  • Debugging "board type not found" build errors
  • Understanding the Kconfig → CMake dependency

Code Reference

Source Location

Signature

choice BOARD_TYPE
    prompt "Board Type"
    default BOARD_TYPE_BREAD_COMPACT_WIFI

config BOARD_TYPE_BREAD_COMPACT_WIFI
    bool "Bread Compact WiFi"
    select IDF_TARGET_ESP32S3

config BOARD_TYPE_M5STACK_CORES3
    bool "M5Stack CoreS3"
    select IDF_TARGET_ESP32S3

config BOARD_TYPE_SEEED_XIAO_ESP32S3
    bool "Seeed XIAO ESP32-S3"
    select IDF_TARGET_ESP32S3

# ... one config per board

endchoice

Import

# Kconfig is processed by the ESP-IDF build system automatically.
# No import needed — the build system reads Kconfig.projbuild.

I/O Contract

Inputs

Name Type Required Description
choice BOARD_TYPE Kconfig block Contains one config per board
config BOARD_TYPE_<NAME> Kconfig entry bool prompt + select IDF_TARGET_<CHIP>

Outputs

Name Type Description
CONFIG_BOARD_TYPE_<NAME> Set to "y" for the selected board, used in CMakeLists.txt
IDF_TARGET_<CHIP> Chip target (e.g., ESP32S3, ESP32C3, ESP32P4)

Usage Examples

Adding a New Board to Kconfig

# In main/Kconfig.projbuild, inside the choice BOARD_TYPE block:
config BOARD_TYPE_MY_CUSTOM_BOARD
    bool "My Custom Board"
    select IDF_TARGET_ESP32S3

Corresponding CMakeLists.txt Entry

# In main/CMakeLists.txt:
elseif(CONFIG_BOARD_TYPE_MY_CUSTOM_BOARD)
    set(SRCS
        boards/my-board/board.cc
    )
    target_add_binary_assets(boards/my-board/assets)
endif()

Related Pages

Implements Principle

Requires Environment

Page Connections

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