缘起是我计划把原先的esp-idf
升级到release/v4.1
, git pull
之后瞄了一眼文档,看到编译环境配置方式有较大变化,交叉编译工具链链接不再提供,而是通过$IDF_PATH/install.sh
脚本自动下载。
在折腾一通最终报错python_env/idf4.2_py2.7_env/bin/python: No module named pip
之后,还是决定走另外一条路:
使用不同的用户分别配置ESP8266 RTOS
和esp-idf
环境。
这么做的好处显而易见。因为ESP8266 RTOS
和esp-idf
环境除了需要配置不同的"IDF_PATH",交叉编译工具版本也不同。两个用户自己有独立的profile,切换非常方便。
macOS系统偏好设置-用户与群组
里新建用户即可。
至于macOS下esp-idf
配置方法,按照官方文档即可。非常顺利。
我这里写一个简化版:
1. 安装必要工具
install pip:
sudo easy_install pip
install pyserial:
pip install --user pyserial
install CMake & Ninja build:
If you have HomeBrew, you can run:
brew install cmake ninja
If you have MacPorts, you can run:
sudo port install cmake ninja
2. 克隆esp-idf
cd dev
git clone --recursive https://github.com/espressif/esp-idf.git
#切换到4.1分支(4.0 hello_world无法通过编译,但是4.1可以)
git checkout release/v4.1
3. 通过脚本下载交叉编译工具链和配置python虚拟环境
cd esp-idf
./install.sh
4. 配置路径
chmod +x ./export.sh
. ./export.sh