ESP8684编译烧录实践

ESP8684 是一款低功耗 Wi-Fi 和蓝牙组合芯片,主要用于以下作用:

  • 物联网设备连接:将物联网设备(如传感器、执行器和家用电器)连接到互联网。
  • 无线数据传输:通过 Wi-Fi 或蓝牙在设备之间传输数据。
  • 远程控制:允许用户通过智能手机或其他设备远程控制设备。
  • 数据采集:从传感器收集数据并将其传输到云端或其他系统进行分析。
  • 嵌入式应用:为嵌入式系统(如无人机、机器人和可穿戴设备)添加无线连接功能。

总的来说,ESP8684 适用于需要低功耗、无线连接和数据传输功能的广泛物联网和嵌入式应用。

目录

编译过程

1、设置环境变量

2、配置编译环境依赖

3、查看ESP32连接的串口

4、设置目标芯片

5、配置项目具体变量

6、编译工程

7、烧录至设备

8、监视输出

9、权限问题

命令总结


编译过程

1、设置环境变量

gedit ~/.bashrc
//新增如下内容至文件中:
alias get_idf='. $HOME/esp/esp-idf/export.sh'
//
source ~/.bashrc

2、配置编译环境依赖

进入esp-idf目录下,执行:

get_idf

相当于直接执行:

. export.sh

脚本会检查环境依赖。 如果出现类似以下错误:

Setting IDF_PATH to '/home/workspace/esp-idf'
Detecting the Python interpreter
Checking "python3" ...
Checking "python" ...
Checking "python3.7" ...
"python3.7" not found
...

//或在安装python后

Setting IDF_PATH to '/home/workspace/esp-idf'
Detecting the Python interpreter
Checking "python3" ...
Checking "python" ...
Checking "python3.7" ...
Python 3.7.9
"python3.7" has been detected
Checking Python compatibility
Checking other ESP-IDF version.
Adding ESP-IDF tools to PATH...
Checking if Python packages are up to date...
Constraint file: /home/.espressif/espidf.constraints.v5.2.txt
Requirement files:
 - /home/workspace/esp-idf/tools/requirements/requirements.core.txt
Python being checked: /home/.espressif/python_env/idf5.2_py3.7_env/bin/python
pkg_resources cannot be imported. The most common cause is a missing pip or setuptools package. If you've installed a custom Python then these packages are provided separately and have to be installed as well. Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required packages.

说明python或pip工具版本不对,要求版本大于等于3.7,Ubuntu更新python版本可以查看:Ubuntu16.04更新python3版本-CSDN博客

在安装python版本后若出现以下错误:

Setting IDF_PATH to '/home/workspace/esp-idf'
Detecting the Python interpreter
Checking "python3" ...
Checking "python" ...
Checking "python3.7" ...
Python 3.7.9
"python3.7" has been detected
Checking Python compatibility
Checking other ESP-IDF version.
ERROR: tool xtensa-esp-elf-gdb has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool riscv32-esp-elf-gdb has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool xtensa-esp32-elf has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool xtensa-esp32s2-elf has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool xtensa-esp32s3-elf has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool riscv32-esp-elf has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool esp32ulp-elf has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool openocd-esp32 has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.
ERROR: tool esp-rom-elfs has no installed versions. Please run '/usr/local/python/python3.7/bin/python3.7 /home/workspace/esp-idf/tools/idf_tools.py install' to install it.

可以单步执行提示中的语句,也可以直接运行esp-idf文件夹下的install.sh脚本。

正确执行结果:

Detecting the Python interpreter
Checking "python3" ...
Python 3.7.9
"python3" has been detected
Checking Python compatibility
Checking other ESP-IDF version.
Adding ESP-IDF tools to PATH...
Checking if Python packages are up to date...
Constraint file: /home/.espressif/espidf.constraints.v5.2.txt
Requirement files:
 - /home/workspace/esp-idf/tools/requirements/requirements.core.txt
Python being checked: /home/.espressif/python_env/idf5.2_py3.7_env/bin/python
/home/workspace/esp-idf/tools/check_python_dependencies.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Python requirements are satisfied.
Added the following directories to PATH:
  /home/workspace/esp-idf/components/espcoredump
  /home/workspace/esp-idf/components/partition_table
  /home/workspace/esp-idf/components/app_update
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

3、查看ESP32连接的串口

插入设备前后各执行一次,多出的那个就是连接的串口

ls /dev/tty*

4、设置目标芯片

idf.py set-target esp32

esp32可以替换为其他,通过执行idf.py set-target可以看到所有支持的芯片

@:~/workspace/hello_world$ idf.py set-target
/home/workspace/esp-idf/tools/check_python_dependencies.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Usage: idf.py set-target [OPTIONS] {esp32|esp32s2|esp32c3|esp32s3|esp32c2|esp3
                         2c6|esp32h2|linux}
Try 'idf.py set-target --help' for help.

Error: Missing argument '{esp32|esp32s2|esp32c3|esp32s3|esp32c2|esp32c6|esp32h2|linux}'. Choose from:
  esp32,
  esp32s2,
  esp32c3,
  esp32s3,
  esp32c2,
  esp32c6,
  esp32h2,
  linux

5、配置项目具体变量

idf.py menuconfig

将出现如下窗口:

可以通过此菜单设置项目的具体变量,包括 Wi-Fi 网络名称、密码和处理器速度等。

注:这一步中需要设置串口波特率,否则后续监测器将出现乱码

进入 Component config –> Hardware Settings –> Main XTAL Config –> Main XTAL frequency 进行配置,将 CONFIG_XTAL_FREQ_SEL 设置为 26 MHz。

6、编译工程

idf.py build

执行结果:

...
[91/92] Generating binary image from built executableesptool.py v4.6.2
Creating esp32c2 image...
Merged 2 ELF sections
Successfully created esp32c2 image.
Generated /home/workspace/hello_world/build/bootloader/bootloader.bin
[92/92] cd /home/workspace/hello_w..._world/build/bootloader/bootloader.binBootloader binary size 0x4a50 bytes. 0x35b0 bytes (42%) free.
[812/813] Generating binary image from built executableesptool.py v4.6.2
Creating esp32c2 image...
Merged 1 ELF section
Successfully created esp32c2 image.
Generated /home/workspace/hello_world/build/hello_world.bin
[813/813] cd /home/workspace/hello...pace/hello_world/build/hello_world.binhello_world.bin binary size 0x1bd20 bytes. Smallest app partition is 0x100000 bytes. 0xe42e0 bytes (89%) free.

Project build complete. To flash, run:
 idf.py flash
or
 idf.py -p PORT flash
or
 python -m esptool --chip esp32c2 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 60m 0x0 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/hello_world.bin
or from the "/home/workspace/hello_world/build" directory
 python -m esptool --chip esp32c2 -b 460800 --before default_reset --after hard_reset write_flash @flash_args

7、烧录至设备

idf.py -p /dev/ttyUSB0 flash

8、监视输出

idf.py -p /dev/ttyUSB0 monitor
    ...
    Hello world!
    Restarting in 10 seconds...
    This is esp32 chip with 2 CPU core(s), WiFi/BT/BLE, silicon revision 1, 2 MB external flash
Minimum free heap size: 298968 bytes
    Restarting in 9 seconds...
    Restarting in 8 seconds...
    Restarting in 7 seconds...

退出监视器:ctrl+]

9、权限问题

在烧录至板子时出现:Failed to open port /dev/ttyUSB0或Can not open,错误消息。此时可以将用户添加至 Linux Dialout 组。

sudo usermod -a -G dialout xxx

然后重启。

命令总结

gedit ~/.bashrc //仅第一次
//新增如下内容至文件中:
alias get_idf='. $HOME/esp/esp-idf/export.sh'//仅第一次
//
source ~/.bashrc //仅第一次
sudo update-alternatives --config python //选择大于python3.7
get_idf
ls /dev/tty*
idf.py set-target esp32c2
idf.py menuconfig
idf.py build
sudo usermod -a -G dialout xxx //仅第一次
reboot //仅第一次
idf.py -p /dev/ttyUSB0 flash
idf.py -p /dev/ttyUSB0 monitor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值