From ae2a84013156f85fb9e291010bddd47b13cf4444 Mon Sep 17 00:00:00 2001 From: Cjiio <39644702+Cjiio@users.noreply.github.com> Date: Thu, 27 Aug 2026 12:42:51 +0800 Subject: [PATCH] docs(dev): add AI environment bootstrap (#20) * docs(dev): add AI environment bootstrap * docs(ui): document CJK font pitfall --- .github/CONTRIBUTING.md | 14 +- .github/CONTRIBUTING.zh_CN.md | 14 +- AGENTS.md | 1 + AGENTS.zh_CN.md | 1 + docs/INDEX.md | 1 + docs/INDEX.zh_CN.md | 1 + docs/development/CI-validation.md | 6 +- docs/development/CI-validation.zh_CN.md | 5 +- docs/development/README.md | 1 + docs/development/README.zh_CN.md | 1 + docs/development/build-and-test.md | 21 +- docs/development/build-and-test.zh_CN.md | 21 +- docs/development/coding-conventions.md | 1 + docs/development/coding-conventions.zh_CN.md | 1 + docs/development/environment-setup.md | 333 ++++++++++++++++++ docs/development/environment-setup.zh_CN.md | 287 +++++++++++++++ .../AI_HARDWARE_DEVELOPMENT_GUIDE.md | 17 +- .../AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md | 33 +- 18 files changed, 717 insertions(+), 42 deletions(-) create mode 100644 docs/development/environment-setup.md create mode 100644 docs/development/environment-setup.zh_CN.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9c7393e..9714f24 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -25,13 +25,19 @@ second development; the fork conventions are in ## Development and verification -Use ESP-IDF 5.5.x (known development environment 5.5.3): +Use ESP-IDF 5.5.3. For a clean-machine setup, follow the +[environment bootstrap](../docs/development/environment-setup.md). + +Prefer the repository firmware gate for builds and flash its verified merged +image at `0x0`. The direct IDF commands below are for incremental development. ```bash -get_idf553 # Enter the repository's ESP-IDF 5.5.3 environment +source /export.sh +idf.py --version # must report ESP-IDF v5.5.3 +./tools/validate.sh --firmware # preferred merged-image build idf.py set-target esp32c3 # Configure the target chip (fresh checkout / after target change) -idf.py build # Compile firmware and validate dependencies -idf.py flash monitor # Flash and open logs +idf.py build # Optional incremental application build +idf.py flash monitor # Optional incremental application flash idf.py fullclean # Clear stale build state (never for user source changes) ``` diff --git a/.github/CONTRIBUTING.zh_CN.md b/.github/CONTRIBUTING.zh_CN.md index da7491d..fe3317e 100644 --- a/.github/CONTRIBUTING.zh_CN.md +++ b/.github/CONTRIBUTING.zh_CN.md @@ -19,13 +19,19 @@ ## 开发与验证 -使用 ESP-IDF 5.5.x(已知开发环境 5.5.3): +使用 ESP-IDF 5.5.3。全新机器先按 +[环境引导](../docs/development/environment-setup.zh_CN.md)完成安装。 + +编译优先运行仓库固件门禁,烧录优先把验证过的合并镜像写入 `0x0`。以下直接 +IDF 命令只用于增量开发。 ```bash -get_idf553 # 进入仓库的 ESP-IDF 5.5.3 环境 +source /export.sh +idf.py --version # 必须输出 ESP-IDF v5.5.3 +./tools/validate.sh --firmware # 优先生成合并固件 idf.py set-target esp32c3 # 配置目标芯片(fresh checkout 后/换 target 后运行) -idf.py build # 编译固件,验证依赖 -idf.py flash monitor # 烧录并打开日志 +idf.py build # 可选:增量 app 编译 +idf.py flash monitor # 可选:增量 app 烧录 idf.py fullclean # 配置过期时清空生成状态(勿用于清理用户源码改动) ``` diff --git a/AGENTS.md b/AGENTS.md index 3297501..1144aff 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,6 +24,7 @@ This file is the only mandatory entry point for AI-assisted work in this reposit | Task | Read before editing | | --- | --- | | Any code change | `docs/development/agent-guide.md`, relevant headers and neighboring implementation | +| Environment bootstrap or missing toolchain | `docs/development/environment-setup.md` | | BSP, pins, buses, display, audio, battery | `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`, `components/bsp/include/bsp_pins.h` | | Demo or menu | `main/demo.h`, `main/main.c`, the nearest `main/demo_*.c` implementation | | Build, test, dependencies, partitions | `docs/development/build-and-test.md`, `sdkconfig.defaults`, `partitions.csv` | diff --git a/AGENTS.zh_CN.md b/AGENTS.zh_CN.md index 79393e8..7d5d21e 100644 --- a/AGENTS.zh_CN.md +++ b/AGENTS.zh_CN.md @@ -24,6 +24,7 @@ | 任务 | 修改前读取 | | --- | --- | | 任意代码修改 | `docs/development/agent-guide.zh_CN.md`、相关头文件和相邻实现 | +| 环境引导或缺少工具链 | `docs/development/environment-setup.zh_CN.md` | | BSP、引脚、总线、显示、音频、电池 | `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md`、`components/bsp/include/bsp_pins.h` | | Demo 或菜单 | `main/demo.h`、`main/main.c`、最近的 `main/demo_*.c` 实现 | | 构建、测试、依赖、分区 | `docs/development/build-and-test.zh_CN.md`、`sdkconfig.defaults`、`partitions.csv` | diff --git a/docs/INDEX.md b/docs/INDEX.md index 33db78b..63ac50d 100644 --- a/docs/INDEX.md +++ b/docs/INDEX.md @@ -16,6 +16,7 @@ Use this page to discover repository documentation. `authoritative` documents de | [contribution/commit-and-pr.md](contribution/commit-and-pr.md) | Commit and pull-request rules | authoritative | | [development/README.md](development/README.md) | Engineering-document index | authoritative | | [development/agent-guide.md](development/agent-guide.md) | AI-assisted development workflow | authoritative | +| [development/environment-setup.md](development/environment-setup.md) | Clean-machine environment bootstrap for AI agents | authoritative | | [development/build-and-test.md](development/build-and-test.md) | Build and validation commands | authoritative | | [development/coding-conventions.md](development/coding-conventions.md) | C and firmware conventions | authoritative | | [development/CI-validation.md](development/CI-validation.md) | Pull-request and main-branch validation | authoritative | diff --git a/docs/INDEX.zh_CN.md b/docs/INDEX.zh_CN.md index 080a496..aa46a30 100644 --- a/docs/INDEX.zh_CN.md +++ b/docs/INDEX.zh_CN.md @@ -16,6 +16,7 @@ | [contribution/doc-conventions.zh_CN.md](./contribution/doc-conventions.zh_CN.md) | 文档规范 | authoritative | 按任务加载上下文、文档职责、写作维护和内容安全 | | [contribution/commit-and-pr.zh_CN.md](./contribution/commit-and-pr.zh_CN.md) | 协作规范 | authoritative | 提交规范 + 提交与 PR 约定 | | [development/README.zh_CN.md](./development/README.zh_CN.md) | 工程规范索引 | authoritative | 通用工程开发规范(构建验证、代码约定) | +| [development/environment-setup.zh_CN.md](./development/environment-setup.zh_CN.md) | 工程规范 | authoritative | AI 全新机器环境引导、国际与中国大陆下载线路 | | [development/build-and-test.zh_CN.md](./development/build-and-test.zh_CN.md) | 工程规范 | authoritative | 构建与验证(ESP-IDF 命令、逻辑测试、改动验证要求) | | [development/coding-conventions.zh_CN.md](./development/coding-conventions.zh_CN.md) | 工程规范 | authoritative | 代码约定(语言风格、复用、注释、测试同步、资源约束) | | [development/agent-guide.zh_CN.md](./development/agent-guide.zh_CN.md) | 工程规范 | authoritative | AI 开发工作流(上下文建立、需求拆解、BSP 边界、验收交付格式) | diff --git a/docs/development/CI-validation.md b/docs/development/CI-validation.md index 3d177e3..6319121 100644 --- a/docs/development/CI-validation.md +++ b/docs/development/CI-validation.md @@ -17,8 +17,10 @@ The workflow has only `contents: read` and uses no repository secrets, so it can ```bash ./tools/validate.sh --static -get_idf553 +source /export.sh ./tools/validate.sh --firmware ``` -Reproduce a CI failure with the same mode locally. Do not maintain duplicate validation commands inside the workflow. +Follow the [environment bootstrap](environment-setup.md) if ESP-IDF 5.5.3 is +not installed. Reproduce a CI failure with the same mode locally. Do not +maintain duplicate validation commands inside the workflow. diff --git a/docs/development/CI-validation.zh_CN.md b/docs/development/CI-validation.zh_CN.md index 1f323f5..05f1681 100644 --- a/docs/development/CI-validation.zh_CN.md +++ b/docs/development/CI-validation.zh_CN.md @@ -17,8 +17,9 @@ ```bash ./tools/validate.sh --static -get_idf553 +source /export.sh ./tools/validate.sh --firmware ``` -CI 失败应先在本地运行相同模式。不要在 workflow 中复制另一套构建或校验命令。 +未安装 ESP-IDF 5.5.3 时先按[环境引导](environment-setup.zh_CN.md)搭建。CI +失败应先在本地运行相同模式。不要在 workflow 中复制另一套构建或校验命令。 diff --git a/docs/development/README.md b/docs/development/README.md index 95e990f..fc23503 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -9,6 +9,7 @@ This directory contains AI Passport engineering rules and reusable workflows. Ru ## Documents - [agent-guide.md](agent-guide.md): AI-assisted development workflow. +- [environment-setup.md](environment-setup.md): clean-machine bootstrap for AI agents, including international and mainland China download routes. - [build-and-test.md](build-and-test.md): ESP-IDF build and validation. - [coding-conventions.md](coding-conventions.md): source-code and resource conventions. - [CI-validation.md](CI-validation.md): pull-request and main-branch checks. diff --git a/docs/development/README.zh_CN.md b/docs/development/README.zh_CN.md index df17dde..81d3531 100644 --- a/docs/development/README.zh_CN.md +++ b/docs/development/README.zh_CN.md @@ -18,6 +18,7 @@ ## 文档索引 - [agent-guide.md](agent-guide.md):AI 开发工作流(面向 AI 编程助手:上下文建立、需求拆解、BSP 边界、验收交付格式)。 +- [environment-setup.zh_CN.md](environment-setup.zh_CN.md):AI 在全新机器上的环境引导,包含国际与中国大陆下载线路。 - [build-and-test.md](build-and-test.md):构建与验证(ESP-IDF 命令、逻辑测试、改动验证要求)。 - [coding-conventions.md](coding-conventions.md):代码约定(语言风格、复用、注释、测试同步、资源约束等)。 - [CI-build-and-release.md](CI-build-and-release.md):自动构建与发布说明(tag 触发自动编译固件并发布 Release)。 diff --git a/docs/development/build-and-test.md b/docs/development/build-and-test.md index ca4f07b..0428cfc 100644 --- a/docs/development/build-and-test.md +++ b/docs/development/build-and-test.md @@ -4,16 +4,29 @@ # Build and Test -Use ESP-IDF 5.5.x; the reproducible environment is ESP-IDF 5.5.3. +Use ESP-IDF 5.5.3. On a clean machine or when the toolchain is missing, follow +the [environment bootstrap](environment-setup.md) first. + +> Prefer `./tools/validate.sh --firmware` for firmware builds and flash its +> verified `build/FoloToy-AI-Passport-full.bin` at offset `0x0`. Treat +> `idf.py build` and `idf.py flash` as incremental development commands, not the +> default delivery path. ```bash -get_idf553 # activate the local ESP-IDF 5.5.3 environment +source /export.sh +idf.py --version # must report ESP-IDF v5.5.3 +./tools/validate.sh --firmware # preferred: build and verify merged 0x0 image idf.py set-target esp32c3 # fresh checkout or changed target -idf.py build # compile firmware and resolve dependencies -idf.py flash monitor # flash the connected board and open logs +idf.py build # optional incremental application build +idf.py flash monitor # optional incremental application flash idf.py fullclean # remove stale generated build state only ``` +`idf.py fullclean` does not fully synchronize an existing `sdkconfig` with +changed defaults. Preserve intentional local settings, then run +`idf.py set-target esp32c3` when the target or tracked defaults must be +regenerated. + The tracked `dependencies.lock` pins Managed Component resolution. After changing an `idf_component.yml`, regenerate the lock with ESP-IDF 5.5.3, review version changes, and commit it with the manifest. An ordinary build must not leave an unexplained lock-file diff. Firmware validation uses a fresh temporary build directory and an isolated `sdkconfig` generated from the tracked defaults. It does not consume or overwrite a developer's root `sdkconfig`, and it copies only the verified merged image to `build/FoloToy-AI-Passport-full.bin`. diff --git a/docs/development/build-and-test.zh_CN.md b/docs/development/build-and-test.zh_CN.md index 2b1bed2..73c81cd 100644 --- a/docs/development/build-and-test.zh_CN.md +++ b/docs/development/build-and-test.zh_CN.md @@ -4,16 +4,27 @@ # 构建与验证(Build & Test) -使用 ESP-IDF 5.5.x(已知开发环境 5.5.3): +使用 ESP-IDF 5.5.3。全新机器或缺少工具链时,先按 +[环境引导](environment-setup.zh_CN.md)完成安装。 + +> 固件编译优先运行 `./tools/validate.sh --firmware`,烧录优先把验证通过的 +> `build/FoloToy-AI-Passport-full.bin` 写入 `0x0`。`idf.py build` 和 +> `idf.py flash` 只作为增量开发命令,不作为默认交付方式。 ```bash -get_idf553 # 进入仓库的 ESP-IDF 5.5.3 环境 +source /export.sh +idf.py --version # 必须输出 ESP-IDF v5.5.3 +./tools/validate.sh --firmware # 优先:编译并验证 0x0 合并固件 idf.py set-target esp32c3 # 配置目标芯片(fresh checkout 后/换 target 后运行) -idf.py build # 编译固件,验证依赖 -idf.py flash monitor # 烧录并打开日志 -idf.py fullclean # 配置过期时清空生成状态(勿用于清理用户源码改动) +idf.py build # 可选:增量 app 编译 +idf.py flash monitor # 可选:增量 app 烧录 +idf.py fullclean # 只清空过期生成状态(勿用于清理用户源码改动) ``` +`idf.py fullclean` 不能让已有 `sdkconfig` 完整同步变更后的 defaults。需要重建 +target 或已跟踪 defaults 时,先保留有意的本地设置,再运行 +`idf.py set-target esp32c3`。 + 仓库提交 `dependencies.lock` 以固定 ESP-IDF Managed Components 的解析结果。修改 `idf_component.yml` 后必须使用 ESP-IDF 5.5.3 重新生成锁文件、review 版本变化并与 manifest 一起提交;普通构建不应产生未提交的锁文件差异。 固件门禁使用全新的临时构建目录,并从仓库 `sdkconfig.defaults` 生成隔离的 `sdkconfig`。它不会读取或覆盖开发者根目录的 `sdkconfig`,只把验证通过的合并镜像复制到 `build/FoloToy-AI-Passport-full.bin`。 diff --git a/docs/development/coding-conventions.md b/docs/development/coding-conventions.md index 621c016..4bc303e 100644 --- a/docs/development/coding-conventions.md +++ b/docs/development/coding-conventions.md @@ -6,6 +6,7 @@ - Write C with four-space indentation and K&R braces, following neighboring files. Use `snake_case`, `BSP_*` public constants, `s_` file-local state, `bsp_` public BSP APIs, and `demo__` demo entry points. Prefer `static` for internal symbols. - Keep UI text and default documentation in English. Explanatory source comments may use Chinese while retaining established English technical terms. +- The baseline enables only LVGL Montserrat 14 and 20, which do not contain CJK glyphs. Chinese UTF-8 text therefore renders as missing-glyph boxes; changing source-file encoding does not fix it. Before adding Chinese UI text, compile and select a CJK font that covers every displayed character, prefer a glyph subset over a full font, configure a suitable fallback for mixed-language text, budget Flash and internal RAM, and verify the result on the device. - Put reusable hardware behavior in `components/bsp`; keep menus, animations, product interaction, and validation pages in `main`. - Document non-trivial functions, state, ownership, blocking behavior, task context, initialization order, failure values, register choices, timing, synchronization, and hardware-specific constants. Explain why, not merely what. - Add or update tests with code changes. If automation is not practical, record the test gap and exact manual validation path. diff --git a/docs/development/coding-conventions.zh_CN.md b/docs/development/coding-conventions.zh_CN.md index 618ce8b..4e146e1 100644 --- a/docs/development/coding-conventions.zh_CN.md +++ b/docs/development/coding-conventions.zh_CN.md @@ -5,6 +5,7 @@ # 代码约定(Coding Conventions) - **语言/风格**:C 用四空格缩进 + K&R 大括号,跟随相邻文件;函数/局部变量 `snake_case`,公开硬件常量 `BSP_*`,文件内状态 `s_` 前缀;BSP API 用 `bsp_` 前缀,demo 入口 `demo__`;内部符号优先 `static`。UI 文案用英文,解释性注释可用中文;保留记录硬件寄存器值与内存约束的注释。 +- **中文方框字陷阱**:当前基线只启用 LVGL Montserrat 14 和 20,这些字体不包含 CJK glyph。即使源码和字符串均为 UTF-8,中文也会显示为缺字方框,修改源文件编码不能解决。添加中文 UI 前,必须编译并选用覆盖全部实际字符的 CJK 字体,优先生成 glyph 子集而非引入完整字库;中英文混排时配置合适的 fallback,同时核对 Flash、内部 RAM 占用并在真机逐字验证。 - **复用既有组件**:可复用硬件逻辑放 `components/bsp`;菜单/动画/业务交互/验证页面放 `main`。不要另造轮子,遵循既有 BSP API。 - **注释要求(尽可能详细)**:项目源码需要尽可能详细地编写函数说明、变量说明,增加完善的代码注释。 - **函数说明**:每个非平凡函数都要有注释,说明:用途/职责、参数含义、返回值、失败值、副作用、阻塞行为、线程/任务上下文、内存所有权、调用前提与初始化顺序。涉及硬件的函数额外注明寄存器操作、时序约束与已知陷阱。 diff --git a/docs/development/environment-setup.md b/docs/development/environment-setup.md new file mode 100644 index 0000000..4e1edd9 --- /dev/null +++ b/docs/development/environment-setup.md @@ -0,0 +1,333 @@ +

+ 简体中文 · English +

+ +# Environment Bootstrap for AI Agents + +This document lets an AI agent bootstrap a clean checkout without relying on a +developer-specific shell function, absolute path, IDE, or preinstalled ESP-IDF. +The required baseline is ESP-IDF 5.5.3 for ESP32-C3. + +## Agent contract + +Before installing anything: + +1. Run `git status --short --branch` in an existing checkout and preserve all + user changes. +2. Detect the operating system and architecture. Check for an already activated + ESP-IDF before downloading another copy. +3. Reuse an existing installation only when `idf.py --version` reports + `ESP-IDF v5.5.3`. Install other versions side by side; do not replace them. +4. Ask for approval before using `sudo`, installing system packages, writing + outside the repository, changing group membership, or downloading through a + restricted network. +5. Do not edit shell startup files, global Git configuration, proxy settings, + certificate verification, or package-manager configuration without explicit + user authorization. +6. Never use a machine-specific shell alias as a required command. +7. Prefer official upstream and Espressif-operated download services. Do not + silently fall back to an unverified mirror. + +Start with read-only discovery: + +```bash +uname -s +uname -m +command -v idf.py || true +idf.py --version 2>/dev/null || true +printf 'IDF_PATH=%s\n' "${IDF_PATH:-}" +git status --short --branch +``` + +If the correct environment is already active, continue at +[Initialize the checkout](#initialize-the-checkout). + +## Choose a download route + +Use the international route by default. Use the mainland China route when the +user requests it or direct GitHub/registry downloads are unavailable or too +slow. Keep mirror variables scoped to the current terminal or command. + +| Download | International default | Mainland China official route | +| --- | --- | --- | +| ESP-IDF source | GitHub `espressif/esp-idf` | Espressif Gitee mirror plus `esp-gitee-tools` | +| Compiler and tool archives | GitHub release assets | `dl.espressif.cn/github_assets` | +| Managed Components | ESP Component Registry default storage | `components-file.espressif.cn` | +| Project repository | URL supplied by the user | A user-supplied mirror of the same repository | + +Do not invent a mirror URL for this project. If the supplied repository URL is +unreachable, ask the user for an authorized mirror or archive. + +## Install host prerequisites + +### Ubuntu and Debian + +After approval for system changes: + +```bash +sudo apt-get update +sudo apt-get install -y git wget curl flex bison gperf python3 \ + python3-pip python3-venv cmake ninja-build ccache libffi-dev \ + libssl-dev dfu-util libusb-1.0-0 build-essential +``` + +### Fedora and related distributions + +```bash +sudo dnf install -y git wget curl flex bison gperf python3 cmake \ + ninja-build ccache libffi-devel openssl-devel dfu-util libusb1-devel \ + gcc gcc-c++ make +``` + +### Arch Linux + +```bash +sudo pacman -S --needed base-devel git wget curl flex bison gperf python \ + cmake ninja ccache dfu-util libusb +``` + +### macOS + +Install Xcode Command Line Tools and Homebrew first, then: + +```bash +xcode-select --install +brew install cmake ninja ccache dfu-util libusb python +``` + +Do not launch `xcode-select --install` or install Homebrew without user approval; +both are host-level changes and may require interaction. + +### Windows and WSL2 + +For native Windows, use Espressif's official ESP-IDF Tools Installer and select +ESP-IDF v5.5.3. Run later commands in the installer-created ESP-IDF PowerShell or +Command Prompt. Do not translate POSIX activation commands literally into +PowerShell. + +WSL2 can run the Linux build flow. USB flashing and monitoring require a device +forwarded into WSL; otherwise build in WSL and flash from an activated native +Windows ESP-IDF terminal. + +## Install ESP-IDF 5.5.3 + +Use a location outside this repository and without spaces. The variable below +is task-specific and can be overridden by the user: + +```bash +export AI_PASSPORT_IDF_ROOT="${AI_PASSPORT_IDF_ROOT:-${HOME}/esp/esp-idf-v5.5.3}" +``` + +### International route + +```bash +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +git clone --branch v5.5.3 --recursive \ + https://github.com/espressif/esp-idf.git \ + "${AI_PASSPORT_IDF_ROOT}" +"${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +If cloning was interrupted, repair the checkout instead of starting over: + +```bash +git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init --recursive +"${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +### Mainland China route + +The following route uses repositories and download endpoints operated by +Espressif. It does not change global Git or pip configuration: + +```bash +export AI_PASSPORT_GITEE_TOOLS_ROOT="${AI_PASSPORT_GITEE_TOOLS_ROOT:-${HOME}/esp/esp-gitee-tools}" +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +git clone --branch v5.5.3 \ + https://gitee.com/EspressifSystems/esp-idf.git \ + "${AI_PASSPORT_IDF_ROOT}" +git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git \ + "${AI_PASSPORT_GITEE_TOOLS_ROOT}" +"${AI_PASSPORT_GITEE_TOOLS_ROOT}/submodule-update.sh" \ + "${AI_PASSPORT_IDF_ROOT}" +IDF_GITHUB_ASSETS=dl.espressif.cn/github_assets \ + "${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +If the Gitee helper reports an interrupted download, rerun its submodule command +for the same checkout. Do not mix partial submodules from unrelated ESP-IDF +versions. + +## Activate and verify ESP-IDF + +Activation applies to the current shell only and is the portable replacement +for machine-specific aliases: + +```bash +source "${AI_PASSPORT_IDF_ROOT}/export.sh" +idf.py --version +python --version +printf 'IDF_PATH=%s\n' "${IDF_PATH}" +``` + +Stop if the reported version is not exactly `ESP-IDF v5.5.3`. Do not generate +project configuration with another version. + +For mainland China, optionally accelerate Managed Component archives in the +current terminal: + +```bash +export IDF_COMPONENT_STORAGE_URL="https://components-file.espressif.cn" +``` + +This changes only the component file-storage endpoint. Version selection still +comes from `components/bsp/idf_component.yml` and the tracked +`dependencies.lock`. + +## Obtain the project + +If the agent was given a repository URL but has no checkout yet: + +```bash +git clone ai-passport +cd ai-passport +git status --short --branch +``` + +Use the user-supplied URL verbatim. Do not embed credentials in it, print tokens, +or persist authentication data in repository files. + +## Initialize the checkout + +From the repository root, prefer the firmware gate for the first build. It +creates and verifies the merged image intended for delivery and flashing: + +```bash +./tools/validate.sh --firmware +``` + +Use `idf.py set-target esp32c3` and `idf.py build` only when an incremental +development build is useful. Before running `set-target` in an established +workspace, inspect and preserve intentional local configuration because it may +rename an existing ignored `sdkconfig` to `sdkconfig.old`. + +`idf.py fullclean` removes build output but does not fully synchronize an +existing `sdkconfig` with changed defaults. + +The first build downloads the versions pinned by `dependencies.lock` into +`managed_components/`. Never edit that generated directory. A normal build must +not leave an unexplained `dependencies.lock` diff. + +Confirm the baseline configuration: + +```bash +grep -E 'CONFIG_IDF_TARGET|CONFIG_ESPTOOLPY_FLASHSIZE|CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG|CONFIG_SPIRAM' sdkconfig +``` + +Expected: ESP32-C3, 8 MB Flash, USB Serial/JTAG console, and no PSRAM. + +## Run the repository gate + +Run the static gate first, then the firmware gate: + +```bash +./tools/validate.sh --static +./tools/validate.sh --firmware +./tools/validate.sh +``` + +The static gate requires Python 3, a C compiler, `curl`, `tar`, and a SHA-256 +tool. It downloads a checksum-pinned `actionlint` release into `/tmp` when one is +not installed. The firmware gate is the preferred build path. It uses an +isolated temporary build and produces the verified `0x0` image at: + +```text +build/FoloToy-AI-Passport-full.bin +``` + +For build-only agents with Docker already authorized, the official Espressif +image is an alternative to a host installation: + +```bash +docker run --rm \ + -v "${PWD}:/project" \ + -w /project \ + -e IDF_GIT_SAFE_DIR=/project \ + espressif/idf:v5.5.3 \ + ./tools/validate.sh --firmware +``` + +Docker does not by itself provide safe USB access for flashing, and mounting the +checkout allows the container to write generated files. Obtain approval before +pulling the image or using Docker. + +## Flash and monitor + +Device access is optional for compilation but required for hardware validation. +Use a data-capable USB cable and discover the actual port; never hardcode it in +the repository: + +```bash +ls /dev/ttyACM* /dev/ttyUSB* 2>/dev/null +``` + +On Linux, serial access commonly requires membership in `dialout` (or `uucp` on +some distributions). Changing group membership requires user approval and a new +login session: + +```bash +sudo usermod -aG dialout "${USER}" +``` + +Close WebSerial pages and other serial monitors before flashing. Do not run the +normal development flow permanently as root. Exit the ESP-IDF monitor with +`Ctrl+]`. + +Prefer flashing the verified merged image from offset `0x0`: + +```bash +python -m esptool --chip esp32c3 -p -b 460800 \ + write-flash 0x0 build/FoloToy-AI-Passport-full.bin +idf.py -p monitor +``` + +The ordinary `build/FoloToy-AI-Passport.bin` is application-only and belongs at +`0x10000`; it must not be written to `0x0`. Use `idf.py flash` only for an +intentional incremental development flash, not as the default delivery or +acceptance path. + +## Failure handling + +| Symptom | Action | +| --- | --- | +| `idf.py` not found | Activate the selected installation's `export.sh`; do not guess a private alias. | +| Wrong ESP-IDF version | Stop and activate/install v5.5.3 side by side. | +| GitHub source or asset download is slow | Switch to the documented Espressif mainland China route. | +| Component download is slow in China | Set `IDF_COMPONENT_STORAGE_URL` for the current terminal. | +| Component download fails | Check network, proxy, DNS, and certificates; never disable TLS verification as a shortcut. | +| Configuration misses tracked defaults | Preserve intentional settings, then rerun `idf.py set-target esp32c3`. | +| Build came from another ESP-IDF | Activate v5.5.3, run `idf.py fullclean`, then `idf.py set-target esp32c3`. | +| Serial port is missing | Check cable, enumeration, host/VM USB forwarding, and power. | +| Serial port is busy | Close WebSerial, VS Code monitor, `idf.py monitor`, and other serial clients. | +| Permission denied on serial port | Add the user to the platform serial group and log in again. | + +## Completion report + +An AI agent must report environment and hardware results separately: + +```text +Environment: PASS / FAIL (OS, architecture, ESP-IDF version, download route) +Build: PASS / FAIL / NOT RUN +Host tests: PASS / FAIL / NOT RUN +Device tests: PASS / FAIL / NOT RUN +Unverified: remaining USB, board, instrument, or user checks +``` + +Official references: + +- [ESP-IDF v5.5 toolchain setup](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c3/get-started/linux-macos-setup.html) +- [ESP-IDF v5.5 project setup](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c3/get-started/linux-macos-start-project.html) +- [Espressif download mirror configuration](https://docs.espressif.com/projects/esp-idf/en/v5.5/esp32c3/api-guides/tools/idf-tools.html) +- [IDF Component Manager configuration](https://docs.espressif.com/projects/idf-component-manager/en/latest/use/how_to_configuration.html) +- [Espressif Gitee tools](https://gitee.com/EspressifSystems/esp-gitee-tools) +- [ESP-IDF Windows setup](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c3/get-started/windows-setup.html) diff --git a/docs/development/environment-setup.zh_CN.md b/docs/development/environment-setup.zh_CN.md new file mode 100644 index 0000000..f0c532c --- /dev/null +++ b/docs/development/environment-setup.zh_CN.md @@ -0,0 +1,287 @@ +

+ 简体中文 · English +

+ +# AI Agent 环境引导 + +本文用于让 AI agent 在全新 checkout 中完成环境搭建,不依赖特定开发者的 shell 函数、绝对路径、IDE 或预装 ESP-IDF。项目要求 ESP32-C3 对应的 ESP-IDF 5.5.3。 + +## Agent 执行约束 + +安装任何内容前: + +1. 已有 checkout 中先运行 `git status --short --branch`,保留全部用户修改。 +2. 检测操作系统和架构;下载新环境前先检查是否已有激活的 ESP-IDF。 +3. 仅当 `idf.py --version` 输出 `ESP-IDF v5.5.3` 时复用已有安装。其他版本应并行安装,不得覆盖。 +4. 使用 `sudo`、安装系统包、写仓库外目录、修改用户组或通过受限网络下载前,先请求用户授权。 +5. 未经用户明确授权,不得修改 shell 启动文件、全局 Git 配置、代理、证书校验或包管理器配置。 +6. 不得把机器专用的 shell alias 当作必要命令。 +7. 优先使用官方上游和乐鑫运营的下载服务,不得静默切换到未经验证的镜像。 + +先执行只读探测: + +```bash +uname -s +uname -m +command -v idf.py || true +idf.py --version 2>/dev/null || true +printf 'IDF_PATH=%s\n' "${IDF_PATH:-}" +git status --short --branch +``` + +若正确环境已经激活,直接进入[初始化 checkout](#初始化-checkout)。 + +## 选择下载线路 + +默认使用国际线路。用户明确要求,或 GitHub/Registry 直连不可用、过慢时,使用中国大陆线路。镜像变量只作用于当前终端或单条命令。 + +| 下载内容 | 国际默认线路 | 中国大陆官方线路 | +| --- | --- | --- | +| ESP-IDF 源码 | GitHub `espressif/esp-idf` | 乐鑫 Gitee 镜像及 `esp-gitee-tools` | +| 编译器和工具归档 | GitHub Release Assets | `dl.espressif.cn/github_assets` | +| Managed Components | ESP Component Registry 默认存储 | `components-file.espressif.cn` | +| 当前项目仓库 | 用户提供的 URL | 用户提供的同仓库镜像 | + +不得为当前项目编造镜像地址。用户提供的仓库 URL 不可访问时,应询问已授权的镜像或归档地址。 + +## 安装主机依赖 + +### Ubuntu 和 Debian + +获得系统修改授权后: + +```bash +sudo apt-get update +sudo apt-get install -y git wget curl flex bison gperf python3 \ + python3-pip python3-venv cmake ninja-build ccache libffi-dev \ + libssl-dev dfu-util libusb-1.0-0 build-essential +``` + +### Fedora 及相关发行版 + +```bash +sudo dnf install -y git wget curl flex bison gperf python3 cmake \ + ninja-build ccache libffi-devel openssl-devel dfu-util libusb1-devel \ + gcc gcc-c++ make +``` + +### Arch Linux + +```bash +sudo pacman -S --needed base-devel git wget curl flex bison gperf python \ + cmake ninja ccache dfu-util libusb +``` + +### macOS + +先安装 Xcode Command Line Tools 和 Homebrew,再执行: + +```bash +xcode-select --install +brew install cmake ninja ccache dfu-util libusb python +``` + +`xcode-select --install` 和 Homebrew 安装均属于主机级修改且可能需要交互,AI 不得未经用户授权直接执行。 + +### Windows 与 WSL2 + +原生 Windows 使用乐鑫官方 ESP-IDF Tools Installer,并选择 ESP-IDF v5.5.3。后续命令应在安装器生成的 ESP-IDF PowerShell 或 Command Prompt 中执行,不得把 POSIX 激活命令机械翻译为 PowerShell。 + +WSL2 可以执行 Linux 编译流程。烧录和监视需要把 USB 设备转发进 WSL;否则在 WSL 编译,在已激活 ESP-IDF 的原生 Windows 终端烧录。 + +## 安装 ESP-IDF 5.5.3 + +安装位置应位于当前仓库之外,路径不得包含空格。以下变量只服务本任务,并允许用户覆盖: + +```bash +export AI_PASSPORT_IDF_ROOT="${AI_PASSPORT_IDF_ROOT:-${HOME}/esp/esp-idf-v5.5.3}" +``` + +### 国际线路 + +```bash +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +git clone --branch v5.5.3 --recursive \ + https://github.com/espressif/esp-idf.git \ + "${AI_PASSPORT_IDF_ROOT}" +"${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +clone 中断时应修复原 checkout,不要从头重复下载: + +```bash +git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init --recursive +"${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +### 中国大陆线路 + +以下线路使用乐鑫运营的仓库和下载端点,不修改全局 Git 或 pip 配置: + +```bash +export AI_PASSPORT_GITEE_TOOLS_ROOT="${AI_PASSPORT_GITEE_TOOLS_ROOT:-${HOME}/esp/esp-gitee-tools}" +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +git clone --branch v5.5.3 \ + https://gitee.com/EspressifSystems/esp-idf.git \ + "${AI_PASSPORT_IDF_ROOT}" +git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git \ + "${AI_PASSPORT_GITEE_TOOLS_ROOT}" +"${AI_PASSPORT_GITEE_TOOLS_ROOT}/submodule-update.sh" \ + "${AI_PASSPORT_IDF_ROOT}" +IDF_GITHUB_ASSETS=dl.espressif.cn/github_assets \ + "${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +Gitee 辅助工具报告下载中断时,对同一个 checkout 重新执行子模块命令。不得混用不同 ESP-IDF 版本的部分子模块。 + +## 激活并核验 ESP-IDF + +激活只影响当前 shell,是个人化 alias 的通用替代方案: + +```bash +source "${AI_PASSPORT_IDF_ROOT}/export.sh" +idf.py --version +python --version +printf 'IDF_PATH=%s\n' "${IDF_PATH}" +``` + +版本不是严格的 `ESP-IDF v5.5.3` 时必须停止,不得用其他版本生成项目配置。 + +中国大陆环境可在当前终端临时加速 Managed Component 归档下载: + +```bash +export IDF_COMPONENT_STORAGE_URL="https://components-file.espressif.cn" +``` + +它只改变组件文件存储端点;版本选择仍由 `components/bsp/idf_component.yml` 和已提交的 `dependencies.lock` 决定。 + +## 获取项目 + +若 agent 只拿到仓库地址、尚无 checkout: + +```bash +git clone ai-passport +cd ai-passport +git status --short --branch +``` + +必须原样使用用户提供的 URL,不得把凭证嵌入 URL、打印 token,或把认证信息写入仓库文件。 + +## 初始化 checkout + +在仓库根目录首次编译时,优先运行固件门禁。它会生成并验证用于交付和烧录的 +合并固件: + +```bash +./tools/validate.sh --firmware +``` + +仅在需要增量开发编译时使用 `idf.py set-target esp32c3` 和 `idf.py build`。 +已有工作区运行 `set-target` 前,应检查并保留有意设置的本地配置,因为它可能把 +已有、被忽略的 `sdkconfig` 重命名为 `sdkconfig.old`。 + +`idf.py fullclean` 只删除构建输出,不能让已有 `sdkconfig` 完整同步新 defaults。 + +首次构建会把 `dependencies.lock` 锁定的版本下载到 `managed_components/`。不得编辑这个生成目录;普通构建不应留下无法解释的 `dependencies.lock` diff。 + +核对基线配置: + +```bash +grep -E 'CONFIG_IDF_TARGET|CONFIG_ESPTOOLPY_FLASHSIZE|CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG|CONFIG_SPIRAM' sdkconfig +``` + +预期为 ESP32-C3、8 MB Flash、USB Serial/JTAG 控制台且无 PSRAM。 + +## 运行仓库门禁 + +先运行静态门禁,再运行固件门禁: + +```bash +./tools/validate.sh --static +./tools/validate.sh --firmware +./tools/validate.sh +``` + +静态门禁需要 Python 3、C 编译器、`curl`、`tar` 和 SHA-256 工具;未安装 +`actionlint` 时,会把带固定校验和的版本下载到 `/tmp`。固件门禁是默认优先的 +编译方式,它使用隔离的临时构建,并生成经过验证的 `0x0` 镜像: + +```text +build/FoloToy-AI-Passport-full.bin +``` + +对于已经获得 Docker 使用授权、只需编译的 agent,乐鑫官方镜像可以替代主机安装: + +```bash +docker run --rm \ + -v "${PWD}:/project" \ + -w /project \ + -e IDF_GIT_SAFE_DIR=/project \ + espressif/idf:v5.5.3 \ + ./tools/validate.sh --firmware +``` + +Docker 本身不会提供安全的 USB 烧录访问,挂载 checkout 后容器也可以写生成文件。拉取镜像或使用 Docker 前必须获得授权。 + +## 烧录与监视 + +编译不要求设备,硬件验证必须访问设备。使用支持数据传输的 USB 线,发现实际端口,不得在仓库中硬编码: + +```bash +ls /dev/ttyACM* /dev/ttyUSB* 2>/dev/null +``` + +Linux 串口访问通常要求用户属于 `dialout`(部分发行版为 `uucp`)。修改用户组前必须获得授权,且修改后需要重新登录: + +```bash +sudo usermod -aG dialout "${USER}" +``` + +烧录前关闭 WebSerial 页面和其他串口监视器。不要长期以 root 身份运行日常开发流程。使用 `Ctrl+]` 退出 ESP-IDF monitor。 + +优先从 `0x0` 烧录经过验证的合并镜像: + +```bash +python -m esptool --chip esp32c3 -p -b 460800 \ + write-flash 0x0 build/FoloToy-AI-Passport-full.bin +idf.py -p monitor +``` + +普通的 `build/FoloToy-AI-Passport.bin` 只是 app,只能位于 `0x10000`,不得烧到 +`0x0`。`idf.py flash` 只用于明确需要的增量开发烧录,不作为默认交付或验收方式。 + +## 故障处理 + +| 症状 | 处理 | +| --- | --- | +| 找不到 `idf.py` | 激活所选安装的 `export.sh`,不得猜测个人 alias。 | +| ESP-IDF 版本错误 | 停止并并行激活/安装 v5.5.3。 | +| GitHub 源码或工具下载慢 | 切换到本文的乐鑫中国大陆线路。 | +| 中国大陆组件下载慢 | 在当前终端设置 `IDF_COMPONENT_STORAGE_URL`。 | +| 组件下载失败 | 检查网络、代理、DNS 和证书,不得通过关闭 TLS 校验绕过。 | +| 配置缺少已跟踪 defaults | 保留有意配置,再执行 `idf.py set-target esp32c3`。 | +| 构建来自其他 ESP-IDF | 激活 v5.5.3,执行 `idf.py fullclean`,再 set-target/build。 | +| 串口不存在 | 检查线材、枚举、主机/虚拟机 USB 转发和供电。 | +| 串口被占用 | 关闭 WebSerial、VS Code monitor、`idf.py monitor` 和其他串口客户端。 | +| 串口 permission denied | 把用户加入平台串口组并重新登录。 | + +## 完成报告 + +AI agent 必须分别报告环境、构建与硬件结果: + +```text +Environment: PASS / FAIL(OS、架构、ESP-IDF 版本、下载线路) +Build: PASS / FAIL / NOT RUN +Host tests: PASS / FAIL / NOT RUN +Device tests: PASS / FAIL / NOT RUN +Unverified: 仍需 USB、板卡、仪器或用户确认的事项 +``` + +官方参考: + +- [ESP-IDF v5.5 工具链安装](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c3/get-started/linux-macos-setup.html) +- [ESP-IDF v5.5 项目初始化](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c3/get-started/linux-macos-start-project.html) +- [乐鑫下载镜像配置](https://docs.espressif.com/projects/esp-idf/en/v5.5/esp32c3/api-guides/tools/idf-tools.html) +- [IDF Component Manager 配置](https://docs.espressif.com/projects/idf-component-manager/en/latest/use/how_to_configuration.html) +- [乐鑫 Gitee 工具](https://gitee.com/EspressifSystems/esp-gitee-tools) +- [ESP-IDF Windows 安装](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c3/get-started/windows-setup.html) diff --git a/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md b/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md index 7650763..38d188f 100644 --- a/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md +++ b/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md @@ -183,18 +183,26 @@ Menu initialization status arrays implicitly follow `DEMOS[]` order; update and ## 12. Development environment -Use ESP-IDF 5.5.3 outside the repository. On Ubuntu/Debian, install the standard ESP-IDF prerequisites, clone Espressif's `v5.5.3` tag recursively, and run `./install.sh esp32c3`. Activate its `export.sh` in every terminal and confirm `idf.py --version`. +Follow the canonical [environment bootstrap](../development/environment-setup.md) +for clean-machine installation, OS-specific prerequisites, and international or +mainland China download routes. Use ESP-IDF 5.5.3 outside the repository, +activate its `export.sh` in every terminal, and confirm the exact version. +Prefer `./tools/validate.sh --firmware` to build the verified merged image and +flash that image at `0x0`; use direct `idf.py build/flash` only for incremental +development. ```bash -get_idf553 +source /export.sh +idf.py --version idf.py set-target esp32c3 idf.py reconfigure idf.py build ``` -The Component Manager resolves dependencies from `components/bsp/idf_component.yml`. Do not edit `managed_components/`. `dependencies.lock` is tracked and must remain reproducible under ESP-IDF 5.5.3. Generated `sdkconfig` does not automatically absorb every changed default; inspect it and use `idf.py fullclean` only for stale generated state. +The Component Manager resolves dependencies from `components/bsp/idf_component.yml`. Do not edit `managed_components/`. `dependencies.lock` is tracked and must remain reproducible under ESP-IDF 5.5.3. Generated `sdkconfig` does not automatically absorb every changed default; preserve intentional settings and use `idf.py set-target esp32c3` when configuration must be regenerated. Use `idf.py fullclean` only to remove stale build output. -Flash through the native USB Serial/JTAG port, commonly `/dev/ttyACM0` on Linux: +For an intentional incremental flash, use the native USB Serial/JTAG port, +commonly `/dev/ttyACM0` on Linux: ```bash idf.py -p /dev/ttyACM0 flash monitor @@ -246,6 +254,7 @@ General board acceptance: | Black after light sleep | timer wake source, sleep error, backlight restore | | Deep sleep does not restart | timer source, boot wake cause, RTC counter | | I2S allocation fails after UI growth | competition among LCD/LVGL buffers and I2S DMA | +| Chinese text appears as boxes | Montserrat 14/20 has no CJK glyphs; compile and select a CJK subset, configure fallback for mixed text, and verify glyph coverage on the device | ## 15. Pre-delivery checklist diff --git a/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md b/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md index b7d82ac..fbe182a 100644 --- a/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md +++ b/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md @@ -26,7 +26,7 @@ AI 应先完成以下检查: ## 2. 硬件总览 -当前代码针对 ESP32-C3 FoloToy AI Passport,使用 ESP-IDF 5.5.x(已知开发环境为 5.5.3)。MCU **没有 PSRAM**,外设 DMA 和 UI 都使用内部 RAM。 +当前代码针对 ESP32-C3 FoloToy AI Passport,使用 ESP-IDF 5.5.3。MCU **没有 PSRAM**,外设 DMA 和 UI 都使用内部 RAM。 | 子系统 | 器件/方式 | 总线或资源 | 固件支持 | | --- | --- | --- | --- | @@ -264,7 +264,12 @@ SOC 准确度取决于电芯与 profile 的匹配程度。本驱动给出的是 ## 12. 开发环境搭建 -项目要求 ESP-IDF 5.5.x,推荐与已知开发环境一致使用 **ESP-IDF 5.5.3**。不要直接使用系统中的任意 `idf.py`,也不要将 Arduino、PlatformIO 或其他 ESP-IDF 版本生成的配置混入当前工程。 +全新机器安装、各操作系统依赖以及国际/中国大陆下载线路统一以 +[环境引导](../development/environment-setup.zh_CN.md)为准。项目严格使用 +**ESP-IDF 5.5.3**。不要直接使用系统中的任意 `idf.py`,也不要将 Arduino、 +PlatformIO 或其他 ESP-IDF 版本生成的配置混入当前工程。 +编译优先使用 `./tools/validate.sh --firmware` 生成并验证合并固件,烧录优先把该 +镜像写入 `0x0`;直接 `idf.py build/flash` 只用于增量开发。 ### 12.1 Linux / WSL 准备 @@ -305,24 +310,16 @@ source "$HOME/esp/esp-idf-v5.5.3/export.sh" idf.py --version ``` -版本输出应为 ESP-IDF v5.5.3。本机若已配置 `get_idf553` shell 快捷命令,也可以用它代替 `source .../export.sh`,但该命令不是仓库文件的一部分,不能假设所有机器都存在。 - -可选地在自己的 shell 配置中定义快捷函数: - -```bash -get_idf553() { - source "$HOME/esp/esp-idf-v5.5.3/export.sh" -} -``` - -修改 `~/.bashrc` 或 `~/.zshrc` 属于用户级环境变更,AI 执行前应获得用户授权;仅在文档中给出示例不代表可以自动修改。 +版本输出必须为 ESP-IDF v5.5.3。文档和自动化不得依赖机器专用 alias,AI +也不得擅自修改 shell 启动文件。 ### 12.3 获取工程依赖并首次构建 进入项目根目录后执行: ```bash -get_idf553 # 或 source 对应 export.sh +source /export.sh +idf.py --version idf.py set-target esp32c3 idf.py reconfigure idf.py build @@ -338,7 +335,7 @@ idf.py build grep -E 'IDF_TARGET|ESP_CONSOLE_USB_SERIAL_JTAG|SPIRAM|FLASHSIZE' sdkconfig ``` -预期目标为 ESP32-C3、控制台为 USB Serial/JTAG、Flash 为 8 MB,并且不启用 PSRAM。`sdkconfig.defaults` 只影响新生成配置;已有 `sdkconfig` 不会自动完全跟随 defaults。defaults 变化后应检查配置差异,必要时备份有用选项后执行 `idf.py fullclean` 并重新配置。 +预期目标为 ESP32-C3、控制台为 USB Serial/JTAG、Flash 为 8 MB,并且不启用 PSRAM。`sdkconfig.defaults` 只影响新生成配置;已有 `sdkconfig` 不会自动完全跟随 defaults。defaults 变化后应检查配置差异,保留有意设置后运行 `idf.py set-target esp32c3` 重新生成配置。`idf.py fullclean` 只用于清理构建输出。 ### 12.4 连接、烧录与监视 @@ -393,10 +390,11 @@ idf.py build ## 13. 构建与验证 -推荐环境: +默认优先运行 `./tools/validate.sh --firmware`。以下命令仅用于增量开发: ```bash -get_idf553 +source /export.sh +idf.py --version idf.py set-target esp32c3 # 新 checkout 或目标变化时 idf.py build idf.py flash monitor @@ -448,6 +446,7 @@ idf.py flash monitor | light sleep 后黑屏 | timer wake source、`esp_light_sleep_start()` 错误日志、唤醒后是否恢复背光 | | deep sleep 后未重启 | timer wake source、启动日志的 wake cause、页面 RTC 计数;当前 demo 使用 RTC timer 唤醒 | | 加大 UI 后 I2S NO_MEM | LCD 双缓冲/LVGL pool 与 I2S DMA 争夺内部 RAM | +| 中文显示为方框 | Montserrat 14/20 不含 CJK glyph;编译并选用中文字体子集,为混排配置 fallback,并在真机核对全部字符 | ## 15. AI 提交前自检