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: routes: - to: default via: 192.168.4.1 version: 2 $ sudo netplan apply $ ip addr show ens33 $ ip route show $ reboot 4. 使用SecureCRT使用SSH远程连接虚拟机的ubuntu 5. 安装各种必要的工具 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 6. 新建esp32目录并进入 $ mkdir esp32 $ cd esp32 7. 拉取gitee工具(原因是从官方下载大概率会失败) $ git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git 8. 执行gitee工具切换镜像脚本 $ cd esp-gitee-tools $ ./jihu-mirror.sh set 9. 拉取esp-idf源码 $ cd .. $ git clone --recursive https://github.com/espressif/esp-idf.git 10. 切换esp-idf版本分支到v5.3 $ cd esp-idf $ git checkout v5.3 $ git submodule update --init --recursive 如果提示失败或有错误试下这句:../esp-gitee-tools/submodule-update.sh 11. 更换pip源 $ pip config set global.index-url http://mirrors.aliyun.com/pypi/simple $ pip config set global.trusted-host mirrors.aliyun.com 12. 安装编译工具 $ ../esp-gitee-tools/install.sh 13. 设置环境变量并将环境变量放到.bashrc中(这样下次启动后上一步设置的环境变量会重新加载) $ source export.sh $ echo "source ~/esp32/esp-idf/export.sh" ~/.bashrc 14. 设置USB串口权限(解决下载代码时报USB串口权限问题) $ sudo usermod -aG dialout usrname usrname需要换成你的用户名 15. 重启 16. windows安装VSCODE,并安装如下插件 17. 通过以上插件远程连接ubuntu 这样就可以建立远程连接了,代码就可以在vscode进行查看和更改,但是我们会发现每次都需要输入密码,我们通过如下方式解决 解决使用VsCode远程ssh连接虚拟机ubuntu需要重复输入密码 18. VSCode中为远程主机安装插件 19. 按照上图依次安装如下插件 20. 进行插件配置 c/c++插件 改ESP-IDF配置 键盘同时按下ctl+shift+p,在弹出的对话框输入如下,这样我们就可以任意查看和跳转代码位置了。 21. 建立第一个工程 使用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