ESP32例程搭建
约 410 字大约 1 分钟
2026-08-03
例程搭建
安装idf
- 安装准备:
sudo apt update
sudo apt-get install git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0- 获取esp-idf
mkdir -p ~/Download/mysoft/esp
cd ~/Download/mysoft/esp
export http_proxy=http://ip:port //挂代理
export https_proxy=http://ip:port
git clone -b v5.5.2 --recursive https://github.com/espressif/esp-idf.git- 设置工具
cd ~/Download/mysoft/esp/esp-idf
./install.sh esp32s3 //或./install.sh all
. ./export.sh //设置环境变量,默认工具IDF_TOOLS_PATH在$HOME/.espressif/- 设置环境变量
. $HOME/Download/mysoft/esp/esp-idf/export.sh- 设置一键激活 ESP-IDF 环境
vim ~/.bashrc //添加alias get_idf='. $HOME/esp/esp-idf/export.sh'
source ~/.bashrc //或重启终端窗口- 验证是否成功
get_idf //是否正确激活ESP-IDF环境
idf.py --version //是否正确输出ESP-IDF V5.5.2- 增加串口权限,ESP32默认串口为ttyACM*(永久生效)
sudo usermod -a -G dialout $USER //设置完成,需要重启虚拟机- ubuntu下,vscode配置安装完ESP-IDF extension后,推荐增加的设置
sudo cp --update=none /home/zhang/.espressif/tools/openocd-esp32/v0.12.0-esp32-20250707/openocd-esp32/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d异常处理
- 不再弹出配置提示。
- 处理:下方文件内容"idf.hasWalkthroughBeenShown": true为true,删除后保存重进vscode即可(确保最后一项没有',')
zhang@zhang-VMware20-1:~$ cat .config/Code/User/settings.json
{
"fittencode.selection.showCodeLens": false,
"editor.mouseWheelScrollSensitivity": 2,
"commentTranslate.ignore": [
{
"languageId": "javascript,typescript,javascriptreact,typescriptreact",
"regular": "[\\*\\s]+"
},
{
"languageId": "dart",
"regular": "[\\s|/]+"
}
],
"workbench.settings.applyToAllProfiles": [
],
"workbench.iconTheme": "vscode-icons",
"workbench.colorTheme": "One Dark Pro Night Flat",
"fittencode.languagePreference.displayPreference": "zh-cn",
"fittencode.languagePreference.commentPreference": "zh-cn",
"python.defaultInterpreterPath": "/home/zhang/serial_bridge_venv/bin/python",
"idf.hasWalkthroughBeenShown": true
}- vscode的ESP-IDF插件,最新为2.0.x版本,默认为EIM的形式安装,不再支持旧方式的路径添加,先安装1.11.1(非2.0.x版本以上),路径添加完,设置完,再点击自动更新去再升级
