主要是拉取 esp-idf
, 项目管理使用官方的工具 idf.py
# 拉取 esp-idf
mkdir -p ~/esp
cd ~/esp
git clone -b v5.4.1 --recursive <https://github.com/espressif/esp-idf.git>
# 安装对应芯片的工具链
cd esp-idf
./install.sh esp32c3
完成工具链后, 每次想使用开发环境需要激活 source
# 这是 fish 的脚本
. /home/cyang/esp/esp-idf/export.fish
我这里在 config.fish
添加配置,通过 startidf
快速配置环境, 这只会修改当前活动 shell 的环境变量, 并不会污染系统环境变量。
alias startidf='. /home/cyang/esp/esp-idf/export.fish'
# 启用 idf 环境
startidf
# 新建项目 - esp32c3
idf.py create hello
cd hello
idf.py set-target esp32c3
# 编译
idf.py build