1 # CHIP nRF Connect Pigweed Example Application
3 The nRF Connect Pigweed Example demonstrates the usage of Pigweed module
4 functionalities in an application.
7 <img src="../../platform/nrfconnect/doc/images/Logo_RGB_H-small.png" alt="Nordic Semiconductor logo"/>
8 <img src="../../platform/nrfconnect/doc/images/nRF52840-DK-small.png" alt="nRF52840 DK">
11 The example is based on [CHIP](https://github.com/project-chip/connectedhomeip),
12 the [Pigweed](https://pigweed.googlesource.com/pigweed/pigweed) module, which is
13 a collection of libraries that provide different functionalities for embedded
14 systems, and Nordic Semiconductor's nRF Connect SDK.
16 You can use this example as a training ground for making experiments, testing
17 Pigweed module features and checking what actions are necessary to fully
18 integrate Pigweed in a CHIP project.
20 Pigweed functionalities are being gradually integrated into CHIP. Currently, the
21 following features are available:
23 - **Echo RPC** - Creates a Remote Procedure Call server and allows sending
24 commands through the serial port to the device, which makes echo and sends
25 the received commands back.
29 - [Overview](#overview)
30 - [Requirements](#requirements)
31 - [Supported devices](#supported_devices)
32 - [Device UI](#device-ui)
33 - [Setting up the environment](#setting-up-the-environment)
34 - [Using Docker container for setup](#using-docker-container-for-setup)
35 - [Using native shell for setup](#using-native-shell-for-setup)
36 - [Building](#building)
37 - [Configuring the example](#configuring-the-example)
38 - [Flashing and debugging](#flashing-and-debugging)
39 - [Flashing on the nRF52840 DK](#nrf52840dk_flashing)
40 - [Flashing on the nRF52840 Dongle](#nrf52840dongle_flashing)
41 - [Testing the example](#testing-the-example)
45 <a name="overview"></a>
49 This example is running on the nRF Connect platform, which is based on the
50 [nRF Connect SDK](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/index.html)
51 and [Zephyr RTOS](https://zephyrproject.org/). Visit CHIP's
52 [nRF Connect platform overview](../../../docs/guides/nrfconnect_platform_overview.md)
53 to read more about the platform structure and dependencies.
55 Pigweed libraries are built and organized in a way that enables faster and more
56 reliable development. In the CHIP project, the Pigweed module is planned to be
57 used to create system infrastructures, for example for performing on-device
58 tests, but considering its general functionalities, it can be useful also in
63 <a name="requirements"></a>
67 The application requires the nRF Connect SDK v1.5.0 to work correctly.
69 <a name="supported_devices"></a>
73 The example supports building and running on the following devices:
75 | Hardware platform | Build target | Platform image |
76 | ------------------------------------------------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
77 | [nRF52840 Dongle](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle) | `nrf52840dongle_nrf52840` | <details><summary>nRF52840 Dongle</summary><img src="../../platform/nrfconnect/doc/images/nRF52840-Dongle-small.jpg" alt="nRF52840 Dongle"/></details> |
78 | [nRF52840 DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK) | `nrf52840dk_nrf52840` | <details><summary>nRF52840 DK</summary><img src="../../platform/nrfconnect/doc/images/nRF52840-DK_top-view-small.jpg" alt="nRF52840 DK"/></details> |
82 <a name="device-ui"></a>
86 This section lists the User Interface elements that you can use to control and
87 monitor the state of the device. These correspond to PCB components on the
90 **LED 1** shows the overall state of the device. The following states are
93 - _Solid On_ — The application was flashed and ran successfully.
95 **Serial port** can be used to communicate with the device by sending commands
96 and receiving responses.
100 > Please note that supported hardware platforms are using different transport
101 > interfaces to perform serial communication, which leads to differences in
102 > configuration. By default, these interfaces are used:
104 > - `nrf52840dk_nrf52840` - UART interface routed to the SEGGER J-Link USB
106 > - `nrf52840dongle_nrf52840` - USB interface routed to the USB port.
110 ## Setting up the environment
112 Before building the example, check out the CHIP repository and sync submodules
113 using the following command:
115 $ git submodule update --init
117 The example requires the nRF Connect SDK v1.5.0. You can either install it along
118 with the related tools directly on your system or use a Docker image that has
119 the tools pre-installed.
121 If you are a macOS user, you won't be able to use the Docker container to flash
122 the application onto a Nordic development kit due to
123 [certain limitations of Docker for macOS](https://docs.docker.com/docker-for-mac/faqs/#can-i-pass-through-a-usb-device-to-a-container).
124 Use the [native shell](#using-native-shell) for building instead.
126 ### Using Docker container for setup
128 To use the Docker container for setup, complete the following steps:
130 1. If you do not have the nRF Connect SDK installed yet, create a directory for
131 it by running the following command:
135 2. Download the latest version of the nRF Connect SDK Docker image by running
136 the following command:
138 $ docker pull nordicsemi/nrfconnect-chip
140 3. Start Docker with the downloaded image by running the following command,
141 customized to your needs as described below:
143 $ docker run --rm -it -e RUNAS=$(id -u) -v ~/nrfconnect:/var/ncs -v ~/connectedhomeip:/var/chip \
144 -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" nordicsemi/nrfconnect-chip
148 - _~/nrfconnect_ can be replaced with an absolute path to the nRF Connect
149 SDK source directory.
150 - _~/connectedhomeip_ must be replaced with an absolute path to the CHIP
152 - _-v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:_ rmw"\*
153 parameters can be omitted if you are not planning to flash the example
154 onto hardware. These parameters give the container access to USB devices
155 connected to your computer such as the nRF52840 DK.
156 - _--rm_ can be omitted if you do not want the container to be
157 auto-removed when you exit the container shell session.
158 - _-e RUNAS=\$(id -u)_ is needed to start the container session as the
159 current user instead of root.
161 4. Check out or update the nRF Connect SDK to the recommended `v1.5.0` version
162 by running the following command in the Docker container:
165 /var/ncs repository is empty. Do you wish to check out nRF Connect SDK sources [v1.5.0]? [Y/N] y
167 /var/chip repository is initialized, skipping...
169 Now you can proceed with the [Building](#building) instruction.
171 ### Using native shell for setup
173 To use the native shell for setup, complete the following steps:
175 1. Download and install the following additional software:
177 - [nRF Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools)
178 - [GN meta-build system](https://gn.googlesource.com/gn/)
180 2. Depending on whether you have the nRF Connect SDK installed:
183 [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#)
184 in the nRF Connect SDK documentation to install the nRF Connect SDK
185 v1.5.0. Since command-line tools will be used for building the example,
186 installing SEGGER Embedded Studio is not required.
188 - If you have an older version of the SDK installed, use the following
189 commands to update it to the recommended version. Replace
190 _nrfconnect-dir_ with the path to your nRF Connect SDK installation
193 $ cd nrfconnect-dir/nrf
195 $ git checkout v1.5.0
198 3. Initialize environment variables referred to by the CHIP and the nRF Connect
199 SDK build scripts. Replace _nrfconnect-dir_ with the path to your nRF
200 Connect SDK installation directory, and _toolchain-dir_ with the path to GNU
201 Arm Embedded Toolchain.
203 $ source nrfconnect-dir/zephyr/zephyr-env.sh
204 $ export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
205 $ export GNUARMEMB_TOOLCHAIN_PATH=toolchain-dir
207 Now you can proceed with the [Building](#building) instruction.
211 <a name="building"></a>
215 Complete the following steps, regardless of the method used for setting up the
218 1. Run the `activate.sh` script, regardless of the building strategy. The
219 script is required for building the Pigweed library. Use the following
222 $ source scripts/activate.sh
224 2. Navigate to the example's directory:
226 $ cd examples/pigweed-app/nrfconnect
228 3. Run the following command to build the example, with _build-target_ replaced
229 with the build target name of the Nordic Semiconductor's kit you own, for
230 example `nrf52840dk_nrf52840`:
232 $ west build -b build-target
234 You only need to specify the build target on the first build. See
235 [Requirements](#requirements) for the build target names of compatible kits.
237 The output `zephyr.hex` file will be available in the `build/zephyr/` directory.
239 ### Removing build artifacts
241 If you're planning to build the example for a different kit or make changes to
242 the configuration, remove all build artifacts before building. To do so, use the
249 <a name="configuring"></a>
251 ## Configuring the example
253 The Zephyr ecosystem is highly configurable and allows you to modify many
254 aspects of the application. The configuration system is based on Kconfig files
255 and the settings can be modified using the menuconfig utility.
257 To open the menuconfig utility, complete the following steps:
259 1. Go to the example directory by running the following command, with the
260 _example-dir_ directory name updated for your configuration:
264 2. Choose one of the following options:
266 - If you are running the build for the first time, run the following
269 $ west build -b nrf52840dk_nrf52840 -t menuconfig
271 - If you are running a subsequent build, run the following command:
273 $ west build -t menuconfig
275 - If you are running menuconfig with ninja, run the following commands:
277 $ cd example-dir/build
280 Changes done with menuconfig will be lost if the `build` directory is deleted.
281 To make them persistent, save the configuration options in the `prj.conf` file.
283 For more information, see the
284 [Configuring nRF Connect SDK examples](../../../docs/guides/nrfconnect_examples_configuration.md)
289 <a name="flashing"></a>
291 ## Flashing and debugging
293 The flashing and debugging procedure is different for the nRF52840 DK and the
296 <a name="nrf52840dk_flashing"></a>
298 ### Flashing on the nRF52840 DK
300 To flash the application to the device, use the west tool and run the following
301 commands, with the _example-dir_ directory name updated for your configuration:
306 If you have multiple nRF52840 development kits connected, west will prompt you
307 to pick the correct one.
309 To debug the application on target, run the following commands:
314 <a name="nrf52840dongle_flashing"></a>
316 ### Flashing on the nRF52840 Dongle
319 [Programming and Flashing nRF52840 Dongle](https://docs.zephyrproject.org/latest/boards/arm/nrf52840dongle_nrf52840/doc/index.html#programming-and-debugging)
320 to read more about flashing on the nRF52840 Dongle.
324 <a name="currently-implemented-features"></a>
326 ## Testing the example
328 Run the following command to start an interactive Python shell, where the Echo
329 RPC commands can be invoked:
331 python -m pw_hdlc.rpc_console --device /dev/ttyACM0 -b 115200 $CHIP_ROOT/third_party/pigweed/repo/pw_rpc/pw_rpc_protos/echo.proto -o /tmp/pw_rpc.out
333 To send an Echo RPC message, type the following command, where the actual
334 message is the text in quotation marks after the `msg=` phrase:
336 rpcs.pw.rpc.EchoService.Echo(msg="hi")