企业项目管理、ORK、研发管理与敏捷开发工具平台

网站首页 > 精选文章 正文

0. esp32开发之ubuntu环境搭建_esp8266 linux开发环境搭建

wudianyun 2025-09-12 04:18:15 精选文章 3 ℃
  1. 在Ubuntu官网下载Ubuntu server 20.04版本https://releases.ubuntu.com/20.04.6/
  2. 在vmware下安装Ubuntu
  3. 改Ubuntu静态IP
$ sudo vi /etc/netplan/00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
renderer: networkd
ethernets:
ens33:
# dhcp4: true
addresses:
- 192.168.4.251/24
nameservers:
addresses: [4.2.2.2,8.8.8.8]
routes:
- to: default
via: 192.168.4.1
version: 2

$ sudo netplan apply
$ ip addr show ens33
$ ip route show
$ reboot

  1. 使用SecureCRT使用SSH远程连接虚拟机的ubuntu
  2. 安装各种必要的工具
sudo apt-get install git wget flex bison gperf python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 net-tools
  1. 新建esp32目录并进入
$ mkdir esp32
$ cd esp32
  1. 拉取gitee工具(原因是从官方下载大概率会失败)
$ git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git
  1. 执行gitee工具切换镜像脚本
$ cd esp-gitee-tools
$ ./jihu-mirror.sh set
  1. 拉取esp-idf源码
$ cd ..
$ git clone --recursive https://github.com/espressif/esp-idf.git
  1. 切换esp-idf版本分支到v5.2
$ cd esp-idf
$ git checkout v5.2
$ git submodule update --init --recursive
如果提示失败或有错误试下这句:../esp-gitee-tools/submodule-update.sh
  1. 更换pip源
$ pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
$ pip config set global.trusted-host mirrors.aliyun.com
  1. 安装编译工具
$ ../esp-gitee-tools/install.sh
  1. 设置环境变量并将环境变量放到.bashrc中(这样下次启动后上一步设置的环境变量会重新加载)
$ source export.sh
$ echo "source ~/esp32/esp-idf/export.sh" >> ~/.bashrc
  1. 编译
$ cd esp32-board/helloworld
$ idf.py build
  1. 设置USB串口权限(解决下载代码时报USB串口权限问题)
$ sudo usermod -aG dialout usrname  usrname需要换成你的用户名
  1. 重启
  2. windows安装VSCODE,并安装如下插件
  1. 通过以上插件远程连接ubuntu

这样就可以建立远程连接了,代码就可以在vscode进行查看和更改

  1. VSCode中为远程主机安装插件

按照上图依次安装如下插件

  1. 进行插件配置
  • c/c++插件
  • 改ESP-IDF配置

键盘同时按下ctl+shift+p,在弹出的对话框输入如下,这样我们就可以任意查看和跳转代码位置了。

  1. 建立第一个工程
  • 使用vscode远程连接虚拟机,在终端窗口进行操作
  • 创建存放工程的目录并进入目录
mkdir esp32-prj
cd esp32-prj
  • 使用命令创建工程
idf.py create-project helloworld
  • 进入目录更改目标芯片,一般默认为esp32
idf.py set-target esp32-s3
  • 进行第一次编译
idf.py build
  • 打开工程
  • 如图操作,这样才可以方便的跳转和查看代码,每个新的工程都需要执行一次
  • 编译代码
  • 烧录,先连接开发板,并保证开发板是连接到了虚拟机
idf.py flash
  • 监视开发板执行情况
idf.py monitor

退出监控使用CTL+]组合键

  • 烧录指令可以和监控指令可以放在一起执行
idf.py flash monitor
最近发表
标签列表