文章目录
Ubuntu子系统下ESP32的编译环境
安装Ubuntu18.04
在开启和关闭windows功能中打开linux子系统选项
在windows stroe中安装Ubuntu18.04
新建用户名和密码
更改软件源
备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
修改
sudo vim /etc/apt/sources.list
将原有源注释或删除,添加以下源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
更新源
sudo apt-get update
sudo apt-get upgrade
设置ESP-IDF工具链
安装编译所需要的依赖库
sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future python-pyparsing python-pyelftools
获取工具链
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
解压
mkdir -p ~/esp
cd ~/esp
tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
添加工具链到环境变量
vim ~/.profile
添加
export PATH="$HOME/esp/xtensa-esp32-elf/bin:$PATH"
更新环境变量
source ~/.profile
获取ESP-IDF
cd esp
git clone --recursive https://github.com/espressif/esp-idf.git
注意千万不要少了–recursive参数,否则无法获取子模块代码。
将IDF添加到环境变量
vim ~/.profile
export IDF_PATH="$HOME/esp/esp-idf"
编译ESP-IDF
安装python库
python2.7 -m pip install --user -r $IDF_PATH/requirements.txt
复制Demo工程
cp -r $IDF_PATH/examples/get-started/hello_world .
配置串口
make menuconfig
编译
make
烧录
make flash
烧录时,出现以下信息时,需要按下BOOT按键,然后按RESET按键。
查看监视器
make monitor