(一)资料
1-官方说明文档
https://docs.espressif.com/projects/esp-idf/zh_CN/release-v4.2/esp32/get-started/index.html
2-gitee开源esp-idf代码:
https://gitee.com/EspressifSystems/esp-idf/tree/release%2Fv4.2/
(二)克隆esp-idf
git clone -b release/v4.2 --recursive https://gitee.com/espressif/esp-idf.git
(三)安装依赖
1-
sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util
2-官方依赖只是Ubuntu的apt依赖,然而还有一堆python依赖
到上一步克隆的代码目录下,找到 requirements.txt 执行:
python3 -m pip install -r requirements.txt
会出现:
ERROR: Exception:
Traceback (most recent call last):File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _mainstatus = self.run(options, args)File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 325, in runself.populate_requirement_set(File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 266, in populate_requirement_setfor req_to_add in parse_requirements(File "/usr/lib/python3/dist-packages/pip/_internal/req/req_file.py", line 138, in parse_requirementsreq = handle_line(File "/usr/lib/python3/dist-packages/pip/_internal/req/req_file.py", line 201, in handle_linereturn install_req_from_line(File "/usr/lib/python3/dist-packages/pip/_internal/req/constructors.py", line 397, in install_req_from_linereturn InstallRequirement(File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 140, in __init__self.local_file_path = self.link.file_pathFile "/usr/lib/python3/dist-packages/pip/_internal/models/link.py", line 105, in file_pathreturn url_to_path(self.url)File "/usr/lib/python3/dist-packages/pip/_internal/utils/urls.py", line 48, in url_to_pathraise ValueError(
ValueError: non-local file URIs are not supported on this platform: 'file://${IDF_PATH}/tools/kconfig_new/esp-windows-curses'
3-这里要export路径:
export IDF_PATH=/home/ddttd/sorfware/esp/esp-idf-v4.2
4-再执行,又有问题
ERROR: Could not find a version that satisfies the requirement pyparsing<2.4.0,>=2.0.3 (from -r requirements.txt (line 12)) (from versions: none)
ERROR: No matching distribution found for pyparsing<2.4.0,>=2.0.3 (from -r requirements.txt (line 12))
但实际上这个错误很奇怪,看下去。
我首先注释掉 requirements.txt 里面的:pyparsing
#pyparsing>=2.0.3,<2.4.0
然后就能安装了:
Downloading pyparsing-2.3.1-py2.py3-none-any.whl (61 kB)|████████████████████████████████| 61 kB 72 kB/s
Collecting pyelftools>=0.22
实际依然安装了这个依赖,而且符合 pyparsing>=2.0.3,<2.4.0 ,可能是pip抽风了。、
5-gevent-1.5.0-cp38-cp38-manylinux2010_x86_64.whl下不来,这个就见仁见智了
一般都是下载超时,这种解决方法也不少,最好的是去清华镜像站下,然后手动安装:
https://pypi.tuna.tsinghua.edu.cn/packages/e5/85/2f80692161f463ffd05e6d1223ef789eb566eec274697c6dae9d19ce65a4/gevent-1.5.0-cp38-cp38-manylinux2010_x86_64.whl#sha256=2f33b4f2d55b562d839e93e2355d7f9a6947a9c68e3044eab17a086a725601e6
pip3 install gevent-1.5.0-cp38-cp38-manylinux2010_x86_64.whl
手动安装参考:https://blog.csdn.net/qq_40925385/article/details/83753598
不用考虑科学了,科学了也不可能直接下下来的。
还有一种更加一劳永逸的方法——给pip换源:
https://blog.csdn.net/qq_14994573/article/details/80934201
6-后面编译的时候会遇到非常莫名其妙的事情
./export.sh
能够执行。
但
idf.py build
会提示你 pyparsing 版本不对
你执行sudo pip3 install pyparsing 会显示已经安装,但安装的不是所要求的<2.4.0,而是2.4.6.
但你继续执行 ./install.sh,他依然给你显示成功安装了2.3.1.
但你再 ./export.sh 也依然是2.4.6.
如果再执行 sudo pip3 install pyparsing==2.3.1 ,则会提示有高版本已经安装,不会执行
如果执行 sudo pip3 uninstall pyparsing则会显示无法卸载。
这时候需要强制安装:
这里最好先更新下pip软件源。
执行
sudo pip install --ignore-installed pyparsing==2.3.1
成功了先别高兴,再执行./export.sh甚至会显示软件版本不对。
Setting IDF_PATH to '/home/tinnu/sorfware/esp/esp-idf-v4.2'
Adding ESP-IDF tools to PATH...
Not using an unsupported version of tool xtensa-esp32-elf found in PATH: 1.22.0-61-gab8375a-5.2.0.
Using Python interpreter in /home/tinnu/.espressif/python_env/idf4.2_py3.8_env/bin/python
Checking if Python packages are up to date...
The following Python requirements are not satisfied:
pyparsing>=2.0.3,<2.4.0
To install the missing packages, please run "/home/tinnu/sorfware/esp/esp-idf-v4.2/install.sh"
Diagnostic information:
IDF_PYTHON_ENV_PATH: /home/tinnu/.espressif/python_env/idf4.2_py3.8_env
Python interpreter used: /home/tinnu/.espressif/python_env/idf4.2_py3.8_env/bin/python
这时候要再执行一次 ./install.sh
然后就可以了
(四)安装
再git目录下,执行
./install.sh
再在git目录下执行
./export.sh
(五)编译
拷贝git目录下example下面某一个工程,必须是在执行过./export.sh的控制台下!
执行
idf.py set-target esp32
idf.py menuconfig
idf.py build