ESP32 基于乐鑫 官网SDK ESP-IDF V4.2

下载SDK

下载后创建目录~/ESP/ESP-IDF

ubuntu16.04

安装依赖

sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0

设置乐鑫服务器下载

cd ~/esp/esp-idf export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"

执行安装脚本,自动安装工具

cd ~/esp/esp-idf ./install.sh

出现报错

Installing virtualenv /usr/bin/python: No module named pip

下载脚本

https://bootstrap.pypa.io/pip/2.7/get-pip.py

执行脚本

python get-pip.py

重新执行安装工具步骤

./install.sh

报错

ERROR: Could not find a version that satisfies the requirement bidict>=0.21.0 (from python-socketio>=1.6.1->Flask-SocketIO<3.0,>=2.9->gdbgui==0.13.2.0->-r /home/kni/esp/esp-idf/requirements.txt (line 14)) (from versions: 0.1.5, 0.2.1, 0.3.0, 0.3.1, 0.9.0rc0, 0.9.0.post1, 0.10.0, 0.10.0.post1, 0.11.0, 0.12.0.post1, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.14.2, 0.15.0.dev0, 0.15.0.dev1, 0.15.0rc1, 0.15.0, 0.16.0, 0.17.0, 0.17.1, 0.17.2, 0.17.3, 0.17.4, 0.17.5, 0.18.0, 0.18.1, 0.18.2, 0.18.3, 0.18.4) ERROR: No matching distribution found for bidict>=0.21.0 (from python-socketio>=1.6.1->Flask-SocketIO<3.0,>=2.9->gdbgui==0.13.2.0->-r /home/kni/esp/esp-idf/requirements.txt (line 14))

解决方案

在requirements.txt中手动添加如下

add manually the following line into the requirements.txt: python-socketio<5; python_version<="2.7"

重新执行安装工具步骤

./install.sh

成功

设置环境变量

. $HOME/esp/esp-idf/export.sh

此后每重新打开一次窗口都需执行上述命令

创建hello world工程,即从示例文件夹中将源文件拷贝出来

cd ~/esp cp -r $IDF_PATH/examples/get-started/hello_world .

进入工程目录,使用idf.py脚本完成以下步骤,设置目标芯片,打开menuconfig,编译工程

cd ~/esp/hello_world idf.py set-target esp32 idf.py menuconfig

idf.py build

使用idf.py脚本烧录或者烧录并监视

idf.py -p PORT [-b BAUD] flash

idf.py -p PORT flash monitor

注意端口名称和端口读写权限。

经验分享 程序员 微信小程序 职场和发展