深入浅出ESP32开发之二ESP-IDF下载、编译与运行

--作者:燕十三(flyingcys)

-- blog:杭州_燕十三的博客_CSDN博客-ARM&Linux,RT-Thread,物联网平台领域博主

--QQ:294102238

一、ESP-IDF下载

ESP-IDF全称Espressif IoT Development Framework是乐鑫基于ESP32推出的新一代SDK,基于FreeRTOS系统,在上一代SDK基础上做了众多更新和改进,集合了众多组件。支持在Windows、Linux和MacOS下基于ESP-IDF开发。

ESP-IDF源码已托管在github上,可在https://github.com/espressif/esp-idf下载,

在命令行输入git clone --recursive https://github.com/espressif/esp-idf下载,注意git clone必须添加--recursive,否则无法拉取components目录下的全部模块。

下载完成后,我们可以看到ESP-IDF的目录结构如下:

l components:ESP-IDF的核心组件

l docs:ESP-IDF相关文档

l examples:ESP-IDF提供的示例程序,包括众多外设、Wi-Fi、蓝牙等demo

l make:EPS-IDF工程管理目录

l tools:ESP-IDF提供的工具集

二、编译

ESP-IDF的example目录下提供了众多的示例程序,我们先编译“get-started”下的“hello_world”

如果直接在该目录下执行make,会提示出错

Makefile:8: /make/project.mk: No such file or directory

make: *** No rule to make target '/make/project.mk'.  Stop.

这是因为Makefile里的变量IDF_PATH没有设置

这里有2种方法:

方法1:

在当前Demo工程内修改Makefile,添加IDF_PATH=/home/share/samba/espressif/esp-idf,输入的路径为ESP-IDF目录

 

这个方法,换个Demo工程就需要手工添加IDF_PATH变量,想要一次性搞定就使用方法2吧。

方法2:

修改/etc/profile文件,添加export IDF_PATH=/home/share/samba/espressif/esp-idf

并使用source /etc/profile使环境变量生效。

完成以上配置后,执行make命令,第一次执行make命令默认会进入configuration界面。我们可以使用默认设置直接退出。

 

make将继续执行编译直至完成。

本次编译总共生成了3个文件,分别为:

位于build/bootloader目录下的bootloader.bin

位于build目录下的partitions_singleapp.bin

位于build目录下的hello-world.bin

三、开发板下载

我使用的是乐鑫原厂出的基于ESP-WROOM-32模组做的ESP32_Core_borad_V2开发板,自带USB-TTL(CP2102),该开发板类似NodeMCU,可自动进入boot模式,下载程序极其方便。

本次测试没有使用在Ubuntu下下载代码,使用的是在Windows版串口下载程序“ESPFlashDownloadTool_v3.4.4.exe”

设置完成后,点击“START”后开始下载,进入boot模式后,“Download Panel”将显示各设备的MAC地址。

四、运行测试

ESP32默认日志通过串口输出,串口波特率设置为:115200

复位开发板后,日志输出串口可看到Hello_world已经正常运行。

 

Demo程序还列出当前ESP32芯片相关信息:

1:当前demo运行于app cpu

2:当前ESP32芯片为双核

3:具有WIFI/BT/BEL功能

4:4MB外部FLASH

  • 7
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
esp32-freertos-sdk 工具包 See the Getting Started guide links above for a detailed setup guide. This is a quick reference for common commands when working with ESP-IDF projects: Setup Build Environment (See Getting Started guide for a full list of required steps with details.) Install host build dependencies mentioned in Getting Started guide. Add tools/ directory to the PATH Run python -m pip install -r requirements.txt to install Python dependencies Configuring the Project idf.py menuconfig Opens a text-based configuration menu for the project. Use up & down arrow keys to navigate the menu. Use Enter key to go into a submenu, Escape key to go out or to exit. Type ? to see a help screen. Enter key exits the help screen. Use Space key, or Y and N keys to enable (Yes) and disable (No) configuration items with checkboxes "[*]" Pressing ? while highlighting a configuration item displays help about that item. Type / to search the configuration items. Once done configuring, press Escape multiple times to exit and say "Yes" to save the new configuration when prompted. Compiling the Project idf.py build ... will compile app, bootloader and generate a partition table based on the config. Flashing the Project When the build finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this automatically by running: idf.py -p PORT flash Replace PORT with the name of your serial port (like COM3 on Windows, /dev/ttyUSB0 on Linux, or /dev/cu.usbserial-X on MacOS. If the -p option is left out, idf.py flash will try to flash the first available serial port. This will flash the entire project (app, bootloader and partition table) to a new chip. The settings for serial port flashing can be configured with idf.py menuconfig. You don't need to run idf.py build before running idf.py flash, idf.py flash will automatically rebuild anything which needs it. Viewing Serial Output The idf.py monitor target uses the idf_monitor tool to display se
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值