[ESP32][ESP-IDF](一)Ubuntu开发环境搭建

目录

一、准备工作

二、搭建开发环境

三、编译下载测试


一、准备工作

1、虚拟机VMware12(其他版本也行)安装操作系统Ubuntu14.04(其他版本也行),安装参考网络上教程。当然有条件的话也可以是电脑直接安装Ubuntu。

2、更换到国内比较好的快速更新源。下面的软件源对应的是Ubuntu14.04版本,其他版本请参看链接:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

  • sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  • sudo gedit /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse

3、更新源。

  • sudo apt-get update
  • sudo apt-get upgrade

二、搭建开发环境

1、创建并进入esp目录。也可以使用其它目录,但是需要注意调整相应的指令。

  • mkdir -p ~/esp
  • cd ~/esp

2、下载并解压esp-idf v3.3.1的工具链到当前esp目录。
64-bit Linux:

  • wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
  • tar -xzf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

32-bit Linux:

  • wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-80-g6c4433a-5.2.0.tar.gz
  • tar -xzf xtensa-esp32-elf-linux32-1.22.0-80-g6c4433a-5.2.0.tar.gz

3、安装git。

  • sudo apt-get install git

4、下载esp-idf v3.3.1到当前esp目录。

  • git clone -b v3.3.1 --recursive https://github.com/espressif/esp-idf.git

5、添加环境变量(对所有用户有效)。

  • sudo gedit /etc/profile
export PATH="$HOME/esp/xtensa-esp32-elf/bin:$PATH"
export IDF_PATH=~/esp/esp-idf

6、使新添加的环境变量立即生效。

  • source /etc/profile

7、查看是否生效。

  • echo $PATH
  • echo $IDF_PATH

8、安装python,至少3.5版本。

  • sudo apt-get install python3.5

9、安装pip。

  • curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  • python3.5 get-pip.py

10、链接python到python3.5。

  • sudo rm -rf /usr/bin/python
  • sudo ln -s /usr/bin/python3.5 /usr/bin/python
  • python --version

11、安装esp-idf依赖的python软件包。

  • python3.5 -m pip install --user -r $IDF_PATH/requirements.txt

三、编译下载测试

1、进入hello_world例程。

  • cd $IDF_PATH/examples/get-started/hello_world/

2、安装libncurses5-dev flex bison gperf。

  • sudo apt-get install libncurses5-dev flex bison gperf

3、配置。

  • make menuconfig

4、编译。

  • make all

5、修改权限。某些 Linux 版本可能在烧写 ESP32 时会出现 Failed to open port /dev/ttyUSB0 错误消息。可以通过将当前用户添加到拨出组来解决。注意:命令执行完要重新登录后才生效。

  • sudo usermod -a -G dialout $USER

6、下载并在下载完成启动后监听串口信息。

  • make flash monitor

7、程序运行效果。

[ESP32][ESP-IDF](一)Ubuntu开发环境搭建_第1张图片

 

开发环境搭建参考资料:ESP-IDF 编程指南-快速入门

https://docs.espressif.com/projects/esp-idf/zh_CN/v3.3.1/get-started/index.html

你可能感兴趣的:(ESP32开发)