Ubuntu18.04 上通过 jihu 镜像完成 ESP-IDF 编译环境搭建流程

为了解决国内开发者从 github 克隆 esp 相关仓库慢的问题,已将 esp-idf 和部分重要仓库及其关联的子模块镜像到了 jihu,这些仓库将自动从原始仓库进行同步。此篇博客用来阐述 Ubuntu18.04 上通过 jihu 镜像完成 ESP-IDF 编译环境搭建流程。

注:乐鑫对应的 jihu 镜像仓库为 esp-mirror espressif 仓库

1 环境搭建前提

1.1 安装编译 ESP-IDF 需要的软件包:
bash 复制代码
sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util
1.2 安装 Python 3.8
bash 复制代码
sudo apt-get install python3.8-venv python3.8-dev
1.3 选择 python3 环境:
bash 复制代码
sudo update-alternatives --config python
1.4 安装 install pip

使用 pip 安装以下 python 软件包

bash 复制代码
python -m pip install pyyaml xlrd

python -m pip --version
1.5 安装 curses
bash 复制代码
sudo apt-get install libncurses5-dev

2 创建一个空的文件夹来存放 esp-idf SDK 和设置 jihu 镜像环境所需的 esp-gitee-tools 工具

bash 复制代码
cd esp

mkdir jihu

cd jihu

3 克隆 esp-gitee-tools 工具

bash 复制代码
git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git

4 运行 jihu-mirror.sh 脚本,设置 jihu 镜像环境

c 复制代码
./jihu-mirror.sh set

运行此指令后,以后克隆任意 Github espressifesp-mirror espressif 下的仓库和组件都会自动镜像 URL 链接到 jihu 链接上。例如:


当我们使用命令 git clone https://github.com/espressif/esp-idf 时,默认的 URL https://github.com/espressif/esp-idf 将被自动替换成 https://jihulab.com/esp-mirror/espressif/esp-idf

当然,也可以使用如下恢复命令,取消已经设置的 jihu 镜像环境,从而不使用镜像的 URL。

bash 复制代码
./jihu-mirror.sh unset

5 通过 jihu 镜像环境克隆 esp-idf

bash 复制代码
cd ..
cd jihu
git clone -b v5.1.1 https://jihulab.com/esp-mirror/espressif/esp-idf.git

可以直接在esp-mirror espressif 下获取仓库链接,也可以直接使用 Github espressif 下的仓库链接。

6 更新 esp-idf 子仓库

bash 复制代码
cd esp-idf                                              

git submodule update --init --recursive

7 设置 esp-idf 的环境变量和运行 esp-idf 工具链

bash 复制代码
export IDF_PATH=$(pwd)

./install.sh 

. ./export.sh

8 编译 esp-idf 下的工程

bash 复制代码
cd examples/get-started/hello_world

idf.py set-target esp32s3           //选择 esp32s3 的芯片环境

idf.py menuconfig                  

idf.py build

idf.py flash monitor
相关推荐
christine-rr38 分钟前
征文投稿:如何写一份实用的技术文档?——以软件配置为例
运维·前端·网络·数据库·软件构建
Lw老王要学习1 小时前
VScode 使用 git 提交数据到指定库的完整指南
windows·git·vscode
去旅行、在路上1 小时前
Git & Svn
git·svn
abcnull2 小时前
github中main与master,master无法合并到main
git·github
养意8 小时前
git提交代码和解决冲突修复bug
git·bug
码农黛兮_4621 小时前
Git 常用命令大全
git
一弓虽21 小时前
git 学习
git·学习
疯狂的沙粒1 天前
如何通过git命令查看项目连接的仓库地址?
大数据·git·elasticsearch
qq_254617771 天前
Gerrit+repo管理git仓库,如果本地有新分支不能执行repo sync来同步远程所有修改,会报错
git
π大星星️1 天前
Git分布式版本控制工具
分布式·git