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.
To run the examples in a build environment based on SEGGER Embedded Studio (SES):
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 examples can communicate with a host computer through SEGGER RTT.
SEGGER Embedded Studio has a built-in RTT Viewer available when debugging the target code (go to Build -> Build and Debug
). Once debugging starts, the RTT communication with the device will be available in the Debug Terminal
window.
When using command line tools, you can use the standalone J-Link RTT Viewer tool (included in the J-Link toolchain) to communicate with the device. Refer to SEGGER J-Link documentation for details on how to set up an RTT session using the J-Link RTT Viewer.