Developing Zephyr BSP and Application Using Nordic Cross Tools (using nRF Connect SDK 2.6.1)

TODO: update for 2.6.1 SDK


1. Overview

This note describes how to set up and use the Nordic cross-development environment for development and debugging of the Zephyr BSP and a user application running on the Emcraft Thingy-9151-Lite platform.

2. Setting Up Cross Development Host

2.1. Setting Up Hardware Links to Emcraft Thingy-9151-Lite Platform

The emulated hardware platform is used for for early software development, while the Emcraft Thingy-9151-Lite hardware kit is not available yet. The emulated platform is based on the existing nRF9161 and nRF5340 development kits.

This note describes how to set up the emulated hardware platform.

Setting Up Hardware of Emulated Platform

Step through the following procedure in order to set up the emulated platform hardware:

  • Connect a USB Type-C cable to the J6 connector on the nRF9161 DK to the Linux host to get access to the on-board programmer and serial console.

  • Connect a Micro-USB cable to the J2 connector on the nRF5340 DK, and to the Linux host to get access to the on-board programmer and the VCOM based serial consoles.

  • Connect a Micro-USB cable to the J3 connector on the nRF5340 DK, and to the Linux host to get access to the USB based serial consoles.

Setting Up Thingy-9151-Lite Platform

TBD

2.1 Setting Up Software on Cross Development Host

Installing the nRF Connect SDK

Emcraft maintains the fork of the nRF Connect SDK on GitHub:

https://github.com/voxelbotics/sdk-nrf

Set up the nRF Connect SDK on a Linux PC as described in the Nordic documentation for the corresponding version. The instruction for v2.5.1 nRF Connect SDK can be found here:

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.1/nrf/installation/installing.html

Follow the Nordic instructions, but replace the west init... command in step 4 with the one below to use the Emcraft repositories:

west init -m https://github.com/voxelbotics/sdk-nrf --mr voxelbotics-v2.5.1-branch

Getting the Source Code of the Thingy-9151-Lite Application

The Thingy-9151-Lite Zephyr application is maintained in the separate GitHub repository:

https://github.com/voxelbotics/nrf-app

Just clone it in the same directory where west was initialized:

git clone git@github.com:voxelbotics/nrf-app -b main

The current branch and release tag are specified in the Release Notes document.

2. Developing Zephyr BSP and Application

2.2. Developing on nRF9151

Building Thingy-9151-Lite Application for nRF9151/nRF9161 from command line

Go to the application directory:

cd nrf-app/thingy9151lite_nrf9151_app/

The boards subdirectory contains the configurations of the supported boards. The Nordic nRF9161 DK board is already supported in Zephyr, so it is configured using the devicetree overlay:

Build the application for nRF9161 DK using the following command:

The resulting image is build/zephyr/merged.hex.

Importing the Thingy-9151-Lite Application for nRF9151/nRF9161 into the VSCode

Start VSCode, activate nRF Connect plugin, select ‘Open an existing application', navigate to <west_init>/nrf-app/thingy9151lite_nrf9151_app, press 'Open'

 

nrfconnect_plugin_openapp.png
Button to start nRF Connect plugin and menu to open existing application highlighted

 

 

Building the Thingy-9151-Lite Application for nRF9151/nRF9161 in the VSCode

Start VSCode, activate nRF Connect plugin.

If build configuration for the application does not exist yet (no build folder in the ‘Application’ window of nRF Connect plugin), create one by selecting 'Add build configuration' and accepting defaults.

Select build configuration, use ‘Build' in the 'Actions’ window of the nRF Connect plugin.

 

nrfconnect_plugin_build.png
Button to start build highlighted

 

2.2. Developing on Application Core of nRF5340

Building Thingy-9151-Lite Application for nRF5340 (application core) from command line

Go to the application directory:

The boards subdirectory contains the configurations of the supported boards. The Nordic nRF5340 DK board is already supported in Zephyr, so it is configured using the devicetree overlay:

 

Build the application for nRF5340 DK using the following command:

The resulting image is build/zephyr/merged.hex.

Importing the Thingy-9151-Lite Application for nRF5340 (application core) into the VSCode

Start VSCode, activate nRF Connect plugin, select ‘Open an existing application', navigate to <west_init>/nrf-app/thingy9151lite_nrf5340_cpuapp_app, press 'Open'

Building the Thingy-9151-Lite Application for nRF5340 (application core) in the VSCode

Start VSCode, activate nRF Connect plugin.

If build configuration for the application does not exist yet (no build folder in the ‘Application’ window of nRF Connect plugin), create one by selecting 'Add build configuration' and accepting defaults.

Select build configuration, use ‘Build' in the 'Actions’ window of the nRF Connect plugin.

2.2. Developing on Network Core of nRF5340

Building Thingy-9151-Lite Application for nRF5340 DK (network core)

Go to the application directory:

The boards subdirectory contains the configurations of the supported boards. The Nordic nRF5340 DK board is already supported in Zephyr, so it is configured using the devicetree overlay:

Build the application for nRF5340 DK using the following command:

The resulting image is build/zephyr/zephyr.hex.

Importing the Thingy-9151-Lite Application for nRF5340 (network core) into the VSCode

Start VSCode, activate nRF Connect plugin, select ‘Open an existing application', navigate to <west_init>/nrf-app/thingy9151lite_nrf5340_cpunet_app, press 'Open'

Building the Thingy-9151-Lite Application for nRF5340 (network core) in the VSCode

Start VSCode, activate nRF Connect plugin.

If build configuration for the application does not exist yet (no build folder in the ‘Application’ window of nRF Connect plugin), create one by selecting 'Add build configuration' and accepting defaults.

Select build configuration, use ‘Build' in the 'Actions’ window of the nRF Connect plugin.

Debugging Zephyr BSP and Application

Debugging in VSCode

Follow Nordic instructions on debugging in VSCode.

 

 

In case manual installation was followed and west complains about missing Python dependencies when trying to install firmware on board, use the following tricks:

  • activate Python virtual environment by running <venv dir>\Scripts\activate.bat

  • start VSCode with application folder set as current

To make startup easier create cmd.exe script that will setup environment and launch VSCode and create desktop icon for it.