ESP-IDF库开发教程之(3)--安装eclipse

在之前的博文中,我解释了如何安装官方开发框架(Espressif物联网开发框架)以及如何使用它来编译第一个示例Hello World。

即使您可以使用简单的文本编辑器编写程序(在Windows上,我始终建议使用开放的Notepad ++),但使用IDE(集成开发环境)可以更容易地完成此任务,该IDE是一个图形应用程序,您可以使用它编写代码(通常包括语法高亮和自动完成),编译它并将二进制文件上载到开发板。在可用的IDE中,最着名和最受欢迎的IDE之一毫无疑问是Eclipse。

Installation

Eclipse安装非常简单:连接到官方站点并为您的操作系统下载适用于C / C ++开发人员的Eclipse IDE(如上一篇文章中,我决定使用Windows):

eclipse-01

Eclipse以zip存档形式提供。下载完成后,将存档解压缩到硬盘驱动器的文件夹中。为了简单起见,我选择了我已经安装了esp-idf的文件夹(用户的home文件夹):

eclipse-02

双击eclipse.exe运行Eclipse。首先,系统会提示您指定工作区的路径(=将保存项目的文件夹)。我选择将工作区创建为Eclipse安装文件夹的子文件夹:

eclipse-03

Project configuration

为了能够使用Eclipse开发基于esp-idf的项目,您需要进行一些配置。首先,在IDE中导入项目。对于本教程,我将使用01_hello_world示例;在以后的文章中,我会告诉你如何从一个空的项目开始。

选择“文件” - “导入”,然后将“现有代码”作为生成文件项目向导运行:

eclipse-04

为该项目命名,选择包含该代码的文件夹,并确保所选工具链是Cross GCC:

eclipse-05

导入完成后,打开项目属性:

eclipse-06

首先选择C / C ++ Build - Environment。添加(使用添加...按钮)两个新变量:

  • name V, value 1
  • name IDF_PATH, value the path where esp-idf is installed (note: you have to use / instead of \)

另外,在Windows上,使用以下值更改PATH变量(如果msys32安装在默认路径中):

C:\msys32\usr\bin;C:\msys32\mingw32\bin;C:\msys32\opt\xtensa-esp32-elf\bin

eclipse-07

如果你在Windows下,现在选择C / C ++ Build,unflag使用默认...并输入下面的build命令:

bash ${IDF_PATH}/tools/windows/eclipse_make.sh

eclipse-08

最后一步是选择C / C ++ General - Preprocessor Include Paths并打开Providers选项卡。

点击CDT Cross GCC内置编译器设置,用xtensa-esp32-elf-gcc改变文本$ {COMMAND}:

eclipse-09

然后点击CDT GCC Build Output Parser并在命令开始处添加xtensa-esp32-elf-:

eclipse-10

您现在已准备好编译该项目:

eclipse-11

在编译过程之后,Eclipse可能会发生一些“未解决的包含”的警告:

eclipse-12

警告应该只出现在Windows下,并且它们是由一个不会阻塞编译过程的已知错误引起的。您可以手动添加从项目属性(C / C ++常规 - 路径和符号 - GNU C)中的文件夹esp-idf / components中找到的不同包含文件夹来解决此问题:

eclipse-13

Flash

您还可以配置Eclipse以运行make flash命令,以在开发板上加载程序的编译版本。

在右侧面板上选择“构建目标”选项卡:

eclipse-14

用鼠标右键单击该项目的文件夹,然后选择新建。

输入flash作为目标名称,然后用OK确认:

eclipse-15

如果现在右键单击新命令,则可以选择构建目标来启动闪存进程:

eclipse-16

IDE的下部面板中的“控制台”选项卡显示了闪存命令输出和结果:

eclipse-17

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr.Lanson

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值