docs(engineering): 环境引导补充乐鑫镜像与子模块排障经验
- 新增乐鑫 Git 服务镜像(git.espressif.com.cn)作为中国大陆首选线路 - 记录子模块长等待/超时处理与原地修复方法 - 提示按仓库 Jihulab insteadOf 残留检查与清理 - 将官方离线压缩包列为最后兜底方案 - 经验来自 esp-mosaico/esp-mosaico-vibe,双语同步更新
This commit is contained in:
1 parent
df3990726e
commit
f7ac6db5f9
4 files changed
+189
-5
No files matched your search
@@ -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`. |
|
||||
|
||||
@@ -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/<status-中的路径>
|
||||
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 <port> 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`。 |
|
||||
|
||||
Reference in new issue
Block a user