Rdzleo fc07d3806d Phase 01 调试迭代: OV3660 人脸检测集成 + 23 条踩坑经验汇总
## 代码变更

### main/application.cc
修复 T01 probe 日志 %lld 格式 bug(改用 %lu + unsigned long)

### main/boards/common/esp32_camera.cc
- 修复 DVP V4L2 单 buffer 导致 DMA 饥饿:req.count 从 1 改为 2
- 修复 [T01] Probe 日志 elapsed=ldus 显示问题(同上格式修复)

### main/face_tracker.cc
多轮迭代:
- 新增 frame debug 诊断日志(打印 top-left/center 16B + zero_bytes 统计)
- pix_type 尝试路径:YUYV → RGB565LE → RGB565BE → YUYV → RGB888(手动转换)
- 手动实现 BT.601 公式 YUYV→RGB888 转换,绕过 ImagePreprocessor 黑盒
- face_tracker 任务从 Core 0 切换到 Core 1,避让 RMT/LED 死锁
- 新增 INFO 级限频日志(每秒 1 条 face 检测记录)
- 修复推理时长日志 %lld 格式 bug
- 连续 3 秒无人脸时打印 no face detected

### main/idf_component.yml
esp_video 升级 1.3.1 → ~1.4.1(手动 patch 修 xclk_freq bug)

### partitions/v2/16m.csv
OTA 分区扩容:3.94MB → 5MB,assets 缩到 5.875MB,支持 4.23MB 固件

### docs/phase-01-face-tracking/PROGRESS.md
更新 Phase 01 执行日志,记录实机调试细节

## 文档更新

### Coglet项目分析与开发指南.md 新增第六点五节

完整记录本轮调试的 23 个踩坑,分为:
1. 编译/配置类(5 个):板级重置、依赖冲突、bootloader 缓存、%lld 格式、xclk_freq bug
2. 摄像头数据链路(5 个):sensor driver 启用、V4L2 buffer 数量、分区扩容、镜头保护膜、光照
3. esp-dl 人脸检测(3 个):MSR letterbox 伪影、ESPDET OOD 默认输出、字节序判断
4. 任务调度(3 个):WDT 崩溃、GDMA ISR 崩溃、弱符号链接
5. RP2040 端(4 个):idle 回中、坐标累加撞限位、mpremote 阻塞、两分支代码差异
6. 硬件(3 个):飞线验证、360° 舵机误用、烧录生效验证

附调试方法论 6 条 + 未解决遗留问题 3 条

## 已解决问题

-  ESP-IDF 编译链路(依赖/分区/格式)
-  ESP32 + RP2040 端到端协议(face:x,y UART)
-  WDT 崩溃(face_tracker 切到 Core 1)
-  RP2040 眼球回中机制(idle 时回正)
-  V4L2 双 buffer(DMA 数据更新正常)

## 遗留问题(待解决)

-  face 检测 box 固定伪激活(无论 pix_type / 画面内容 / 模型选择)
-  GDMA ISR 每 ~30s 触发 InstrFetchProhibited 崩溃
- ⚠️ 端到端验收:眼球未真正跟随人脸

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 18:22:15 +08:00
..

Version 2 Partition Table

This version introduces significant improvements over v1 by adding an assets partition to support network-loadable content and optimizing partition layouts for different flash sizes.

Key Changes from v1

Major Improvements

  1. Added Assets Partition: New assets partition for network-loadable content
  2. Replaced Model Partition: The old model partition (960KB) is replaced with a larger assets partition
  3. Optimized App Partitions: Reduced application partition sizes to accommodate assets
  4. Enhanced Flexibility: Support for dynamic content updates without reflashing

Assets Partition Features

The assets partition stores:

  • Wake word models: Customizable wake word models that can be loaded from the network
  • Theme files: Complete theming system including:
    • Fonts (text and icon fonts)
    • Audio effects and sound files
    • Background images and UI elements
    • Custom emoji packs
    • Language configuration files
  • Dynamic Content: All content can be updated over-the-air via HTTP downloads

Partition Layout Comparison

v1 Layout (16MB)

  • nvs: 16KB (non-volatile storage)
  • otadata: 8KB (OTA data)
  • phy_init: 4KB (PHY initialization data)
  • model: 960KB (model storage - fixed content)
  • ota_0: 6MB (application partition 0)
  • ota_1: 6MB (application partition 1)

v2 Layout (16MB)

  • nvs: 16KB (non-volatile storage)
  • otadata: 8KB (OTA data)
  • phy_init: 4KB (PHY initialization data)
  • ota_0: 4MB (application partition 0)
  • ota_1: 4MB (application partition 1)
  • assets: 8MB (network-loadable assets)

Available Configurations

8MB Flash Devices (8m.csv)

  • nvs: 16KB
  • otadata: 8KB
  • phy_init: 4KB
  • ota_0: 3MB
  • ota_1: 3MB
  • assets: 2MB

16MB Flash Devices (16m.csv) - Standard

  • nvs: 16KB
  • otadata: 8KB
  • phy_init: 4KB
  • ota_0: 4MB
  • ota_1: 4MB
  • assets: 8MB

16MB Flash Devices (16m_c3.csv) - ESP32-C3 Optimized

  • nvs: 16KB
  • otadata: 8KB
  • phy_init: 4KB
  • ota_0: 4MB
  • ota_1: 4MB
  • assets: 4MB (4000K - limited by available mmap pages)

32MB Flash Devices (32m.csv)

  • nvsfactory: 200KB
  • nvs: 840KB
  • otadata: 8KB
  • phy_init: 4KB
  • ota_0: 4MB
  • ota_1: 4MB
  • assets: 16MB

Benefits

  1. Dynamic Content Management: Users can download and update wake word models, themes, and other assets without reflashing the device
  2. Reduced App Size: Application partitions are optimized, allowing more space for dynamic content
  3. Enhanced Customization: Support for custom themes, wake words, and language packs enhances user experience
  4. Network Flexibility: Assets can be updated independently of the main application firmware
  5. Better Resource Utilization: Efficient use of flash memory with configurable asset storage
  6. OTA Asset Updates: Assets can be updated over-the-air via HTTP downloads

Technical Details

  • Partition Type: Assets partition uses spiffs subtype for SPIFFS filesystem compatibility
  • Memory Mapping: Assets are memory-mapped for efficient access during runtime
  • Checksum Validation: Built-in integrity checking ensures asset data validity
  • Progressive Download: Assets can be downloaded progressively with progress tracking
  • Fallback Support: Graceful fallback to default assets if network updates fail

Migration from v1

When upgrading from v1 to v2:

  1. Backup Important Data: Ensure any important data in the old model partition is backed up
  2. Flash New Partition Table: Use the appropriate v2 partition table for your flash size
  3. Download Assets: The device will automatically download required assets on first boot
  4. Verify Functionality: Ensure all features work correctly with the new partition layout

Usage Notes

  • The assets partition size varies by configuration to optimize for different flash sizes
  • ESP32-C3 devices use a smaller assets partition (4MB) due to limited available mmap pages in the system
  • 32MB devices get the largest assets partition (16MB) for maximum content storage
  • All partition tables maintain proper alignment for optimal flash performance