ESP-IDF Development Environment Setup and XiaoZhi Compilation
ESP-IDF Development Environment Setup and XiaoZhi Compilation
This article will guide you on how to set up the ESP-IDF 5.3.2 development environment on Windows systems and compile the XiaoZhi firmware.
Installing ESP-IDF
1. Download the Offline Installation Package
You can download the ESP-IDF installation package from the following addresses:
Note: Both versions 5.3.1 and 5.3.2 can be used, with minor functional differences.
2. Installation Steps
- Double-click the downloaded EXE file to start installation
- Accept the license agreement
- Select the installation path (recommended not to install on C drive)
- Follow the wizard to complete the installation
3. Verify Installation
- Double-click the “ESP-IDF 5.3 PowerShell” shortcut on the desktop
- The terminal will automatically import the IDF environment
- Execute the test command:
cd examples/get-started/hello_world/
idf.py build
Compiling XiaoZhi Firmware
1. Get the Source Code
# Clone via Git (recommended)
git clone https://github.com/78/xiaozhi-esp32
# Or download the ZIP archive from GitHub
2. Configure the Development Board
- Set the target chip:
# ESP32-S3
idf.py set-target esp32s3
# ESP32-C3
idf.py set-target esp32c3
- Configure the development board type:
idf.py menuconfig
# Enter Xiaozhi Assistant -> Board Selection
3. Compile and Flash
Basic commands:
# Compile only
idf.py build
# Compile and flash
idf.py build flash monitor
# Use faster flashing speed
idf.py -b 2000000 build flash monitor
# Specify serial port
idf.py -p COM5 build flash monitor
4. Common Configuration Changes
Modify Wake Word
idf.py menuconfig
# Enter ESP Speech Recognition -> Wake Word
Modify WebSocket API
idf.py menuconfig
# Enter Xiaozhi Assistant -> Websocket -> Websocket URL
Common Issues
1. Improving Compilation Speed
- Turn off antivirus software (including Windows Defender)
- Delete the build folder and recompile
2. Serial Port Driver Issues
If the serial port cannot be recognized, you need to install the USB driver for the corresponding chip.
3. I2C Conflict Resolution
If you encounter I2C conflict issues:
- Enter
idf.py menuconfig
- Select
Component config -> Audio Codec Device Configuration
- Turn off the first option
- Recompile
Notes
- Project path should not contain Chinese characters
- Remember to delete the build folder when transferring the project
- Ensure you use the correct chip model configuration
- It is recommended to regularly clean the build directory to resolve compilation issues