esp32 centos开发环境搭建
系统:CentOS Linux release 7.8.2003 (Core)
chip:esp32c3
前言
重点:之前是在windows下工作的,因为编译烧录都比较方便。最近因为各种git的不稳定原因,导致无法正确编译和运行,所以才打算在海外搞个linux环境,这样就可以解决git相关的困扰。
环境安装
官方指导参考:https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/get-started/index.html#id4
-
进入目标目录, 下载工具:
git clone --recursive https://github.com/espressif/esp-idf.git
-
设置工具
./install.sh
遇到的问题:
1)python版本问题
ESP-IDF supports Python 3.6 or newer but you are using Python 2.7.5. Please upgrade your installation as described in the documentation.
需要升级python,请参考网上文章,通过最新源码更新python。
2)
问题ModuleNotFoundError: No module named '_ctypes'
解决:
yum install libffi-devel -y
然后需要重新安装python3
make clean
./configure
make&&make install
- 设置环境变量
./export.sh
遇到的问题:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'click'
env: idf.py: No such file or directory
解决:
python -m pip install click
由于是vps,所以 export.sh 实际上不会成功,一直卡死在 libusb-1.0 的错误中。所以只能手动设置环境变量,需要设置IDF_PYTHON_ENV_PATH 和PATH:
export PATH=/data/develop/esp/esp-idf/tools:$PATH
export PATH=/root/.espressif/python_env/idf4.4_py3.9_env/bin:$PATH
export IDF_PYTHON_ENV_PATH=/root/.espressif/python_env/idf4.4_py3.9_env
注意IDF_PYTHON_ENV_PATH一定要设置成 espressif的python路径,否则会一直提醒你执行 install.sh
验证idf.py环境ok:
idf.py --version
Setting IDF_PATH environment variable: /data/develop/esp/esp-idf
ESP-IDF v4.4-dev-1849-g8e3e65a-dirty
编译
找一个例子测试下
idf.py set-target esp32c3
idf.py build
出现错误:
- CMake 3.5 or higher is required. You are running version 2.8.12.2
升级cmake:
wget https://github.com/Kitware/CMake/releases/download/v3.21.0-rc2/cmake-3.21.0-rc2.tar.gz
tar zxvf cmake-3.21.0-rc2.tar.gz
make&&make install
添加cmake的环境变量
/usr/local/share/cmake-3.21
cmake --version
cmake version 3.21.0-rc2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
- 工具链错误 :
riscv32-esp-elf-gcc
is not a full path and was not found in the PATH.
解决:把
> /root/.espressif/tools/riscv32-esp-elf/esp-2021r1-8.4.0/riscv32-esp-elf/bin
添加到PATH环境变量里
排除完问题后,以前在windows下无法正常编译的demo,编译通过,