120 lines
3.2 KiB
Markdown
120 lines
3.2 KiB
Markdown
|
|
# 烧录与编译说明(Windows,ESP32-C6)
|
|||
|
|
|
|||
|
|
本说明适用于交付目录中的工程与固件:
|
|||
|
|
- 源码:`Deliverable/01_Source/matter-light-c6-wifi`
|
|||
|
|
- 预编译固件:`Deliverable/02_Firmware_Binaries/cct/*`
|
|||
|
|
|
|||
|
|
> 备注:本项目基于 ESP-IDF v5.2+;你当前环境若已安装 Espressif IDF(例如 v5.5.1)也可直接使用。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 1. 环境准备
|
|||
|
|
|
|||
|
|
### 1.1 安装/启用 ESP-IDF(PowerShell)
|
|||
|
|
|
|||
|
|
以你机器上的默认安装路径为例(如不同请替换):
|
|||
|
|
|
|||
|
|
```powershell
|
|||
|
|
# 进入你的 ESP-IDF 目录后执行(不要在命令里写 cd 的话,也可以直接在该目录打开 PowerShell)
|
|||
|
|
# 示例:C:\Espressif\frameworks\esp-idf-v5.5.1
|
|||
|
|
. "C:\Espressif\frameworks\esp-idf-v5.5.1\export.ps1"
|
|||
|
|
|
|||
|
|
idf.py --version
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 1.2 串口与硬件
|
|||
|
|
|
|||
|
|
- 连接 ESP32-C6 开发板(建议 16MB Flash 版本)。
|
|||
|
|
- 在设备管理器确认串口号(如 `COM4`)。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 2. 从源码编译并烧录(推荐,最稳)
|
|||
|
|
|
|||
|
|
在工程目录执行:
|
|||
|
|
|
|||
|
|
```powershell
|
|||
|
|
cd D:\ESP-LED\Deliverable\01_Source\matter-light-c6-wifi
|
|||
|
|
|
|||
|
|
# 清理并编译
|
|||
|
|
idf.py fullclean
|
|||
|
|
idf.py build
|
|||
|
|
|
|||
|
|
# 烧录并监视(将 COM4 替换成你的串口)
|
|||
|
|
idf.py -p COM4 flash monitor
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
停止串口监视:按 `Ctrl+]`。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 3. 直接烧录预编译 Factory 固件(无需重新编译)
|
|||
|
|
|
|||
|
|
预编译 Factory 固件路径:
|
|||
|
|
|
|||
|
|
- `Deliverable/02_Firmware_Binaries/cct/factory/bootloader.bin`
|
|||
|
|
- `Deliverable/02_Firmware_Binaries/cct/factory/partition-table.bin`
|
|||
|
|
- `Deliverable/02_Firmware_Binaries/cct/factory/ota_data_initial.bin`
|
|||
|
|
- `Deliverable/02_Firmware_Binaries/cct/factory/light.bin`
|
|||
|
|
|
|||
|
|
烧录地址(来自工程构建输出 `flasher_args.json/flash_args`):
|
|||
|
|
|
|||
|
|
- `0x0000` bootloader
|
|||
|
|
- `0x8000` partition-table
|
|||
|
|
- `0x1C000` ota_data_initial
|
|||
|
|
- `0x20000` app (`light.bin`)
|
|||
|
|
|
|||
|
|
### 3.1 使用 `esptool.py` 一次性写入
|
|||
|
|
|
|||
|
|
确保已执行过 `export.ps1`,然后运行:
|
|||
|
|
|
|||
|
|
```powershell
|
|||
|
|
$PORT="COM4" # 替换为你的串口
|
|||
|
|
$BAUD="921600" # 可改成 460800/115200 以提升稳定性
|
|||
|
|
|
|||
|
|
$BASE="D:\ESP-LED\Deliverable\02_Firmware_Binaries\cct\factory"
|
|||
|
|
|
|||
|
|
python -m esptool --chip esp32c6 -p $PORT -b $BAUD `
|
|||
|
|
--before default_reset --after hard_reset `
|
|||
|
|
write_flash --flash_mode dio --flash_freq 80m --flash_size 16MB `
|
|||
|
|
0x0 "$BASE\bootloader.bin" `
|
|||
|
|
0x8000 "$BASE\partition-table.bin" `
|
|||
|
|
0x1c000 "$BASE\ota_data_initial.bin" `
|
|||
|
|
0x20000 "$BASE\light.bin"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
> 如果你的板子实际是 4MB Flash,可把 `--flash_size 16MB` 改为 `4MB`。
|
|||
|
|
|
|||
|
|
### 3.2 监视串口日志
|
|||
|
|
|
|||
|
|
```powershell
|
|||
|
|
idf.py -p COM4 monitor
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 4. OTA 固件文件说明(给服务器/升级用)
|
|||
|
|
|
|||
|
|
OTA 文件路径:
|
|||
|
|
- `Deliverable/02_Firmware_Binaries/cct/ota/light.bin`
|
|||
|
|
|
|||
|
|
说明:
|
|||
|
|
- `light.bin` 用于 OTA 升级包(用于远程 HTTP OTA 场景的下载与升级)。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 5. 常见问题
|
|||
|
|
|
|||
|
|
### 5.1 找不到 `python` / `idf.py`
|
|||
|
|
|
|||
|
|
确保已执行 `export.ps1`,且使用的是同一个 PowerShell 窗口。
|
|||
|
|
|
|||
|
|
### 5.2 串口被占用
|
|||
|
|
|
|||
|
|
关闭其它串口工具(如 Arduino 串口监视器、串口调试助手)。
|
|||
|
|
|
|||
|
|
### 5.3 Flash size 警告
|
|||
|
|
|
|||
|
|
如果日志提示“Detected size larger than size in binary image header”,请确认:
|
|||
|
|
- 工程配置选择了正确的 Flash size(建议 16MB),并重新 `idf.py fullclean build`。
|