diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 231202f..90794d9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,8 @@ - Added the supplied 80-byte CW2017 profile for the specified 520 mAh cell, including content/update-flag checks, verified writes, the required restart sequence, and bounded SOC-readiness polling. +- Expanded the environment bootstrap document: added Espressif's Git service mirror (`git.espressif.com.cn`) as the preferred mainland-China route for ESP-IDF v5.5.3 and its submodules, documented submodule long-wait/timeout handling and in-place repair, warned about stale per-repository Jihulab `insteadOf` residue, and added the official offline release archive as a last-resort fallback (learned from `esp-mosaico/esp-mosaico-vibe`). + - Reorganized the documentation by function area with a dual entry point: the root `AGENTS.md` is now a thin router (hard constraints + task routing only) and the detailed AI workflow lives in `docs/development/ai-guide.md`; `agent-guide.md` was folded in. `docs/development/` gained a second level (`engineering/`, `ci/`, `release/`), and the `plays/` application archive and `experiences/` moved into a `docs/reference/` area with a dedicated README. Removed `docs/software-design/` (empty scaffold); folded the three `assets/{fonts,images,music}/README` leaves into the `assets/` README; flattened the six `project-completion` sub-documents into a single file; and unified each directory to a single README, eliminating every `INDEX` file and a duplicated experience index. All cross-references and bibliographic links were updated; no content was dropped. - Kept the fixed protected `cardid`/Recovery partitions and CI validation for diff --git a/docs/CHANGELOG.zh_CN.md b/docs/CHANGELOG.zh_CN.md index f3e682f..728d6e9 100644 --- a/docs/CHANGELOG.zh_CN.md +++ b/docs/CHANGELOG.zh_CN.md @@ -8,6 +8,8 @@ - 加入厂家为优特利 520mAh 电芯生成的 80 字节 CW2017 profile,并实现内容与更新标志检查、写入后校验、规定的重启时序以及有上限的 SOC 就绪等待。 +- 扩充环境引导文档:新增乐鑫 Git 服务镜像(`git.espressif.com.cn`)作为中国大陆首选线路,覆盖 ESP-IDF v5.5.3 及其子模块;补充子模块长等待/超时处理与原地修复;提示按仓库残留的 Jihulab `insteadOf` 旧配置;并把官方离线 release 压缩包加入兜底方案(经验来自 `esp-mosaico/esp-mosaico-vibe`)。 + - 按功能域整理文档并采用双入口:根目录 `AGENTS.md` 变为薄路由(只保留硬约束与任务路由),详细的 AI 开发工作流下沉到 `docs/development/ai-guide.md`,`agent-guide.md` 并入其中。为 `docs/development/` 增加二级分区(`engineering/`、`ci/`、`release/`),把 `plays/` 应用档案与 `experiences/` 移入带专属 README 的 `docs/reference/` 参考区;删除 `docs/software-design/`(空脚手架);把 `assets/{fonts,images,music}/README` 三个叶子 README 并入 `assets/` README;把 `project-completion` 的六个子文档压平为单文件;并把每个目录统一为单一 README,消除所有 `INDEX` 文件与一处重复经验索引。所有交叉引用与文献链接已更新;未丢弃任何内容。 - 保留固定的 `cardid`/Recovery 保护分区,以及 CI 对合并镜像结构、 diff --git a/docs/development/engineering/environment-setup.md b/docs/development/engineering/environment-setup.md index 4e1edd9..68c0555 100644 --- a/docs/development/engineering/environment-setup.md +++ b/docs/development/engineering/environment-setup.md @@ -50,7 +50,7 @@ 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` | +| ESP-IDF source | GitHub `espressif/esp-idf` | Espressif Git service mirror (`git.espressif.com.cn`), or 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 | @@ -58,6 +58,30 @@ slow. Keep mirror variables scoped to the current terminal or command. 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. +The Espressif Git service mirror hosts the full `esp-idf` history and every +v5.5.3 submodule repository (`espressif/esp32-wifi-lib`, `espressif/esp-lwip`, +`ThrowTheSwitch/CMock`, and so on). Because the v5.5.3 `.gitmodules` entries are +relative URLs, cloning the parent repository from the mirror resolves every +submodule to the same mirror automatically; no separate submodule rewrite is +needed. Cloning from the mirror leaves a working checkout identical to the +GitHub clone: verify the tag commit matches +`https://github.com/espressif/esp-idf/releases/tag/v5.5.3` (currently +`b31fcc7a314a44ad992b58f589f7d1d8a4fadff6`). + +Legacy mirror installers sometimes write a global per-repository `insteadOf` +rewrite for Jihulab (`jihulab.com/esp-mirror/...`, or a +`git config --global url."https://jihulab.com/esp-mirror/".insteadOf` switch). +A per-repository entry is more specific than any bulk switch and silently +redirects submodules to a source that returns 404 or timeouts. When a submodule +fetch fails this way, inspect and clean the residue after user approval instead +of retrying blindly: + +```bash +git config --global --get-regexp 'url\..*jihulab' +# Cleaning requires user approval: unset each entry individually; removing only +# the bulk switch leaves per-repository entries that still redirect submodules. +``` + ## Install host prerequisites ### Ubuntu and Debian @@ -137,8 +161,28 @@ git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init --recursive ### Mainland China route -The following route uses repositories and download endpoints operated by -Espressif. It does not change global Git or pip configuration: +The following routes use repositories and download endpoints operated by +Espressif. They do not change global Git or pip configuration. + +**Espressif Git service mirror (preferred).** Clone from the mirror URL +directly — `origin` becomes the mirror URL, so every relative submodule URL +inside `esp-idf` (`../../espressif/...`) resolves to the same mirror without a +rewrite and without global Git configuration: + +```bash +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +git clone --branch v5.5.3 --recursive \ + https://git.espressif.com.cn/espressif/esp-idf.git \ + "${AI_PASSPORT_IDF_ROOT}" +IDF_GITHUB_ASSETS=dl.espressif.cn/github_assets \ + "${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +The mirror has published the same v5.5.3 tag commit as GitHub +(`b31fcc7a314a44ad992b58f589f7d1d8a4fadff6`), and it hosts the submodule +repositories themselves, so the checkout is identical to the GitHub clone. + +**Gitee mirror plus esp-gitee-tools (fallback).** ```bash export AI_PASSPORT_GITEE_TOOLS_ROOT="${AI_PASSPORT_GITEE_TOOLS_ROOT:-${HOME}/esp/esp-gitee-tools}" @@ -158,6 +202,56 @@ 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. +### Submodule pulls and long waits + +`esp-idf` v5.5.3 bundles more than twenty submodules, and several of them +(`components/esp_wifi/lib`, `components/esp_phy/lib`, +`components/bt/controller/lib_esp32c3_family`) are large prebuilt libraries. +A `git submodule update --init --recursive` can therefore run for minutes with +little output, and agent shells commonly kill it after a fixed wait (for +example a 300000 ms or "exceeding timeout" message) while the process is still +fetching. Check the real state first instead of assuming the mirror failed: + +- Submodule fetching in progress is not a failure until the shell reports an + exit code AND `git status` stays non-clean. Re-run with a longer shell wait + limit, or run the command in the background until it truly exits. +- An interrupted `git submodule update` leaves `modified:` entries under + `components/` (for example `components/esp_wifi/lib`). This is a partial + checkout, not corrupted state. + +Repair in place rather than cloning from scratch: + +```bash +git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init --recursive +# if status still lists submodule paths, update each one by path: +git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init components/ +git -C "${AI_PASSPORT_IDF_ROOT}" status --short +``` + +Keep the checkout clean before running `install.sh`; `idf.py` ignores +uninitialized submodules differently across versions and a partially updated +tree produces confusing compile errors. + +### Offline archives as a last resort + +If every source is unreachable after repeated attempts, the official Espressif +release archive is a complete checkout snapshot — it already contains `.git` +and every v5.5.3 submodule — so unpacking it needs no network or Git operation +after download: + +```bash +curl -fL -o /tmp/esp-idf-v5.5.3.zip \ + https://dl.espressif.com/github_assets/espressif/esp-idf/releases/download/v5.5.3/esp-idf-v5.5.3.zip +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +unzip -q /tmp/esp-idf-v5.5.3.zip -d "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +"${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +The archive expands to a `esp-idf-v5.5.3/` directory (about 1.8 GB). Use the +`dl.espressif.cn` host variant if `dl.espressif.com` is slow; both serve the +same file. Validate the expanded tree with the checksum released next to the +archive before reusing it as an installation base. + ## Activate and verify ESP-IDF Activation applies to the current shell only and is the portable replacement @@ -303,6 +397,8 @@ acceptance path. | `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. | +| Submodule fetch times out or the shell reports an exceeded wait | Confirm `git status` first; if still fetching, rerun with a longer wait limit or in the background, then repair with `git submodule update --init --recursive`. | +| Submodule fetch 404s or retries against a stale mirror | Inspect `git config --global --get-regexp 'url\..*jihulab'`; obtain user approval to clean residue before retrying. | | 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`. | diff --git a/docs/development/engineering/environment-setup.zh_CN.md b/docs/development/engineering/environment-setup.zh_CN.md index f0c532c..feb2ba0 100644 --- a/docs/development/engineering/environment-setup.zh_CN.md +++ b/docs/development/engineering/environment-setup.zh_CN.md @@ -37,13 +37,32 @@ git status --short --branch | 下载内容 | 国际默认线路 | 中国大陆官方线路 | | --- | --- | --- | -| ESP-IDF 源码 | GitHub `espressif/esp-idf` | 乐鑫 Gitee 镜像及 `esp-gitee-tools` | +| ESP-IDF 源码 | GitHub `espressif/esp-idf` | 乐鑫 Git 服务镜像(`git.espressif.com.cn`),或 Gitee 镜像及 `esp-gitee-tools` | | 编译器和工具归档 | GitHub Release Assets | `dl.espressif.cn/github_assets` | | Managed Components | ESP Component Registry 默认存储 | `components-file.espressif.cn` | | 当前项目仓库 | 用户提供的 URL | 用户提供的同仓库镜像 | 不得为当前项目编造镜像地址。用户提供的仓库 URL 不可访问时,应询问已授权的镜像或归档地址。 +乐鑫 Git 服务镜像收录了完整 `esp-idf` 历史以及 v5.5.3 的全部子模块仓库 +(`espressif/esp32-wifi-lib`、`espressif/esp-lwip`、`ThrowTheSwitch/CMock` 等)。 +由于 v5.5.3 的 `.gitmodules` 条目全部是相对 URL,从该镜像克隆父仓库后,每个 +子模块会自动解析到同一镜像,无需单独的镜像改写步骤。从镜像克隆得到的 +checkout 与 GitHub 克隆完全一致:请核对 tag commit 与 +`https://github.com/espressif/esp-idf/releases/tag/v5.5.3` 相同(当前为 +`b31fcc7a314a44ad992b58f589f7d1d8a4fadff6`)。 + +旧版镜像安装脚本有时会在全局 Git 配置中写入按仓库的 `insteadOf` 重定向 +(`jihulab.com/esp-mirror/...`,或 +`git config --global url."https://jihulab.com/esp-mirror/".insteadOf` 总开关)。 +按仓库的条目比任何总开关更具体,会把子模块静默重定向到返回 404 或超时的 +源。当子模块拉取因此失败时,先检查并在用户授权下清理残留,而不是盲目重试: + +```bash +git config --global --get-regexp 'url\..*jihulab' +# 清理需要用户授权:逐条 unset;只删总开关会留下仍会劫持子模块的按仓库条目。 +``` + ## 安装主机依赖 ### Ubuntu 和 Debian @@ -116,7 +135,26 @@ git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init --recursive ### 中国大陆线路 -以下线路使用乐鑫运营的仓库和下载端点,不修改全局 Git 或 pip 配置: +以下线路使用乐鑫运营的仓库和下载端点,不修改全局 Git 或 pip 配置。 + +**乐鑫 Git 服务镜像(首选)。** 直接克隆镜像 URL —— `origin` 就是镜像地址, +`esp-idf` 内部的相对子模块 URL(`../../espressif/...`)会全部解析到同一镜像, +既不需要改写规则,也不需要全局 Git 配置: + +```bash +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +git clone --branch v5.5.3 --recursive \ + https://git.espressif.com.cn/espressif/esp-idf.git \ + "${AI_PASSPORT_IDF_ROOT}" +IDF_GITHUB_ASSETS=dl.espressif.cn/github_assets \ + "${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +镜像发布了与 GitHub 相同的 v5.5.3 tag commit +(`b31fcc7a314a44ad992b58f589f7d1d8a4fadff6`),并且托管了各子模块仓库本身, +因此得到的 checkout 与 GitHub 克隆完全一致。 + +**Gitee 镜像及 esp-gitee-tools(备选)。** ```bash export AI_PASSPORT_GITEE_TOOLS_ROOT="${AI_PASSPORT_GITEE_TOOLS_ROOT:-${HOME}/esp/esp-gitee-tools}" @@ -134,6 +172,50 @@ IDF_GITHUB_ASSETS=dl.espressif.cn/github_assets \ Gitee 辅助工具报告下载中断时,对同一个 checkout 重新执行子模块命令。不得混用不同 ESP-IDF 版本的部分子模块。 +### 子模块拉取与长等待 + +`esp-idf` v5.5.3 内含 20 余个子模块,其中 +(`components/esp_wifi/lib`、`components/esp_phy/lib`、 +`components/bt/controller/lib_esp32c3_family`)是大体积预编译库。 +`git submodule update --init --recursive` 可能长时间没有输出,agent 的 shell +也常按固定等待时间把它杀掉(例如 300000 ms 或 "exceeding timeout"),而此时 +进程还在继续拉取。先检查真实状态,不要贸然认定镜像失败: + +- 只要 shell 还没报告退出码且 `git status` 仍然不干净,子模块拉取就不算失败。 + 用更长的 shell 等待时间重试,或后台执行直到真正退出。 +- `git submodule update` 被中断后,`components/` 下会出现 `modified:` 条目 + (例如 `components/esp_wifi/lib`)。这是部分 checkout,不是损坏状态。 + +原地修复,而不是重新克隆: + +```bash +git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init --recursive +# 若 status 仍列出子模块路径,按路径逐个更新: +git -C "${AI_PASSPORT_IDF_ROOT}" submodule update --init components/ +git -C "${AI_PASSPORT_IDF_ROOT}" status --short +``` + +运行 `install.sh` 前保持 checkout 干净;各版本 `idf.py` 对未初始化子模块的 +处理不同,部分更新的目录树会产生难以定位的编译错误。 + +### 离线压缩包兜底 + +重复尝试后所有源都不可达时,乐鑫官方 release 归档是一次完整 checkout 快照 +——已包含 `.git` 与 v5.5.3 的全部子模块——下载后解压即用,不需要任何网络或 +Git 操作: + +```bash +curl -fL -o /tmp/esp-idf-v5.5.3.zip \ + https://dl.espressif.com/github_assets/espressif/esp-idf/releases/download/v5.5.3/esp-idf-v5.5.3.zip +mkdir -p "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +unzip -q /tmp/esp-idf-v5.5.3.zip -d "$(dirname "${AI_PASSPORT_IDF_ROOT}")" +"${AI_PASSPORT_IDF_ROOT}/install.sh" esp32c3 +``` + +归档解压后为 `esp-idf-v5.5.3/` 目录(约 1.8 GB)。若 `dl.espressif.com` 较慢, +可使用 `dl.espressif.cn` 主机变体,两者提供同一文件。复用该目录作为安装基础 +前,用归档旁发布的校验和验证解压结果。 + ## 激活并核验 ESP-IDF 激活只影响当前 shell,是个人化 alias 的通用替代方案: @@ -257,6 +339,8 @@ idf.py -p monitor | 找不到 `idf.py` | 激活所选安装的 `export.sh`,不得猜测个人 alias。 | | ESP-IDF 版本错误 | 停止并并行激活/安装 v5.5.3。 | | GitHub 源码或工具下载慢 | 切换到本文的乐鑫中国大陆线路。 | +| 子模块拉取超时或 shell 报告等待超限 | 先确认 `git status`;若仍在拉取,用更长等待时间或后台重试,再用 `git submodule update --init --recursive` 修复。 | +| 子模块拉取 404 或反复回到过期镜像 | 检查 `git config --global --get-regexp 'url\..*jihulab'`;清理残留前先获得用户授权。 | | 中国大陆组件下载慢 | 在当前终端设置 `IDF_COMPONENT_STORAGE_URL`。 | | 组件下载失败 | 检查网络、代理、DNS 和证书,不得通过关闭 TLS 校验绕过。 | | 配置缺少已跟踪 defaults | 保留有意配置,再执行 `idf.py set-target esp32c3`。 |