lyrat开发板要工作起来需要用一根microusb线接到供电口,而下载或者调试设备需要另一根microusb线接到串口端。另外要将电源键拨到ON的位置。该开发板的定位是智能音箱,所以要测试音频需要接一个3.5英寸接口的耳机/音箱。在烧录程序之前还需要摁着boot按键再拨开电源键,这样开发板才会进入烧录模式。
git clone --recursive https://github.com/espressif/esp-adf.git
sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-serial
编译链的下载地址如下:
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
使用wget命令就可以下载
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
编译项目有时候需要配置wifi的帐号和密码,在make menuconfig菜单里配置就行了。
cd ~/esp-adf/examples/get-started/play_mp3
make menuconfig
make -j4
运行‘make flash’命令,需要长摁着boot键,再短按一下reset键。启动开发板,还有需要注意串口权限的问题。
make flash
运行开发板之前需要摁reset键
make monitor
因为esp32芯片进入烧录模式的条件是启动的时候会检测boot引脚,所以需要摁着boot键启动才能下载程序。
linux下面串口设备的使用者一般是root,所以临时使用串口需要赋予程序root权限或者修改dev目录下串口的权限。如果想串口支持一般用户,那么就需要把当前用户添加到拨号组,添加办法如下面命令所示:
sudo usermod -a -G dialout $USER
1.错误信息如下
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
如果使用这个方法也会出错,提示超时,那么恭喜你了,网络被墙了!解决方法就是自备梯子再下载。
2.提示components要更新
long@long-desktop:~/workspace/esp32/esp-adf/examples/player/pipeline_http_mp3$ make
WARNING: esp-idf git submodule components/esp32/lib may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/micro-ecc/micro-ecc may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/esptool_py/esptool may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/esp32/lib may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/micro-ecc/micro-ecc may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/esptool_py/esptool may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/micro-ecc/micro-ecc may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/esptool_py/esptool may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
WARNING: esp-idf git submodule components/esp32/lib may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
解决方法是进IDF的目录执行'git submodule update'
2.
编译例程的时候出现这个错误:
/home/esp8266/Desktop/esp/esp-adf/components/audio_stream/./fatfs_stream.c:39:22: fatal error: wav_head.h: No such file or directory
compilation terminated.
make[1]: *** [fatfs_stream.o] Error 1
make: *** [component-audio_stream-build] Error 2
解决方法:
获取所有子模块,输入命令:
git submodule update --init
3.应用程序过大
esp_image: Image length 1390176 doesn't fit in partition length 1048576�[0m
�[0;31mE (516) boot: Factory app partition is not bootable�[0m
解决方法:
修改分区表,使应用程序可以大于2M
$IDF_PATH/components/partition_table/partitions_singleapp.csv
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 2M,
四、参考资料
1.IDF---ESP-IDF Programming Guide
2.ADF框架--Audio Development Framework
3.原理图--esp32-lyrat-v4-schematic.pdf
4.ADF音频框架的github网址