docs(engineering): 环境引导补充乐鑫镜像与子模块排障经验

- 新增乐鑫 Git 服务镜像(git.espressif.com.cn)作为中国大陆首选线路
- 记录子模块长等待/超时处理与原地修复方法
- 提示按仓库 Jihulab insteadOf 残留检查与清理
- 将官方离线压缩包列为最后兜底方案
- 经验来自 esp-mosaico/esp-mosaico-vibe,双语同步更新
This commit is contained in:
Shinku committed 2026-09-09 10:03:33 +08:00
1 parent df3990726e
commit f7ac6db5f9
4 files changed
+189 -5

No files matched your search

+2
View File
@@ -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
+2
View File
@@ -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 对合并镜像结构、
@@ -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/<path-from-status>
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`. |
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff. Show more