本机环境:ubuntu16.04
一、搭建ESP32编译环境的步骤:
1、建源码工作目录
mkdir ~/esp32
cd ~/esp32
2、拉代码
git clone --recursive https://github.com/espressif/esp-idf.git
3、设置工具
cd ~/esp/esp-idf
./install.sh
4、执行命令
. ./export.sh
5、开始一个简单范例
cd ~/esp
cp -r $IDF_PATH/examples/get-started/hello_world .
6、usb口连接板卡、查询设备
lsusb
7、检查串口名称
bo@bo-HP-ZBook-15-G3:~/workspace/esp32$ ls /dev/ttyUSB0
/dev/ttyUSB0
8、编译工程
cd ~/esp/hello_world
idf.py menuconfig
idf.py build
9、烧录
idf.py -p PORT [-b BAUD] flash
二、搭建ESP32-Cam开发环境
1、下载esp-who
cd ~/esp
git clone --recursive https://github.com/espressif/esp-who.git
2、下载esp-idf v3.3
wget https://github.com/espressif/esp-idf/releases/download/v3.3/esp-idf-v3.3.zip
unzip esp-idf-v3.3.zip
mv esp-idf-v3.3 esp-idf
在 ~/.profile 添加环境变量
export IDF_PATH=~/workspace/esp32/esp-idf
export PATH="$IDF_PATH/tools:$PATH"
3、下载工具链
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
PATH="$HOME/bin:$HOME/.local/bin:$PATH:/home/bo/workspace/esp32/xtensa-esp32-elf/bin"
4、编译
cd /ext_sys/1~5_mp3_player/esp-who/examples/single_chip/camera_web_server/
source ~/.profile
4.1、配置编译选项
idf.py menuconfig
.→ Camera Web Server → Camera Pins
选择 (X) ESP_EYE DevKit
→ Component config → Camera configuration
仅选择
[*] OV2640 Support
4.2、修改pin定义
代码中的一个坑(代码分支中的任何pin定义与https://docs.m5stack.com/#/en/unit/esp32cam中的pinmap都不一致),需要修改文件中的pin
vim /ext_sys/1~5_mp3_player/esp-who/examples/single_chip/camera_web_server/main/include/app_camera.h
的分支#elif CONFIG_CAMERA_MODEL_ESP_EYE
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 25
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 17
#define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
4.3、编译
idf.py build
4.4、烧录
idf.py -p /dev/ttyUSB0 flash
4.6、uart打印看log
idf.py -p /dev/ttyUSB0 monitor
参考:
1、快速入门 ESP-IDF编程指南
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/get-started/index.html
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/get-started/index.html#esp-idf
2、esp-who下载,和esp-idf v3.3下载
https://github.com/espressif/esp-who
https://github.com/espressif/esp-idf/releases/v3.3