This page describes how to run examples included in the nRF5 SDK for Mesh package.
Just as with installing the toolchain and building the mesh stack and examples, the procedure for running examples depends on the IDE.
Once you have an example running, you can interact with it through command line with SEGGER RTT.
Table of contents
The following procedure only works if you have built the example with SEGGER Embedded Studio.
To run the examples in a build environment based on SEGGER Embedded Studio (SES):
If the debugging does not start, reset the J-Link: Target -> Reset J-Link.
After you built the example with CMake, you can run the example using either:
Both use files created by CMake to compile the project.
You can run custom CMake targets using either ninja or make. Depending on you choice, you have to use different commands:
Flash the example by running one of the following commands from the build
directory:
ninja flash_<target-name>
. Example: build $ ninja flash_light_switch_server_nrf52832_xxAA_s132_6.1.0
make flash_<target-name>
. Example: build $ make flash_light_switch_server_nrf52832_xxAA_s132_6.1.0
ninja
build tool: ninja -t targets
or ninja help
make
: make help
After you issue the command to flash the example, the build system checks whether the example binaries are up-to-date. If required, it rebuilds them before flashing. It then displays a list of connected boards.
Running examples using nrfjprog
command line tool requires you to program a SoftDevice and the example hex file to your board.
You need to know the path to SoftDevice binaries to run examples with nrfjprog
. The SoftDevice binaries are located in the bin/softdevice/
folder. The example binaries are built in the corresponding example folder, in the build/
directory.
If you do not know the SoftDevice version that was used to build the mesh stack, check the name of the example binary. For example, if the example's binary name is light_switch_client_nrf52832_xxAA_s132_6.1.0.hex
, the required SoftDevice binary is s132_nrf52_6.1.0_softdevice.hex
.
To run an example with nrfjprog
:
nrfjprog --program <path_to_the_example_binary_file> --chiperase
. Example: nrf5_sdk_for_mesh$ nrfjprog --program ./bin/softdevice/s132_6.1.0/s132_nrf52_6.1.0_softdevice.hex --chiperase
nrfjprog --program <path_to_the_example_binary_file> --sectorerase
. Example: nrf5_sdk_for_mesh$ nrfjprog --program ./build/examples/light_switch/client/light_switch_client_nrf52832_xxAA_s132_6.1.0.hex --sectorerase
nrfjprog -r
. Soft-reset is particularly useful if you want to use the debugger or RTT viewer (see the following section) and prevent disconnection of the RTT link.The nRF5 SDK for Mesh examples can communicate with a host computer through SEGGER RTT, and several examples require or allow you to connect RTT viewer to observe output generated in the RTT log.
The RTT viewer is available as:
Only the standalone application allows you to issue commands through RTT, for example when testing Dimming examples (experimental).
SEGGER Embedded Studio (SES) has a built-in RTT Viewer available when debugging the target code.
To see the RTT output generated when using SES, build and run the example. Once debugging starts, the RTT communication with the device will be available in the Debug Terminal window.
nRF5x Command Line Tools come with the standalone J-Link RTT Viewer tool that can be used when using both CMake or SEGGER.
To see the RTT log of single development boards in this tool, make sure you connect the nRF5 boards to the USB ports. When the boards are connected, complete the following steps for each board:
After flashing the example firmware and running the example, you will see output printed in the RTT log while testing.
Refer to SEGGER J-Link documentation for more details about how to set up an RTT session using the J-Link RTT Viewer.