原文链接:https://blog.csdn.net/weixin_42133260/article/details/90600041
前提: 在电脑上已安装好ubutnu系统 (我是直接安装的Ubuntu18.04,不是虚拟机) VS code 软件下载并安装好 准备工作: 1.在用户目录的下创建 esp目录,方便统一 工具链、ESP-IDF ESP-ADF 和 开发程序 . 如果创建的目录不同后续的命令也需要相应的修改
~$ mkdir ~/esp ~$ cd esp/2.安装基础工具:
sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future3.下载ESP32 工具链,大家可以windows上下载,在复制到虚拟下的~/esp/目录下
64-bit Linux:https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz 32-bit Linux:https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-80-g6c4433a-5.2.0.tar.gz
4.将工具链解压到 ~/esp/xtensa-esp32-elf/ 目录
~/esp$ tar -xzf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz5.增加环境变量,需要在 ~/.profile 文件中更新环境变量 PATH
~/esp$ sudo vim ~/.profile然后在打开的文件里添加 export PATH="$HOME/esp/xtensa-esp32-elf/bin:$PATH" 修改后的文件大概像下面这样
# the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 #esp32-tools export PATH="$HOME/esp/xtensa-esp32-elf/bin:$PATH" # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then ."$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi重启执行下面指令测试是否设置成功
~$ printenv PATH如果成功,则会在显示的字符串中出现 $HOME/esp/xtensa-esp32-elf/bin 其中$HOME=/home/用户名
1.下载IDF仓库
~/esp$ git clone --recursive https://github.com/espressif/esp-idf.git2.设置环境变量(和上面一样,完成后重启检查一下)
export IDF_PATH=~/esp/esp-idf新建一个 project 文件夹,用于存放自己编写的工程文件
mkdir ~/esp/project(具体路径按实际路径填写)
{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/esp32/sources/esp-idf/**", "/esp32/crossTools/xtensa-esp32-elf/xtensa-esp32-elf/**" ], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "clang-x64" } ], "version": 4 }最后尝试编译一下IDF中提供的例程 hello-world 如果报关于工具链相关的错误,根据提示重新安装对应的工具链.