使用 nRF Connect for VS Code 加速物联网开发

前言

原文链接

https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/accelerate-iot-development-with-nrf-connect-for-vscode

原文前言

Development tools are essential for embedded software developers, especially those crafting embedded software for IoT products typically centered around resource-constrained wireless SoCs such as Nordic’s nRF52, nRF53, or nRF91 Series devices.

开发工具对于嵌入式软件开发人员来说至关重要,尤其是那些为通常以资源有限的无线 SoC(例如 Nordic 的 nRF52、nRF53 或 nRF91 系列设备)为中心的物联网产品制作嵌入式软件的开发人员。

The Integrated Development Environment (IDE), in particular, effectively becomes the interface between the embedded software developer and a variety of other pieces required for IoT embedded software development, such as the Software Development Kit (SDK), toolchain (compiler, linker, utilities), debug probe, and the wireless SoC itself.

特别是集成开发环境 (IDE),有效地成为嵌入式软件开发人员与物联网嵌入式软件开发所需的各种其他部分之间的接口,例如软件开发套件 (SDK)、工具链(编译器、链接器、实用程序) )、调试探针和无线 SoC 本身。

As the famous quote goes, “If the only tool you have is a hammer, you tend to see every problem as a nail.” it is essential to pick the right tool for the job.

正如一句名言所说:“如果你拥有的唯一工具是锤子,那么你往往会将所有问题视为钉子。”为工作选择正确的工具至关重要。

Therefore, it is unsurprising that “better development tools” rank highly on various surveys as an influential factor when selecting a silicon vendor (e.g., 2019 Embedded Markets Study). There is a clear connection between good development tools and development speed, leading to faster time-to-market and lower overall development costs.

因此,毫不奇怪,“更好的开发工具”在各种调查中作为选择芯片供应商时的影响因素排名很高(例如,2019 年嵌入式市场研究)。良好的开发工具和开发速度之间存在明显的联系,从而加快上市时间并降低总体开发成本。

Nordic introduced nRF Connect for Visual Studio Code (VS Code) in August 2021, designed and built from the ground up for nRF Connect SDK. It provides developers with a full-fledged and feature-rich IDE ideal for developing applications with nRF Connect SDK so that developers can genuinely leverage all the SDK features more efficiently and effectively.

Nordic 于 2021 年 8 月推出了 nRF Connect for Visual Studio Code (VS Code),它是为 nRF Connect SDK 重新设计和构建的。它为开发人员提供了功能齐全、功能丰富的 IDE,非常适合使用 nRF Connect SDK 开发应用程序,以便开发人员能够更高效、更有效地真正利用所有 SDK 功能。

This blog post will discuss some of the most relevant nRF Connect for VS Code features and how they can help accelerate IoT embedded development with Nordic’s wireless SoCs and software. We recommend watching the nRF Connect for VS Code tutorials for more detailed insights.

本博文将讨论一些最相关的 nRF Connect for VS Code 功能,以及它们如何帮助利用 Nordic 的无线 SoC 和软件加速物联网嵌入式开发。我们建议观看 nRF Connect for VS Code 教程以获取更详细的见解。

Getting Started(入门)

The most common starting point for getting familiar with a new SDK is through samples, typically small bite-sized examples focusing on a particular functionality, and applications that showcase more complete use cases leveraging various pieces of functionality.

要熟悉一个新的 SDK,最常见的起点是通过示例,通常是专注于特定功能的小样本,以及展示利用各种功能的更完整用例的应用程序。

When using nRF Connect for VS Code, exploring the rich list of samples and applications in nRF Connect SDK can be done through the built-in sample browser, which is part of the workflow for creating a new application.

使用 nRF Connect for VS Code 时,可以通过内置示例浏览器探索 nRF Connect SDK 中丰富的示例和应用程序列表,这是创建新应用程序的工作流程的一部分。

The sample browser offers a complete list of all the available SDK

熟悉新 SDK 的最常见起点是通过示例,通常是专注于特定功能的小型示例,以及展示利用各种功能的更完整用例的应用程序。

samples and applications, and it also includes search capabilities, documentation rendered within the IDE, and shortcuts for direct access to the sample documentation and source code on a browser.

它还包括搜索功能、在集成开发环境中显示文档,以及在浏览器上直接访问示例文档和源代码的快捷方式。

This allows for a user-friendly exploration of the SDK samples without ever having to leave the IDE context.

这样,用户无需离开集成开发环境即可方便地探索 SDK 示例。

使用 nRF Connect for VS Code 加速物联网开发_第1张图片

After selecting a sample and getting familiar with the functionality through the handy built-in documentation, the next step is to typically flash to a target board, most commonly a hardware kit, at the early stages of development.

选择样本并通过方便的内置文档熟悉功能后,下一步通常是在开发的早期阶段闪存到目标板(最常见的是硬件套件)。

The nRF Connect SDK leverages a Zephyr concept called devicetree, a hierarchical data structure describing the underlying hardware where we want to run our firmware. This allows for a decoupling between source code and hardware configuration.

nRF Connect SDK 利用了名为 devicetree 的 Zephyr 概念,这是一种分层数据结构,描述了我们想要运行固件的底层硬件。这允许源代码和硬件配置之间的解耦。

The key benefit is having the same source code (drivers, stacks, middleware, application) targeting multiple hardware boards without modifications to the source code itself.

主要好处是拥有针对多个硬件板的相同源代码(驱动程序、堆栈、中间件、应用程序),而无需修改源代码本身。

This short devicetree description justifies an intermediate step between creating the sample and flashing it to our target, which is adding a build configuration, or in other words, selecting the target hardware which will bring its devicetree into the project.

这个简短的设备树描述证明了创建示例和将其刷新到我们的目标之间的中间步骤,即添加构建配置,或者换句话说,选择将其设备树带入项目的目标硬件。

This is made extremely easy with nRF Connect for VS Code, as it offers a quick way to browse multiple boards and quickly pinpoint the one being used.

使用 nRF Connect for VS Code 可以非常轻松地实现这一点,因为它提供了一种快速浏览多个板并快速查明正在使用的板的方法。

使用 nRF Connect for VS Code 加速物联网开发_第2张图片

Creating a build configuration will automatically trigger a build of the project, after which additional views surface on the extension when the project is selected, namely the Details, Devicetree, and Actions Views. Since we aim to flash the application, we will focus on the Actions View containing several shortcuts (actions).

创建构建配置将自动触发项目的构建,之后当选择项目时,扩展上会显示其他视图,即“详细信息”、“设备树”和“操作”视图。由于我们的目标是刷新应用程序,因此我们将重点关注包含多个快捷方式(操作)的操作视图。

使用 nRF Connect for VS Code 加速物联网开发_第3张图片

It is clear what action we are interested in, and a simple click on Flash will take the image that came out of the build and flash it to our target board through the onboard debug adapter on the Nordic Development Kit.

我们很清楚对什么操作感兴趣,只需单击 Flash 即可获取构建后的映像,并通过 Nordic 开发套件上的板载调试适配器将其刷新到我们的目标板。

This sequence of steps can be easily repeated for any sample, allowing quick iteration and exploration of the SDK samples and functionality.

对于任何示例都可以轻松重复这一系列步骤,从而可以快速迭代和探索 SDK 示例和功能。

Development and Debugging(开发调试)

The majority of time spent by IoT embedded software developers is on developing and debugging the software itself.

物联网嵌入式软件开发人员花费的大部分时间都花在软件本身的开发和调试上。

That does not strictly mean creating new application software from scratch, but also eventually debugging and troubleshooting issues found along the way, which can be more time-consuming than the software creation itself, if adequate tools are not present to ease up the job.

严格来说,这并不意味着从头开始创建新的应用程序软件,而且最终还需要对过程中发现的问题进行调试和故障排除,如果没有足够的工具来简化工作,这可能比软件创建本身更耗时。

In this section of the blog, we will introduce some of the critical tools within nRF Connect for VS Code that can help developers create and troubleshoot their IoT embedded software.

在博客的这一部分中,我们将介绍 nRF Connect for VS Code 中的一些关键工具,这些工具可以帮助开发人员创建 IoT 嵌入式软件并对其进行故障排除。

These tools are complimentary to the existing command line interface (CLI) and developers are free to chose their preferred approach which better fits into their workflows.

这些工具是对现有命令行界面 (CLI) 的补充,开发人员可以自由选择更适合其工作流程的首选方法。

Devicetree Visual Editor(Devicetree可视化编辑器)

The devicetree data structure can be tricky for developers new to nRF Connect SDK. To ease the learning curve and accelerate the hardware configuration, Nordic has introduced the Devicetree Visual Editor.

对于刚接触 nRF Connect SDK 的开发人员来说,devicetree 数据结构可能会很棘手。为了简化学习曲线并加速硬件配置,Nordic 推出了 Devicetree 可视化编辑器。

As the name implies, it offers a graphical way of editing the devicetree as an alternative to text-based editing. The keyword here is ‘alternative’, as developers can choose between a graphical or text approach or use them side by side, as illustrated below.

顾名思义,它提供了一种编辑设备树的图形方式,作为基于文本编辑的替代方法。这里的关键字是“替代”,因为开发人员可以在图形或文本方法之间进行选择,或者并排使用它们,如下所示。

It is also worth noting that the Devicetree Visual Editor can be used on existing projects, it doesn’t require starting a new project from scratch.

还值得注意的是,Devicetree可视化编辑器可以在现有项目上使用,不需要从头开始一个新项目。

使用 nRF Connect for VS Code 加速物联网开发_第4张图片

What is being depicted in the above image is the same devicetree overlay file being visualized with both the DeviceTree Visual Editor (left) and the basic text editor (right). Changes made on either side are immediately reflected on the other, and they are always kept in sync.

上图中描绘的是使用 DeviceTree 可视化编辑器(左)和基本文本编辑器(右)可视化的同一 devicetreeoverlay 文件。任何一侧所做的更改都会立即反映在另一侧,并且它们始终保持同步。

This allows for faster development and learning the devicetree data structure syntax on the go by experimenting with the DeviceTree Visual Editor while observing the text editor.

通过在观察文本编辑器的同时尝试使用 DeviceTree 可视化编辑器,可以随时随地更快地开发和学习 devicetree 数据结构语法。

The embedded software development will eventually transition from a standard vendor development kit into a custom board, and that process can be accelerated by leveraging the custom board creation feature in nRF Connect for VS Code together with the Devicetree Visual Editor.

嵌入式软件开发最终将从标准供应商开发套件过渡到定制板,并且可以通过利用 nRF Connect for VS Code 中的定制板创建功能以及 Devicetree 可视化编辑器来加速该过程。

nRF Kconfig

Applications built with nRF Connect SDK can be configured using KConfig options, which use symbols to enable/disable/configure various functionalities available in the SDK (e.g., enable logging module or set buffer sizes for a given functional module). nRF Connect for VS Code includes nRF Kconfig, a GUI that displays a list of Kconfig options used in the project file, allowing easy management of the required functionality on a given project, as well as exploring the available options and features available in every nRF Connect SDK module/library.

使用 nRF Connect SDK 构建的应用程序可使用 KConfig 选项进行配置,这些选项使用符号来启用/禁用/配置 SDK 中的各种可用功能(例如,启用日志模块或为给定功能模块设置缓冲区大小)。nRF Connect for VS Code 包含 nRF Kconfig,这是一个图形用户界面,可显示项目文件中使用的 Kconfig 选项列表,从而轻松管理给定项目中的所需功能,并探索每个 nRF Connect SDK 模块/库中的可用选项和功能。

It contains a search function to find a specific option in the list quickly and displays associated documentation.

它包含搜索功能,可在列表中快速查找特定选项,并显示相关文档。

使用 nRF Connect for VS Code 加速物联网开发_第5张图片

There are other interactive KConfig interfaces supported in nRF Connect SDK, menuconfig and guiconfig, but Nordic’s own Kconfing interface stands out by its unique ability to permanently store configurations in the project configuration file (prj.conf).

nRF Connect SDK、menuconfig 和 guiconfig 中还支持其他交互式 KConfig 接口,但 Nordic 自己的 Kconfing 接口因其在项目配置文件 (prj.conf) 中永久存储配置的独特能力而脱颖而出。

nRF Debug(nRF调试)

Debug sessions are an essential mechanism to grasp better what is happening with the software in run-time. Nordic has introduced its own debugger nRF Debug based on Microsoft’s Debug Engine with unique features that enhance the developer’s comprehension of their firmware. It is worth noting that Ozone debugger is also supported as an alternative.

调试会话是更好地掌握软件在运行时发生的情况的重要机制。 Nordic 推出了自己的调试器 nRF Debug,它基于 Microsoft 的调试引擎,具有增强开发人员对其固件的理解的独特功能。值得注意的是,还支持 Ozone 调试器作为替代方案。

The key features in nRF Debug that we want to highlight are the Thread Viewer, Memory Viewer, Call Stack and Peripherals View, all illustrated below.

我们要强调的 nRF 调试中的关键功能是线程查看器、内存查看器、调用堆栈和外设视图,如下所示。

使用 nRF Connect for VS Code 加速物联网开发_第6张图片

The Thread Viewer provides information about the threads, such as priority, stack usage, and thread options (labeled as ‘user options’ in the thread viewer). It also links back to the source code through the Name and Entry fields, which will open the source code location in the editor if known.

线程查看器提供有关线程的信息,例如优先级、堆栈使用情况和线程选项(在线程查看器中标记为“用户选项”)。它还通过“名称”和“条目”字段链接回源代码,这将在编辑器中打开源代码位置(如果已知)。

Memory Viewer shows the content of both Flash and RAM. It includes a user-friendly color notation of different regions that map directly to symbols in the source code, allowing for quick jumping to the symbol’s file and location.

内存查看器显示闪存和 RAM 的内容。它包括不同区域的用户友好的颜色表示法,直接映射到源代码中的符号,允许快速跳转到符号的文件和位置。

This is a convenient feature for troubleshooting memory issues such as memory leaks or writing out of bounds of data arrays.

这是解决内存问题(例如内存泄漏或写入数据数组越界)的便捷功能。

The peripherals view provides an interface to the device’s hardware registers and fields, including the capability to directly modify their data if the registers and fields are writable.

外设视图提供了设备硬件寄存器和字段的接口,包括在寄存器和字段可写的情况下直接修改其数据的功能。

Call stack shows the call stack within each available threads, as well as the run state of each thread.

调用堆栈显示每个可用线程内的调用堆栈以及每个线程的运行状态。

Memory Report(内存报告)

To optimize the flash/RAM consumption of a given firmware project, it’s essential to understand how the resources are being used across the code base. nRF Connect for VS Code includes a memory report feature that provides a simple list of resource usage following the SDK folder structure, as well as a graphical representation through a sunburst chart that allows one to quickly navigate and highlight parts of the code from an SDK folder level down to individual source files and symbols.

为了优化给定固件项目的闪存/RAM 消耗,必须了解资源在代码库中的使用方式。 nRF Connect for VS Code 包含内存报告功能,可提供遵循 SDK 文件夹结构的简单资源使用情况列表,以及通过旭日图的图形表示,使用户能够快速导航并突出显示 SDK 文件夹中的部分代码级别下降到单个源文件和符号。

使用 nRF Connect for VS Code 加速物联网开发_第7张图片

The graphical representation of resources allows to easily to observe resource usage across different software modules and find opportunities for optimization.

资源的图形表示可以轻松观察不同软件模块的资源使用情况并找到优化机会。

nRF Terminal(nRF终端)

One of the most common ways to interact with an embedded device during the development phase is through a terminal (over RTT or Serial), whether receiving logging information or sending commands to control parts of the firmware.

在开发阶段与嵌入式设备交互的最常见方法之一是通过终端(通过 RTT 或串行),无论是接收日志信息还是发送命令来控制固件的各个部分。

使用 nRF Connect for VS Code 加速物联网开发_第8张图片

A developer using nRF Connect for VS Code doesn’t need any 3rd party application for this purpose, as a built-in nRF Terminal can fulfill this need. It can be easily invoked from the Panel Toolbar or directly from a COM port associated with a connected device.

使用 nRF Connect for VS Code 的开发人员不需要任何第三方应用程序来实现此目的,因为内置的 nRF 终端可以满足此需求。它可以轻松地从面板工具栏或直接从与所连接设备关联的 COM 端口调用。

使用 nRF Connect for VS Code 加速物联网开发_第9张图片

Git integration(Git 集成)

nRF Connect SDK is a combination of multiple repositories which are managed through a Zephyr tool called west. nRF Connect for VS Code provides a graphical front end to west, within VS Code’s source control, as an alternative to the traditional CLI interface.

nRF Connect SDK 是多个存储库的组合,这些存储库通过名为 west 的 Zephyr 工具进行管理。 nRF Connect for VS Code 在 VS Code 的源代码控制范围内提供了一个图形前端,作为传统 CLI 界面的替代方案。

To streamline Git usage with nRF Connect SDK applications, creating a new project will automatically initialize a Git repository in the generated project directory, including the .gitignore files listing file types which do not need to be tracked.

为了简化 nRF Connect SDK 应用程序中的 Git 使用,创建新项目将自动初始化生成的项目目录中的 Git 存储库,包括列出不需要跟踪的文件类型的 .gitignore 文件。

Closing(闭幕式)

Developing IoT embedded software leveraging advanced and easy-to-use tools, such as nRF Connect for VS Code, gives developers an advantage that allows creating applications faster and with higher quality.

利用先进且易于使用的工具(例如 nRF Connect for VS Code)开发物联网嵌入式软件,为开发人员提供了一个优势,可以更快地创建更高质量的应用程序。

The tight coupling between nRF Connect SDK and nRF Connect for VS Code makes it the primary IDE to create IoT applications with Nordic products.

nRF Connect SDK 和 nRF Connect for VS Code 之间的紧密耦合使其成为使用 Nordic 产品创建物联网应用程序的主要 IDE。

We strive to continue bringing new features and improving the overall ease of use to help developers accelerate their time-to-market for IoT devices.

我们努力继续带来新功能并提高整体易用性,以帮助开发人员加快物联网设备的上市时间。

If you are an nRF Connect for VS Code user, please comment below and let us know how it helped you develop IoT devices with Nordic’s products and software.

如果您是 nRF Connect for VS Code 用户,请在下面发表评论,让我们知道它如何帮助您使用 Nordic 的产品和软件开发物联网设备。

你可能感兴趣的:(外网嵌入式资讯,物联网)