Skip to main content

nRFConnect SDK Usage with Seeed Studio XIAO nRF54LM20A Sense

nRF Connect SDK (NCS) is Nordic Semiconductor's official software development kit, built on top of the Zephyr RTOS real-time operating system. It provides a complete, native, and highly optimized development framework for the nRF series chips. Compared with PlatformIO, NCS offers developers fuller access to the entire hardware capabilities of the nRF54 series, including native support for Bluetooth Low Energy (BLE), Thread, Matter, and other wireless protocol stacks, as well as finer-grained power management and peripheral control. Nordic officially maintains and updates this SDK continuously, ensuring optimal compatibility with chip firmware and early access to the latest features.

This tutorial will guide you step by step through the entire process — from setting up the nRF Connect SDK development environment and installing the toolchain, to creating and configuring your first project, and finally flashing your first example program onto the XIAO nRF54LM20A Sense to see it in action.

Hardware Preperation

Seeed Studio XIAO nRF54LM20A Sense

Using nRF Connect SDK on VSCode

Install nRF Connect SDK Knowledge in advance

This document details how to install the nRF Connect SDK development environment on a Windows 11 computer.The following is an overview of the tools that need to be installed

ninja --version
  • CMake
cmake --version
  • Zephyr SDK
west --version
  • nRF Connect SDK
  • VSCode nRF Connect plugin

If you have pre-installed it on your computer, you can check the version number of your tool by following the command below

1
Install the extension

Open VS Code and search for nRF Connect for VS Code Extension Pack in the Plugin Center. This plugin pack will automatically install other VS Code plugins required for nRF Connect.


The nRF Connect for VS Code extension enables developers to utilize the popular Visual Studio Code Integrated Development Environment (VS Code IDE) to develop, build, debug and deploy embedded applications based on Nordic's nRF Connect SDK (Software Development Kit). The extension includes useful development tools such as a compiler interface, linker, complete build system, RTOS-enabled debugger, seamless interfacing with the nRF Connect SDK, device tree visualization editor, and an integrated serial terminal.

The nRF Connect extension package for VS Code includes the following components:

  • nRF Connect for VS Code: The main extension contains the interface between the build system and the nRF Connect SDK, as well as an interface to manage the nRF Connect SDK version and toolchain.
  • nRF DeviceTree: Provides device tree language support and a device tree visualization editor.
  • nRF Kconfig: Provides Kconfig language support.
  • nRF Terminal: Serial and RTT terminals.
  • Microsoft C/C++: Adds language support for C/C++, including features of IntelliSense.
  • CMake: CMake language support.
  • GNU Linker Mapping Files: Support for linker mapping files. We can download any preferred version of the nRF Connect SDK and its toolchain via the extension. The full nRF Connect for VS Code documentation is available at https://docs.nordicsemi.com/bundle/nrf-connect-vscode/page/index.html.
2
Installing the toolchain

The toolchain is a collection of tools that work together to build nRF Connect SDK applications, including assembler, compiler, linker, and CMake components. The first time you open nRF Connect for VS Code, you will be prompted to install the toolchain. This usually happens if the extension does not detect any installed toolchain on your computer. Click Install Toolchain and a list of toolchain versions will be listed that can be downloaded and installed on your computer. Select the version of the toolchain that matches the version of the nRF Connect SDK you plan to use. We always recommend using the latest tagged version of the nRF Connect SDK.

By default, nRF Connect for VS Code only displays the Released tab (i.e., the stable version) of the toolchain. If you are evaluating a new feature and would like to use the Preview tab or another type of tab (e.g. Customer Sampling -cs), click on "Show all toolchain versions" as shown below:

note

The ToolChain here is 3.3.0 or above

3
Installing the nRF Connect SDK

In the nRF Connect extension for VS Code, click on Manage SDK. from the Manage SDK menu, we can install or uninstall the nRF Connect SDK version. Since this is the first time we are using the extension, the interface will only show two options.

Clicking Install SDK will list all available nRF Connect SDK versions that can be downloaded and installed locally. Select the version of the nRF Connect SDK that is required for the development of your project.

note

The nRF Connect SDK here is 3.2.4 or above

tip

If you do not see either of these options, make sure you have the latest version of the nRF Connect for VS Code extension package installed. It is important to note that the nRF Connect SDK is IDE independent, which means you can choose to use any IDE or none at all. The nRF Connect SDK is available via the https://www.nordicsemi.com/Products/Development-tools/nRF-Util (nrfutil) command line The (nrfutil) command line interface (CLI) will download and install nRF Connect. However, we highly recommend using our nRF Connect for VS Code extension with VS Code, as it integrates not only a convenient graphical user interface (GUI) and an efficient command line interface (CLI), but also includes a number of features that will greatly simplify firmware development. Configuring other IDEs to work with the nRF Connect SDK requires additional manual steps beyond the scope of this course.

4
Creating User Programs

In this exercise we will write a simple application based on the blinky example to control blinking LEDs on a development board. The same applies to all supported NordicSemiconductor development boards (nRF54, nRF53, nRF52, nRF70 or nRF91 series). The goal is to make sure that all the tools needed to build and burn the example are set up correctly. The focus is on learning how to create an application, build it and burn it to a Nordic chip development board using the “Copy Example” template!

  • In VS Code, click the nRF Connect extension icon. In the Welcome view, click Create New Application.
  • Type blinky in the search bar and select the second Blinky sample (path zephyr/samples/basic/blinky), as shown below.

The Blinky example will cause the LED1 on the development board to blink continuously.However, since our nRF54LM20A is equipped with an RGB light, you can modify some files through the following steps to make the RGB light shine with various lighting effects.

Our first application will be based on the Blinky example. The Blinky example is derived from the Zephyr mold block in the nRF Connect SDK, so you will see the zephyr name in the sample path: zephyr\samples\basic\blinky.

5
Add XIAO nRF54LM20A Board

To get started, clone the repository from the GitHub linkinto your preferred local folder. Once cloned, navigate to the platform-seeedboards/zephyr/ directory. Remember this zephyr folder Path;

git clone https://github.com/Seeed-Studio/platform-seeedboards.git

To configure your board for nRF Connect in VS Code, you can follow these steps:

  • Open VS Code and go to Settings.

  • Type nRF Connect in the search box.

  • Find the Board Roots settings item and click Edit in settings.json.

  • Add the zephyr path of the downloaded XIAO nRF54LM20A board file to the boardRoots array.


tip

Please note that the end point of the added path is the path of the boards folder, not the path of the platform-seeedboards folder.

  • In the application view, click Add Build Configuration below the application name .

  • We can select the model of XIAO nRF54LM20A in the Board target, and select the default prj.config file in the Base configuration files, and finally click Generate and Build to build the file.

6
Download Burn-in Plug-in

Additional Plugins:

On Windows, we'll use the Chocolatey package manager to install OpenOCD.

1.Open PowerShell (Run as Administrator):

  • In the Windows search bar, type PowerShell.
  • Right-click Windows PowerShell and select Run as administrator.

2.Check PowerShell Execution Policy:

  • Type Get-ExecutionPolicy and press Enter.
  • Type Get-ExecutionPolicy -List and press Enter.

3.Install Chocolatey:

  • Paste and run the following command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

This command bypasses the execution policy for the current PowerShell session and installs Chocolatey. After installation, close and reopen the PowerShell window (still run as administrator).

4.Install OpenOCD:

  • In the new PowerShell window (as administrator), type:
choco install openocd

5.Verify OpenOCD Installation:

  • Type Get-Command openocd and press Enter.

  • If the installation is successful, this command will display the path to openocd.exe.

7
Burn-in program
  • Open the src/main.c and prj.conf files and replace the original code with the following code.
src/main.c

/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/pwm.h>
#include <nrfx_power.h>

#define PWM_PERIOD_NS 1000000U
#define STEP_TIME_MS 500

#define LED_R_NODE DT_ALIAS(pwm_led1)
#define LED_G_NODE DT_ALIAS(pwm_led2)
#define LED_B_NODE DT_ALIAS(pwm_led0)

#if !DT_NODE_EXISTS(LED_R_NODE) || !DT_NODE_EXISTS(LED_G_NODE) || !DT_NODE_EXISTS(LED_B_NODE)
#error "This RGB blink demo expects pwm-led0/pwm-led1/pwm-led2 devicetree aliases"
#endif

static const struct pwm_dt_spec led_r = PWM_DT_SPEC_GET(LED_R_NODE);
static const struct pwm_dt_spec led_g = PWM_DT_SPEC_GET(LED_G_NODE);
static const struct pwm_dt_spec led_b = PWM_DT_SPEC_GET(LED_B_NODE);

struct rgb_step {
uint8_t r;
uint8_t g;
uint8_t b;
uint32_t delay_ms;
};

static int pwm_set_u8(const struct pwm_dt_spec *led, uint8_t level)
{
uint32_t duty_ns = (PWM_PERIOD_NS * (uint32_t)level) / 255U;

return pwm_set_dt(led, PWM_PERIOD_NS, duty_ns);
}

static int rgb_set(uint8_t r, uint8_t g, uint8_t b)
{
int ret;

ret = pwm_set_u8(&led_r, r);
if (ret < 0) {
return ret;
}

ret = pwm_set_u8(&led_g, g);
if (ret < 0) {
return ret;
}

ret = pwm_set_u8(&led_b, b);
if (ret < 0) {
return ret;
}

return 0;
}

int main(void)
{
int ret;

#if defined(CONFIG_NRFX_POWER)
nrfx_power_constlat_mode_request();
#endif

if (!device_is_ready(led_r.dev) || !device_is_ready(led_g.dev) || !device_is_ready(led_b.dev)) {
return -1;
}

static const struct rgb_step demo[] = {
{ 255, 0, 0, STEP_TIME_MS },
{ 0, 255, 0, STEP_TIME_MS },
{ 0, 0, 255, STEP_TIME_MS },
{ 255, 255, 0, STEP_TIME_MS },
{ 0, 255, 255, STEP_TIME_MS },
{ 255, 0, 255, STEP_TIME_MS },
{ 255, 255, 255, STEP_TIME_MS },
{ 0, 0, 0, STEP_TIME_MS },
};

while (1) {
for (size_t i = 0; i < ARRAY_SIZE(demo); i++) {
ret = rgb_set(demo[i].r, demo[i].g, demo[i].b);
if (ret < 0) {
return ret;
}
k_msleep(demo[i].delay_ms);
}
}

return 0;
}

prj.conf
CONFIG_GPIO=y
CONFIG_PWM=y
CONFIG_SERIAL=n

board/xiao_nrf54lm20a_nrf54lm20a_cpuapp.overlay
  1. If you need to modify or redefine device tree node contents, create a new xiao_nrf54lm20a_nrf54lm20a_cpuapp.overlay file in the Zephyr directory to explicitly bind device nodes.
  2. If you have modified the device tree files, please clean up the original files before rebuilding to prevent CMake from failing to recognize your changes.
/*
* Device tree overlay for XIAO nRF54LM20A RGB LED PWM demo.
*
* PWM20 peripheral is used for RGB LED control:
* - Channel 0: P1.22 (Blue LED) -> pwm_led0
* - Channel 1: P1.23 (Red LED) -> pwm_led1
* - Channel 2: P1.24 (Green LED) -> pwm_led2
*/

&pwm20 {
status = "okay";
};

/ {
pwmleds {
compatible = "pwm-leds";

pwm_led0: pwm_led_0 {
pwms = <&pwm20 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "Blue LED";
};

pwm_led1: pwm_led_1 {
pwms = <&pwm20 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "Red LED";
};

pwm_led2: pwm_led_2 {
pwms = <&pwm20 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "Green LED";
};
};
};

/ {
aliases {
pwm-led0 = &pwm_led0;
pwm-led1 = &pwm_led1;
pwm-led2 = &pwm_led2;
};
};
  • Then open the Open terminal and type the west flash command.

tip

If the west flash error occurs, it means you need to Add build configuration agagin,but you need to remove the discorrect build first.


Code Explanation

  • src/main.c Main application entry point that implements demo logic, including LED color configuration, breathing effects, blink rhythm control, button-based mode switching, and other hardware interaction behaviors.

  • zephyr/prj.conf Zephyr RTOS configuration file for enabling/disabling system components and peripheral drivers, including logging, UART, PWM, I2C, SPI, low-power management, and other functionalities.

Observe the Result

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...