yahboom
HomeTutorialsProduct
Solution
Blog
Online Store
About Us
EN/中文
Store
ESP32 Core Board📖
1. ESP32 Introduction
  • 1. ESP32S3 Overview
  • 2. Environment Setup Introduction
  • 3. Dev Board Introduction
2. ESP-IDF Development Tutorial
1. Before Development
  • 1. Environment Setup (Windows)
  • 2. Environment Setup (Linux)
  • 3. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. DMA
  • 8. ADC
  • 9. PWM Breathing LED
  • 10. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. PSRAM External Memory Experiment
  • 5. Flash Read and Write Experiment
  • 6. USB Emulated Mass Storage Experiment
4. FreeRTOS operating system
  • 1.FreeRTOS Core Concepts Theory
  • 2.Task Creation and Management
  • 3.Queue
  • 4.Binary Semaphore
  • 5.Mutex
  • 6.Event Groups
  • 7.Software Timer
  • 8.Task Scheduler
  • 9.Low Power Mode
  • 10.Deadlock
  • 11.Priority Inversion
5. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. Socket Programming Basics
  • 9. HTTP Client Experiment
  • 10. HTTP Server Experiment
  • 11. MQTT IoT Communication Protocol
  • 12. WIFI OTA Upgrade
  • 13. Bluetooth Fundamentals
  • 14. Bluetooth Slave Mode
  • 15. Bluetooth Master Mode
6. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
7. Xiaozhi AI Voice
  • 1. Burn Xiaozhi Firmware
  • 2. Network and Configuration
  • 3. AI Agent Settings
  • 4. Program Analysis
  • 5. Free Chat
3. Arduino Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. ADC
  • 8. PWM Breathing LED
  • 9. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication
  • 2. I2C OLED Display
  • 3. SPI Bus Communication
  • 4. Flash Read and Write
  • 5. USB Emulated Mass Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Server Experiment
  • 5. UDP Client Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT IoT Communication Protocol
  • 11. WIFI OTA Upgrade
  • 12. Bluetooth Fundamentals
  • 13. Bluetooth Slave Mode
  • 14. Bluetooth Master Mode
5. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
4. MicroPython Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
  • 3. Thonny IDE
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. TIMER_IT
  • 5. Watchdog Timer
  • 6. ADC
  • 7. PWM Breathing LED
  • 8. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. Flash Read and Write Experiment
  • 5. Print Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT
  • 11. Bluetooth Fundamentals
  • 12. Bluetooth Slave Mode
  • 13. Bluetooth Master Mode
5. Audio Applications
  • 1. I2S Audio Playback Experiment
  • 2. Repeater Experiment
Download
  • Code
  • Hardware_Info
  • 3D_Model_File
  • Software_Tools
  • VMware
  • VM_File
Download ZIP

Welcome to ESP32 Core Board repository

1. Burn Xiaozhi Firmware

1. Burn Xiaozhi Firmware


1. Burn Xiaozhi Firmware1. Xiaozhi AI OverviewWhat is AI Xiaozhi?Implemented Features OverviewTutorial Coverage2. Configuration and Preparation1. Prerequisites2. Clone Source Repository3. Install Third-Party Component Dependencies4. Configuration and CompilationStep 1: Set Target ChipStep 2: menuconfig ConfigurationOpen menuconfig① Board Model② Flash Size③ Partition Table④ PSRAMSave and ExitStep 3: First Compilation5. Compilation and Flashing6. Comparison of Two Flashing MethodsMethod 1: Self-Compile and Flash (Sections 2~5 above)Method 2: Use Pre-compiled Firmware Direct Flash7. Verification: First Boot Logs


1. Xiaozhi AI Overview

What is AI Xiaozhi?

AI Xiaozhi is an open-source AI voice chat robot based on the ESP32 series chip, utilizing the AI capabilities of large language models like Qwen/DeepSeek, and implementing voice interaction and device control through the MCP (Model Context Protocol). It is essentially a "talking smart terminal": your words are collected, encoded by the device, and sent to the cloud AI; the voice returned from the cloud is decoded and played locally, enabling free human-machine dialogue.

This project is open-sourced by Brother Xia Ge and released under the MIT license. The current stable version is v2.2.6, requiring ESP-IDF ≥ 5.5.2.

Implemented Features Overview

FeatureDescription
Wi-Fi / 4G NetworkingSupports dual-mode networking via Wi-Fi and ML307 Cat.1 4G module
Offline Voice Wake-upBased on ESP-SR, supports custom wake words (e.g., "Hi,Andy")
Dual Protocol CommunicationWebSocket or MQTT+UDP
OPUS Audio CodecLow-latency, high-compression voice transmission
ASR + LLM + TTSStreaming speech recognition → LLM inference → speech synthesis
Voiceprint RecognitionIdentifies current speaker based on 3D Speaker
OLED / LCD DisplaySupports expressions, status, and dialogue text display
MCP Device ControlControl volume, lights, motors, GPIO, etc. via MCP protocol
Multi-languageChinese, English, Japanese
Multi-platformESP32-C3, ESP32-S3, ESP32-P4
OTA UpgradeSupports Wi-Fi wireless firmware upgrade

Tutorial Coverage

This tutorial breaks down the process of building Xiaozhi AI from scratch to free dialogue into five progressive chapters, each completing a verifiable milestone:

ChapterContentAfter Completion
1. Burn Xiaozhi FirmwareGet source code, configure ESP-IDF environment, install component dependenciesSuccessfully compile and flash official firmware
2. Network and ConfigurationWi-Fi provisioning, WebSocket/MQTT protocol selection, server connectionDevice successfully connects to network
3. AI Agent SettingsRegister AI platform, get API Key, configure LLM parametersDevice has an AI brain
4. Program AnalysisProject architecture, state machine, audio pipeline, MCP service, display systemUnderstand code for secondary development
5. Free ChatWake-up interaction, dialogue flow, custom configuration, troubleshootingFreely chat with Xiaozhi and customize features

Learning Suggestion: If this is your first time working with ESP32 or AI hardware development, it is recommended to follow the chapters sequentially.


2. Configuration and Preparation

1. Prerequisites

Before starting, ensure you have completed the following preparations (see basic tutorial for details):

PreparationRequirementReference Tutorial
ESP-IDF Environment6.0.1 ≥ version ≥ 5.5.2[1. Environment Setup]
Target ChipESP32-S3 (used in this tutorial)—
Speaker + MICOnboard ES8311 audio codec—
USB Data CableType-C, supports data transfer—

Why can't ESP-IDF 6.0.x be used? ESP-IDF 6.0.x introduced many breaking API changes (such as esp_netif interface refactoring, Wi-Fi driver API deprecation), while Xiaozhi firmware (v2.2.6) is written based on ESP-IDF 5.x, with many dependencies on old APIs and build systems (Kconfig/CMake macros). Compiling on 6.0.x will directly report errors, requiring source code modifications to adapt throughout—extremely workload-intensive and prone to introducing bugs. Therefore, official support is only for 5.x series ≥ 5.5.2.

Recommended: Use VSCode + ESP-IDF Extension

2. Clone Source Repository

Open terminal, enter your project directory, and execute clone:

​x
# Clone AI Xiaozhi main repository
git clone https://github.com/78/xiaozhi-esp32.git -b v2.2.6
cd xiaozhi-esp32

# Check current version
git describe --tags

After cloning, the project root directory structure is as follows:

xxxxxxxxxx
xiaozhi-esp32-main/
├── CMakeLists.txt          ← Project entry (project name "xiaozhi", version 2.2.6)
├── main/
│   ├── main.cc             ← app_main() entry
│   ├── application.cc/h    ← Application main control logic
│   ├── audio/              ← Audio codec, wake word, audio pipeline
│   │   ├── codecs/         ← ES8311/ES8374/ES8388 and other codec drivers
│   │   ├── processors/     ← Audio processors (AFC, AEC, VAD, etc.)
│   │   └── wake_words/     ← Wake word models
│   ├── boards/             ← 70+ board configurations
│   ├── protocols/          ← WebSocket / MQTT protocol implementation
│   ├── display/            ← OLED/LCD display drivers
│   ├── led/                ← LED light effect control
│   ├── assets/             ← Multi-language resources (fonts, expressions, voice prompts)
│   ├── mcp_server.cc/h     ← Device-side MCP service
│   ├── ota.cc/h            ← OTA online upgrade
│   └── settings.cc/h       ← NVS persistent configuration
├── config/                 ← Kconfig menu configuration
├── partitions/             ← Partition table definition
├── scripts/                ← Auxiliary scripts
└── docs/                   ← Development documentation

3. Install Third-Party Component Dependencies

AI Xiaozhi depends on many third-party libraries in the ESP-IDF component registry. The dependency declaration file is located at main/idf_component.yml.

Core Dependency List:

ComponentVersionPurpose
espressif/esp_codec_dev~1.5.6ES8311 and other audio codec drivers
espressif/esp_audio_codec~2.4.1Audio codec framework
espressif/esp_audio_effects~1.2.1Audio effects processing
espressif/esp-sr~2.3.0Speech recognition (wake word)
78/esp-wifi-connect~3.1.3Wi-Fi smart provisioning
78/xiaozhi-fonts~1.6.0Xiaozhi dedicated font package
78/esp-ml307~3.6.5ML307 4G module driver
lvgl/lvgl~9.5.0LVGL graphics library (display)
esp_lvgl_port~2.7.2LVGL ESP porting layer
espressif/led_strip~3.0.2WS2812 and other LED drivers
espressif/button~4.1.5Button driver
espressif/esp32-camera^2.1.6Camera support (some board models)

Tip: The component manager automatically downloads third-party dependencies from remote repositories to the managed_components/ directory when executing idf.py build. First build requires internet; subsequent builds use cache.

xxxxxxxxxx
# main/idf_component.yml (key excerpt)
dependencies:
  espressif/esp-sr: ~2.3.0
  78/esp-wifi-connect: ~3.1.3
  espressif/esp_audio_codec: ~2.4.1
  espressif/esp_codec_dev: ~1.5.6
  78/xiaozhi-fonts: ~1.6.0
  # ... more dependencies in source file
  idf:
    version: '>=5.5.2'

4. Configuration and Compilation

Step 1: Set Target Chip

xxxxxxxxxx
idf.py set-target esp32s3

After execution, IDF automatically generates sdkconfig default configuration.

Step 2: menuconfig Configuration

menuconfig is a GUI configuration tool provided by ESP-IDF, allowing you to modify project settings, component options, and partition tables without directly editing code. The configuration items that need modification for this project and their menuconfig paths are as follows (automatically generated default items are not listed).

Operation tips: ↑↓ move cursor, Space check/switch options, Enter enter submenu/edit text, Q exit current layer (top layer Q prompts save, Y save and exit / N discard), S save but don't exit, ? view help.

Open menuconfig

Execute in project root directory (refer to 3. Serial Communication and Storage System → 4. PSRAM External Memory Experiment):

xxxxxxxxxx
idf.py menuconfig

Wait for terminal to load configuration items (first open takes about 5-10 seconds to compile mconf tool).

① Board Model
xxxxxxxxxx
Top ▸ Xiaozhi
        └─ Board Type ────────────────────→ (X) esp-box-lite
#OperationDescription
1Enter Xiaozhi → select Board Type, press Space to select corresponding boarde.g., esp-box-lite
② Flash Size
xxxxxxxxxx
Top ▸ Serial flasher config
        └─ Flash size ──────────────────→ (X) 16 MB
#OperationDescription
1Serial flasher config → select Flash size, press Space to switch to 16 MBMatch onboard 16MB SPI Flash
③ Partition Table
xxxxxxxxxx
Top ▸ Partition Table
        └─ Partition Table ──────────────────→ (X) Custom partition table CSV
        └─ (partitions.csv) Custom partition CSV file ──→ partitions/v2/partition-table.csv
#OperationDescription
1Enter Partition Table → select Partition Table, press Space to switch to (X) Custom partition table CSVEnable custom partition table
2Enter Custom partition CSV file, press Enter to edit, change to partitions/v2/partition-table.csvPoint to Xiaozhi partition CSV file
④ PSRAM
xxxxxxxxxx
Top ▸ Component config
        └─ ESP PSRAM
              └─ [*] Support for external, SPI-connected RAM
#OperationDescription
1Component config → ESP PSRAM → check [*] Support for external, SPI-connected RAMEnable 8MB PSRAM; AI voice processing requires large memory

PSRAM is a mandatory option for AI Xiaozhi—audio codec buffer, LVGL display buffer, and wake word model loading all depend on PSRAM. Not enabling will cause compilation failure or runtime out-of-memory.

Save and Exit

Press Q → Y in sequence to save and exit; menuconfig automatically updates the sdkconfig file.

Configuration Quick Reference (can also be preset via sdkconfig.defaults to avoid repeated configuration):

Configuration ItemValueMenu LocationDescription
XIAOZHI_BOARD_TYPEesp-box-liteXiaozhiBoard model
ESPTOOLPY_FLASHSIZE_16MBySerial flasher configFlash size 16MB
PARTITION_TABLE_CUSTOMyPartition TableEnable custom partition table
PARTITION_TABLE_CUSTOM_FILENAME"partitions/v2/partition-table.csv"Partition TablePartition CSV file path
SPIRAMyESP PSRAMEnable external PSRAM
xxxxxxxxxx
# sdkconfig.defaults — AI Xiaozhi Required Configuration
# Flash size
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y

# Custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions/v2/partition-table.csv"

# PSRAM / External RAM
CONFIG_SPIRAM=y

The above sdkconfig.defaults only lists required items. Wi-Fi and server configuration can be done in Chapters 2 and 3 via menuconfig or dynamic provisioning.

Step 3: First Compilation

xxxxxxxxxx
idf.py build

During first compilation, the ESP-IDF component manager automatically downloads all third-party dependencies declared in idf_component.yml. This process takes a few minutes; please be patient.

Compilation Success Indicator:

xxxxxxxxxx
Project build complete.

If compilation reports errors, common issues:

Error MessageCauseSolution
fatal error: xxx.h: No such fileComponent not downloadedExecute idf.py clean then idf.py build again
CMake Error: Version mismatchESP-IDF version too lowUpgrade to ≥ 5.5.2
No partition table foundPartition table path errorConfirm partition table path in menuconfig
Target mismatchChip target errorExecute idf.py set-target esp32s3

5. Compilation and Flashing

ESP-IDF Flashing Process: See ESP-IDF Development Tutorial → 1. Before Development → 3. Build and Flash.

6. Comparison of Two Flashing Methods

There are two ways to get Xiaozhi firmware, choose based on your situation:

 Method 1: Self-Compile and FlashMethod 2: Use Pre-compiled Firmware Direct Flash
PrerequisitesESP-IDF environment ≥ 5.5.2, GitOnly serial driver and flashing tool required
StepsClone source → menuconfig → idf.py build → idf.py flashDownload .bin file → flashing tool one-click flash
TimeFirst 30~60 minutes (including component download + compilation)3~5 minutes
Target UsersDevelopers with ESP-IDF development environment, need custom configurationBeginners, no development environment, want quick experience
CustomizationCan modify wake word, board model, server, and all configurationsUses preset default configuration (use Method 1 for customization)

Suggestion: Beginners or quick experience → use Method 2 direct flash. For modifying configuration or secondary development later → return to Method 1 self-compilation.

Method 1: Self-Compile and Flash (Sections 2~5 above)

Follow the complete flow of 2. Clone Source Repository → 3. Install Dependencies → 4. Configuration and Compilation → 5. Compilation and Flashing. The advantage is complete control, with every menuconfig option customizable.

Method 2: Use Pre-compiled Firmware Direct Flash

This tutorial provides pre-compiled firmware package; download, extract, and flash directly without setting up ESP-IDF environment. ESP-IDF Flashing Process: See ESP-IDF Development Tutorial → 1. Before Development → 3. Build and Flash. Flash addresses for each file are as follows:

Pre-compiled firmware uses default configuration: board esp-box-lite, server xiaozhi.me, protocol WebSocket. For custom configuration (wake word, board model, etc.), use Method 1 self-compilation.

7. Verification: First Boot Logs

After successful flashing, reset the development board; serial output should be similar to:

xxxxxxxxxx
I (77) esp_psram: Found 8MB PSRAM device
I (80) esp_psram: Speed: 80MHz
I (102) app_init: Project name:     xiaozhi
I (106) app_init: App version:      2.2.6
I (119) app_init: ESP-IDF:          v5.5.4
I (162) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
I (212) main_task: Calling app_main()
I (220) Board: UUID=80fb638b... SKU=esp-box-lite
I (324) OledDisplay: Initialize LVGL
I (327) StateMachine: State: unknown -> starting
I (346) Es8311AudioCodec: Duplex channels created
I (355) Es8311AudioCodec: Es8311AudioCodec initialized
I (355) AudioCodec: Audio codec started
I (357) MCP: Add tool: self.get_device_status
I (357) MCP: Add tool: self.audio_speaker.set_volume
I (362) MCP: Add tool: self.screen.set_theme
  ... (Total 8 MCP tools registered)
I (398) WifiManager: Initializing...
I (537) wifi:mode : sta (a4:cb:8f:c6:b8:34)
I (1477) WifiBoard: EnterWifiConfigMode called
I (1499) StateMachine: State: starting -> wifi_configuring
I (1537) WifiConfigurationAp: Access Point started with SSID Xiaozhi-B835
I (1553) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.4.1
W (1554) Application: Alert [gear] Config mode: phone connects to hotspot Xiaozhi-B835, browser visits http://192.168.4.1
I (1579) AudioCodec: Set output enable to true
I (1580) I2S_IF: STD: TX, sample_rate_hz: 16000
I (1599) I2S_IF: STD: RX, sample_rate_hz: 16000

Key Log Nodes:

Log LineStageDescription
Found 8MB PSRAM devicePSRAM mountDetected 8MB Octal PSRAM and added to heap allocator
App version: 2.2.6Version confirmationProject name xiaozhi, based on ESP-IDF v5.5.4
Board: SKU=esp-box-liteBoard identificationUUID + SKU confirms board model
OledDisplay: Initialize LVGLDisplay systemLVGL task started, OLED screen ready
StateMachine: unknown → startingState machineDevice entering startup state
Es8311AudioCodec initializedAudio codecES8311 duplex channel created, Slave mode
MCP: Add tool: ...MCP tool registrationRegistered 8 MCP tools (system status, volume, theme, etc.)
WifiBoard: EnterWifiConfigModeEnter provisioningNo saved Wi-Fi credentials, automatically create AP hotspot
State: starting → wifi_configuringState transitionDevice entering Wi-Fi config state
SSID Xiaozhi-B835, IP: 192.168.4.1Provisioning hotspot readyPhone connects to this hotspot, browser visits 192.168.4.1 to complete Wi-Fi config
I2S_IF: TX/RX, sample_rate_hz: 16000Audio channel readyI2S full-duplex 16kHz ready, recording + playback channels opened

First boot automatically enters provisioning mode due to no Wi-Fi credentials; device creates hotspot named Xiaozhi-XXXX. After phone connects, browser visits 192.168.4.1 to complete Wi-Fi configuration. See 2. Network and Configuration.

Repeater Experiment
Network and Configuration

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文