一.开发板使用前的准备
1.硬件准备
lyrat开发板要工作起来需要用一根microusb线接到供电口,而下载或者调试设备需要另一根microusb线接到串口端。另外要将电源键拨到ON的位置。该开发板的定位是智能音箱,所以要测试音频需要接一个3.5英寸接口的耳机/音箱。在烧录程序之前还需要摁着boot按键再拨开电源键,这样开发板才会进入烧录模式。
2.开发环境的准备
(1)下载开发板的sdk
git clone --recursive https://github.com/espressif/esp-adf.git
(2)安装依赖库
sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-serial
(3)编译链、IDF和ADF的安装和配置
编译链的下载地址如下:
for 64-bit Linux:
https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
for 32-bit Linux:
https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-80-g6c4433a-5.2.0.tar.gz
mkdir -p ~/esp cd ~/esp wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz tar -xzf /xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
接下来配置编译链、idf、adf的路径,使用命令“vim ~/.profile
”在profile文件添加以下内容
export PATH="$PATH:$HOME/esp/xtensa-esp32-elf/bin" alias get_esp32='export PATH="$PATH:$HOME/esp/xtensa-esp32-elf/bin"' export IDF_PATH=~/workspace/esp32/esp-adf/esp-idf export ADF_PATH=~/workspace/esp32/esp-adf
重启电脑后使用命令验证是否添加成功
$ printenv PATH /home/user-name/bin:/home/user-name/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/user-name/esp/xtensa-esp32-elf/bin
二、编译、下载、运行并调试lyrat开发板
1.编译的方法
编译项目有时候需要配置wifi的帐号和密码,在make menuconfig菜单里配置就行了。cd ~/esp-adf/examples/get-started/play_mp3 make menuconfig make -j4
2.下载的方法
需要摁着boot键启动开发板,还有需要注意串口权限的问题。
make flash
3.运行并调试开发板
运行开发板之前需要摁reset键make monitor
三、开发板使用的时候经常遇到的问题以及解决方法
1.开发板无法进入烧录模式下载程序
因为esp32芯片进入烧录模式的条件是启动的时候会检测boot引脚,所以需要摁着boot键启动才能下载程序。
2.开发板下载程序的时候老是提示串口权限不足
linux下面串口设备的使用者一般是root,所以临时使用串口需要赋予程序root权限或者修改dev目录下串口的权限。如果想串口支持一般用户,那么就需要把当前用户添加到拨号组,添加办法如下面命令所示:
sudo usermod -a -G dialout $USER
3.使用make monitor提示出错
错误信息如下
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "/opt/esp-adf/esp-idf/tools/idf_monitor.py", line 120, in _run_outer self.run() File "/opt/esp-adf/esp-idf/tools/idf_monitor.py", line 155, in run c = self.console.getkey() File "/opt/esp-adf/esp-idf/tools/idf_monitor.py", line 235, in getkey_patched c = self.enc_stdin.read(1) AttributeError: 'Console' object has no attribute 'enc_stdin' Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "/opt/esp-adf/esp-idf/tools/idf_monitor.py", line 120, in _run_outer self.run() File "/opt/esp-adf/esp-idf/tools/idf_monitor.py", line 193, in run if not self.serial.is_open: AttributeError: 'Serial' object has no attribute 'is_open'
出现错误的原因应该是串口工具pyserial版本太低所致,那么解决办法就是升级pyserial工具
sudo -H pip install pyserial --upgrade
如果使用这个方法也会出错,提示超时,那么恭喜你了,网络被墙了!解决方法就是自备梯子再下载。
四、参考资料
1.IDF---ESP-IDF Programming Guide
2.ADF框架--Audio Development Framework