Linux环境
使用Windows 10 Linux 子系统 Ubuntu 16.04
其它Ubuntu以此类推;
安装编译链
sudo apt-get install git make gcc libncurses5-dev flex bison gperf python-serial
从这里获取最新的编译链,Linux 64bit的
http://esp-idf.readthedocs.io/en/latest/get-started/linux-setup.html#install-prerequisites
cd /home/jacob
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
sudo chmod 777 xtensa-esp32-elf
sudo tar zxvf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz -C /opt/esp
sudo vi /etc/environment
最后添加/opt/esp/xtensa-esp32-elf/bin
source /etc/environment
xtensa-esp32-elf-gcc -v
验证通过,即可。
最后添加启动自加载,到/etc/profile的最后,即在最后加入
export IDF_PATH=/mnt/c/wsl/esp/esp-idf
export PATH=/mnt/c/wsl/esp/xtensa-esp32-elf/bin:$PATH
2,增加idf sdk
git clone --recursive https://github.com/espressif/esp-idf
设置IDF_PATH到/etc/profile的最后
即在最后加入:export IDF_PATH=/media/jacob/Files/git_workspace/esp-idf
命令行:source /etc/profile
使环境变量生效
echo $IDF_PATH
编译应用
进入目录 esp-idf-v3.1.3/examples/get-started/hello_world
make
make menuconfig
参考文章
http://blog.csdn.net/flyingcys/article/details/72186736
http://blog.csdn.net/flyingcys/article/details/72183706
http://esp-idf.readthedocs.io/en/latest/get-started/linux-setup.html#install-prerequisites
https://segmentfault.com/a/1190000012119486
异常处理
问题1
menuconfig的依赖项,否则会出现:
fatal error: curses.h: No such file or directory compilation terminated
sudo apt-get install libncurses5-dev libncursesw5-dev
flex也要安装,否则会出现:
make[1]: flex: Command not found
Makefile:337: recipe for target 'zconf.lex.c' failed
make[1]: *** [zconf.lex.c] Error 127
sudo apt-get install flex
同理 bison gperf 也和flex一样安装
问题2
mconf-idf is not required on this platform
mconf-idf is not required on this platform
The following Python requirements are not satisfied:
setuptools>=21
click>=5.0
pyserial>=3.0
future>=0.15.2
cryptography>=2.1.4
pyparsing>=2.0.3,<2.4.0
pyelftools>=0.22
Please follow the instructions found in the "Set up the tools" section of ESP-IDF Getting Started Guide
make: *** No rule to make target 'check_python_dependencies', needed by 'menuconfig'. Stop.
安装pip,使用pip安装对应的包,满足Python Requirements
首先,pip安装对应的包
pip install setuptools future cryptography pyparsing pyelftools
还不行,
pip 查询已经安装的包的版本
pip install setuptools=21
安装完成就可以了。
烧录
1,window 带有UI界面烧录的,见https://blog.csdn.net/wang3141128/article/details/78704737
2,使用wsl命令词烧录的,
可以先用命令测试一下,如下,注意修改 --port /dev/ttyS4 (我这边是COM4),修改串口号的配置,wsl 串口号的调用见:https://blog.csdn.net/iamlvshijie/article/details/89042367
python /mnt/d/wsl/esp/esp-idf-v3.1.3/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyS4 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 /mnt/d/wsl/esp/esp-idf-v3.1.3/examples/get-started/hello_world/build/bootloader/bootloader.bin 0x10000 /mnt/d/wsl/esp/esp-idf-v3.1.3/examples/get-started/hello_world/build/hello-world.bin 0x8000 /mnt/d/wsl/esp/esp-idf-v3.1.3/examples/get-started/hello_world/build/partitions_singleapp.bin
通过了,直接修改菜单里面的COM编号,以后就可以make flash就行了。
make menuconfig