ESP32 开发环境搭建

考虑到开发环境的可复制性,不用每次都重新进行环境搭建,以及整体环境大小的最优化,使用Docker环境搭建,在此记录下搭建过程,开发环境基于Debain进行搭建。

Debian 基础环境搭建

  1. 首先在Docker中获取Debian环境,并运行到终端目录中。

    Docker的安装和Debian环境的获取参见Docker安装和使用。

  2. 进入终端后,由于Debian只有些基础组件,因此需要对系统进行些配置,首先安装nano编辑器,修改下载路径为国内源。

    1
    2
    3
    nano /etc/apt/sources.list

    https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free deb-src
  3. 安装环境相关软件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    nano      // 文本编辑器 vi vim 都可以
    net-tools // 网路相关工具 例如ifconfig
    ssh // ssh工具 用于后续远程连接以及VScode远程调试

    ssh配置,修改后重启ssh服务
    // 编辑SSH配置文件
    nano /etc/ssh/sshd_config
    // 打开22端口
    Port 22
    // 将PermitRootLogin的值改为yes
    PermitRootLogin yes

    // 重启ssh
    /etc/init.d/ssh restart
    Restarting OpenBSD Secure Shell server: sshd.

ESP-IDF 环境搭建

  1. 参考官方环境搭建连接,注意开发环境版本说明,本次安装使用最新稳定版V4.4.1

    快速入门 - ESP32 - — ESP-IDF 编程指南 v4.4.1 文档 (espressif.com)

    ESP-IDF 版本简介 - ESP32 - — ESP-IDF 编程指南 v4.4.1 文档 (espressif.com)

  2. 在克隆主程序过程中,由于是从外网服务下载,有时会出现某些子模块下载失败的情况,此时可以在esp_idf目录下使用git submodule update --init补充没有成功下载的子模块。

  3. 安装时建议只安装使用到的芯片,若all全部安装整体镜像会非常大,违背了轻量化的原则。