mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
- Curated guides under docs/; trim China-only integration docs and screenshots - Root and main README set aligned with westernized product positioning - LICENSE text update where applicable
10 KiB
10 KiB
🔌 Device Flashing Guide
This guide covers how to flash firmware to your ESP32 device using various methods.
🎯 Flashing Methods Overview
Choose the method that works best for your setup:
- Web-based Flashing (Recommended) - No software installation required
- Command Line Flashing - For developers and advanced users
- IDE Flashing - Using Arduino IDE or PlatformIO
- OTA Flashing - Over-the-air updates for existing devices
🌐 Web-based Flashing (Recommended)
Step 1: Prepare Your Device
- Connect ESP32 to your computer via USB
- Install USB drivers if needed (usually automatic on Windows/Mac)
- Identify COM port (Windows) or device path (Mac/Linux)
Windows:
- Open Device Manager → Ports (COM & LPT)
- Look for "Silicon Labs CP210x" or similar
Mac/Linux:
# List USB devices
ls /dev/tty.*
# Look for /dev/tty.usbserial-* or /dev/ttyUSB*
Step 2: Access ESP-Launchpad
- Open Chrome browser (recommended for best compatibility)
- Navigate to: https://espressif.github.io/esp-launchpad/
- Allow camera/microphone permissions if prompted
Step 3: Upload Firmware
- Click "Choose File" or drag and drop your firmware file
- Select your firmware:
merged-binary.bin(from firmware compilation) - Click "Connect" and select your ESP32 device
- Wait for connection to be established
Step 4: Flash Firmware
- Click "Flash" to start the flashing process
- Wait for completion (usually 30-60 seconds)
- Device will restart automatically after flashing
- Check console output for any errors
Step 5: Verify Installation
- Check device status - LED indicators should show normal operation
- Test wake word - Say "Hey Xiaozhi" or configured wake word
- Check server logs - Look for device connection in server logs
💻 Command Line Flashing
Prerequisites
- ESP-IDF development environment installed
- esptool.py available in your PATH
- Firmware file ready for flashing
Step 1: Install esptool
# Install esptool if not already installed
pip install esptool
# Verify installation
esptool.py version
Step 2: Identify Device
# List available serial ports
esptool.py --port auto chip_id
# Or specify port directly
esptool.py --port COM3 chip_id # Windows
esptool.py --port /dev/ttyUSB0 chip_id # Linux
esptool.py --port /dev/tty.usbserial-* chip_id # Mac
Step 3: Flash Firmware
# Basic flashing command
esptool.py --chip esp32s3 --port COM3 --baud 921600 write_flash 0x0 merged-binary.bin
# With verification
esptool.py --chip esp32s3 --port COM3 --baud 921600 --verify write_flash 0x0 merged-binary.bin
# With progress indicator
esptool.py --chip esp32s3 --port COM3 --baud 921600 --verify --progress write_flash 0x0 merged-binary.bin
Step 4: Advanced Flashing Options
# Flash with specific memory layout
esptool.py --chip esp32s3 --port COM3 --baud 921600 \
--flash_mode dio \
--flash_freq 80m \
--flash_size 16MB \
write_flash 0x0 merged-binary.bin
# Flash multiple files
esptool.py --chip esp32s3 --port COM3 --baud 921600 \
write_flash 0x0 bootloader.bin \
0x8000 partition-table.bin \
0x10000 merged-binary.bin
🔧 IDE Flashing
Arduino IDE Method
Step 1: Install ESP32 Board Package
- Open Arduino IDE
- Go to: File → Preferences
- Add board manager URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Go to: Tools → Board → Boards Manager
- Search for "ESP32" and install "ESP32 by Espressif Systems"
Step 2: Configure Board
- Select board: Tools → Board → ESP32 Arduino → ESP32S3 Dev Module
- Select port: Tools → Port → [Your COM port]
- Configure settings:
- Upload Speed: 921600
- Flash Mode: DIO
- Flash Frequency: 80MHz
- Flash Size: 16MB
Step 3: Flash Firmware
- Open firmware file (if available as .ino)
- Click Upload button
- Wait for completion
PlatformIO Method
Step 1: Install PlatformIO
# Install PlatformIO
pip install platformio
# Or use PlatformIO IDE
# Download from: https://platformio.org/install/ide
Step 2: Create Project
# Create new project
pio project init --board esp32s3-devkitc-1
# Or use existing project
cd your-project-directory
Step 3: Configure platformio.ini
[env:esp32s3]
platform = espressif32
board = esp32s3-devkitc-1
framework = arduino
monitor_speed = 115200
upload_speed = 921600
Step 4: Flash Firmware
# Upload firmware
pio run --target upload
# Monitor serial output
pio device monitor
📡 OTA (Over-the-Air) Flashing
Prerequisites
- Device already running Xiaozhi firmware
- Network connectivity to your server
- OTA interface accessible
- New firmware file ready
Step 1: Prepare OTA Update
- Access OTA interface:
http://YOUR_IP:8003/xiaozhi/ota/ - Verify interface shows "OTA interface is running normally"
- Prepare firmware file for upload
Step 2: Upload Firmware
- Click "Choose File" in OTA interface
- Select new firmware file
- Click "Upload" to start OTA update
- Wait for upload to complete
Step 3: Trigger Update
- Wake up device using wake word
- Say "Update firmware" or similar command
- Device will download and install new firmware
- Device will restart automatically
Step 4: Verify Update
- Check device status after restart
- Test functionality with voice commands
- Check server logs for successful connection
🛠️ Troubleshooting Flashing Issues
Common Issues and Solutions
"Port not found" Error
# Check available ports
esptool.py --port auto chip_id
# Install USB drivers
# Windows: Download from Silicon Labs website
# Mac: Usually automatic
# Linux: Add user to dialout group
sudo usermod -a -G dialout $USER
"Failed to connect" Error
- Hold BOOT button while pressing RESET
- Release RESET while holding BOOT
- Release BOOT after 2 seconds
- Try flashing again
"Flash write error" Error
# Try slower baud rate
esptool.py --chip esp32s3 --port COM3 --baud 115200 write_flash 0x0 merged-binary.bin
# Try different flash mode
esptool.py --chip esp32s3 --port COM3 --baud 921600 --flash_mode qio write_flash 0x0 merged-binary.bin
"Verification failed" Error
# Flash without verification first
esptool.py --chip esp32s3 --port COM3 --baud 921600 write_flash 0x0 merged-binary.bin
# Then verify separately
esptool.py --chip esp32s3 --port COM3 --baud 921600 verify_flash 0x0 merged-binary.bin
"Device not responding" Error
- Check USB cable - use data cable, not charging cable
- Try different USB port - prefer USB 2.0 ports
- Check power supply - ensure stable 5V supply
- Reset device - press RESET button
Advanced Troubleshooting
Erase Flash Before Flashing
# Erase entire flash
esptool.py --chip esp32s3 --port COM3 erase_flash
# Erase specific sectors
esptool.py --chip esp32s3 --port COM3 erase_region 0x0 0x400000
Read Flash for Verification
# Read flash content
esptool.py --chip esp32s3 --port COM3 read_flash 0x0 0x400000 flash_content.bin
# Compare with original
diff merged-binary.bin flash_content.bin
Reset to Factory Settings
# Erase flash and reset
esptool.py --chip esp32s3 --port COM3 erase_flash
esptool.py --chip esp32s3 --port COM3 run
🔍 Flashing Verification
Step 1: Check Flash Content
# Read flash and verify
esptool.py --chip esp32s3 --port COM3 verify_flash 0x0 merged-binary.bin
Step 2: Monitor Boot Process
# Monitor serial output during boot
esptool.py --chip esp32s3 --port COM3 monitor
Step 3: Test Device Functionality
- Power on device
- Check LED indicators
- Test wake word detection
- Verify server connection
📊 Flashing Performance Tips
Optimize Flashing Speed
# Use maximum baud rate
esptool.py --chip esp32s3 --port COM3 --baud 921600 write_flash 0x0 merged-binary.bin
# Use optimal flash mode
esptool.py --chip esp32s3 --port COM3 --baud 921600 --flash_mode dio write_flash 0x0 merged-binary.bin
Batch Flashing Multiple Devices
#!/bin/bash
# Flash multiple devices script
DEVICES=("/dev/ttyUSB0" "/dev/ttyUSB1" "/dev/ttyUSB2")
FIRMWARE="merged-binary.bin"
for device in "${DEVICES[@]}"; do
echo "Flashing $device..."
esptool.py --chip esp32s3 --port "$device" --baud 921600 write_flash 0x0 "$FIRMWARE"
if [ $? -eq 0 ]; then
echo "Successfully flashed $device"
else
echo "Failed to flash $device"
fi
done
🎯 Next Steps
After successful flashing:
- Configure Your Device - Complete device setup
- Test Voice Interaction - Verify functionality
- Configure AI Providers - Set up AI services
- Hardware Troubleshooting - Common hardware issues
🆘 Need Help?
- Flashing Issues? Check Troubleshooting
- Hardware Questions? See Supported Devices
- General Questions? Browse FAQ
🎯 Quick Reference
Flashing Commands
# Web-based (recommended)
https://espressif.github.io/esp-launchpad/
# Command line
esptool.py --chip esp32s3 --port COM3 --baud 921600 write_flash 0x0 merged-binary.bin
# OTA update
http://YOUR_IP:8003/xiaozhi/ota/
Common Ports
- Windows: COM3, COM4, COM5...
- Mac: /dev/tty.usbserial-*
- Linux: /dev/ttyUSB0, /dev/ttyUSB1...
Troubleshooting Steps
- Check USB connection
- Install drivers
- Try different baud rate
- Hold BOOT button during reset
- Use web-based flashing
Your device is ready to flash! 🎉