Implementation:78 Xiaozhi esp32 Board Implementations
| Knowledge Sources | |
|---|---|
| Domains | Board_Hardware, Embedded_Systems |
| Last Updated | 2026-10-17 00:00 GMT |
Overview
Concrete board implementation files for XiaoZhi voice assistant firmware, each exporting exactly one board factory via DECLARE_BOARD and wiring together the board's audio codec, display, LED, network transport, buttons, and power management.
Description
Each board directory under main/boards/ contains a .cc file that defines a board class inheriting from WifiBoard, Ml307Board, DualNetworkBoard, EthernetBoard, or RndisBoard. The board class implements GetBoardType(), GetAudioCodec(), GetDisplay(), GetLed(), GetNetwork(), StartNetwork(), SetPowerSaveLevel(), and optionally GetCamera().
The following large board implementations (≥300 lines) are documented here:
| Board File | Lines | Base Class | Key Hardware |
|---|---|---|---|
chd_esp32s3_box_board.cc |
859 | DualNetworkBoard | ES8311+ES7210, SPI LCD, GT911 touch, camera, power manager |
ai_passport_board.cc |
1079 | WifiBoard | Custom codec, CW2017 battery, camera, power manager |
df_k10_board.cc |
304 | WifiBoard | K10 audio codec, custom LED, display |
jiuchuan_dev_board.cc |
396 | WifiBoard | GC9301 LCD, custom GPIO manager, power controller |
lcdwiki-es3c35p.cc |
379 | WifiBoard | 3.5" LCD, touch, audio |
atoms3_echo_base.cc |
370 | WifiBoard | AtomS3 echo base, I2C codec |
m5stack_cardputer_adv.cc |
380 | WifiBoard | TCA8418 keyboard, WiFi config UI, LCD |
m5stack_core_s3.cc |
395 | WifiBoard | CoreS3, ES8311, touch, AEC |
m5stack_corep4.cc |
368 | WifiBoard | CoreP4, MIPI display, camera |
otto_robot.cc |
420 | WifiBoard | Otto robot, 6 servos, MCP controller |
sensecap_watcher.cc |
667 | WifiBoard | SSCMA camera, AI vision, custom codec |
sp-esp32-s3-1.28-box.cc |
491 | WifiBoard | 1.28" round display, power manager |
sp-esp32-s3-1.54-muma.cc |
325 | WifiBoard | 1.54" display, power manager |
taiji_pi_s3.cc |
693 | WifiBoard | Large LCD, touch, camera, power manager |
wk-esp32s3-dev.cc |
319 | WifiBoard | ILI9486/NV3030B LCD |
xingzhi-abs-2.0.cc |
389 | WifiBoard | Custom LCD display, power manager |
Usage
Reference this implementation when:
- Studying how a concrete board wires together all subsystems
- Adding a new board (follow the pattern in the closest existing board)
- Understanding which board class to inherit from for a given network type
Code Reference
Source Location
- Repository: XiaoZhi ESP32
- Directory:
main/boards/(various subdirectories)
Signature
// Typical board class pattern (example: chd_esp32s3_box_board.cc)
class ChdEsp32s3BoxBoard : public DualNetworkBoard {
public:
ChdEsp32s3BoxBoard() : DualNetworkBoard(BOARD_NAME, AUDIO_CODECS, DISPLAY, ...) {
// Initialize I2C bus
// Create audio codec (BoxAudioCodec)
// Create display (SpiLcdDisplay / EmoteDisplay)
// Create LED (SingleLed / GpioLed)
// Create camera (Esp32Camera)
// Initialize buttons
// Set up power manager
// Register MCP tools
}
std::string GetBoardType() override { return "chd-esp32s3-box"; }
AudioCodec* GetAudioCodec() override { return codec_.get(); }
Display* GetDisplay() override { return display_.get(); }
Led* GetLed() override { return led_.get(); }
Camera* GetCamera() override { return camera_.get(); }
void StartNetwork() override;
void SetPowerSaveLevel(PowerSaveLevel level) override;
std::string GetBoardJson() override;
std::string GetDeviceStatusJson() override;
};
DECLARE_BOARD(ChdEsp32s3BoxBoard); // Exactly one per build
Import
#include "wifi_board.h" // or ml307_board.h, dual_network_board.h, etc.
#include "codecs/box_audio_codec.h"
#include "display/lcd_display.h"
#include "led/single_led.h"
#include "button.h"
#include "config.h" // board-specific pin definitions
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config.h | #define macros | Yes | Board-specific pin definitions and hardware parameters |
| Board base class | WifiBoard etc. | Yes | Provides network, protocol, audio service wiring |
Outputs
| Name | Type | Description |
|---|---|---|
| Board factory | create_board() | Exported via DECLARE_BOARD macro; returns new board instance |
| Hardware objects | unique_ptr | Codec, display, LED, camera, buttons initialized and owned by board |
Usage Examples
Board Selection via Build System
# Build a specific board variant
python3 scripts/build.py main/boards/chd/chd-esp32s3-box --name chd-esp32s3-box
Adding a New Board
// main/boards/my-board/my_board.cc
#include "wifi_board.h"
#include "codecs/es8311_audio_codec.h"
#include "led/single_led.h"
#include "config.h"
class MyBoard : public WifiBoard {
public:
MyBoard() : WifiBoard(BOARD_NAME) {
// I2C bus init
i2c_master_bus_config_t i2c_cfg = { /* ... */ };
i2c_master_bus_handle_t bus;
i2c_new_master_bus(&i2c_cfg, &bus);
// Audio codec
codec_ = std::make_unique<Es8311AudioCodec>(
bus, I2C_NUM_0, 16000, 16000,
CONFIG_I2S_MCLK, CONFIG_I2S_BCLK, CONFIG_I2S_WS,
CONFIG_I2S_DOUT, CONFIG_I2S_DIN,
CONFIG_PA_PIN, 0x18);
// LED
led_ = std::make_unique<SingleLed>(CONFIG_LED_PIN);
// Buttons
button_ = std::make_unique<Button>(CONFIG_BUTTON_PIN);
button_->OnClick([this]() { /* handle */ });
}
std::string GetBoardType() override { return "my-board"; }
// ... other overrides
};
DECLARE_BOARD(MyBoard);
Related Pages
Implements Principle
- Principle:78_Xiaozhi_esp32_Board_Abstraction_Layer
- Principle:78_Xiaozhi_esp32_Build_System_Configuration
- Principle:78_Xiaozhi_esp32_Power_Management