blob: 14385357bc56df596cec4db993570da619fcad0f [file] [log] [blame] [view]
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +02001# Matter nRF Connect Lock Example Application
Damian Królik34a4a932020-07-20 20:07:50 +02002
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +02003> **Note:** This example is intended only to perform smoke tests of a Matter
4> solution integrated with nRF Connect SDK platform. The example quality is not
5> production ready and it may contain minor bugs or use not optimal
6> configuration. It is not recommended to use this example as a basis for
7> creating a market ready product.
8>
9> For the production ready and optimized Matter samples, see
10> [nRF Connect SDK samples](https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/matter.html).
11> The Matter samples in nRF Connect SDK use various additional software
12> components and provide multiple optional features that improve the developer
13> and user experience. To read more about it, see
14> [Matter support in nRF Connect SDK](https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/matter/index.html#ug-matter)
15> page. Using Matter samples from nRF Connect SDK allows you to get a full
16> Nordic technical support via [DevZone](https://devzone.nordicsemi.com/)
17> portal.
18
Damian Królikee937e62020-12-07 15:46:30 +010019The nRF Connect Lock Example demonstrates how to remotely control a door lock
20device with one basic bolt. It uses buttons to test changing the lock and device
21states and LEDs to show the state of these changes. You can use this example as
22a reference for creating your own application.
23
Gaute Svanes Lundee7347ea2023-01-09 19:43:07 +010024<img src="../../platform/nrfconnect/doc/images/Logo_RGB_H-small.png" alt="Nordic Semiconductor logo"/>
25<img src="../../platform/nrfconnect/doc/images/nRF52840-DK-small.png" alt="nRF52840 DK">
Łukasz Duda4b61b4f2021-03-04 21:44:51 +010026
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +020027The example is based on
28[Matter](https://github.com/project-chip/connectedhomeip) and Nordic
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010029Semiconductor's nRF Connect SDK, and was created to facilitate testing and
30certification of a Matter device communicating over a low-power, 802.15.4 Thread
31network, or Wi-Fi network.
Damian Królikee937e62020-12-07 15:46:30 +010032
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +020033The example behaves as a Matter accessory, that is a device that can be paired
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010034into an existing Matter network and can be controlled by this network. In the
35case of Thread, this device works as a Thread Sleepy End Device. Support for
36both Thread and Wi-Fi is mutually exclusive and depends on the hardware
37platform, so only one protocol can be supported for a specific lock device.
Damian Królik34a4a932020-07-20 20:07:50 +020038
39<hr>
40
Damian Królikee937e62020-12-07 15:46:30 +010041## Overview
Damian Królik34a4a932020-07-20 20:07:50 +020042
Łukasz Duda4b61b4f2021-03-04 21:44:51 +010043This example is running on the nRF Connect platform, which is based on Nordic
44Semiconductor's
Damian Królikee937e62020-12-07 15:46:30 +010045[nRF Connect SDK](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/index.html)
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +020046and [Zephyr RTOS](https://zephyrproject.org/). Visit Matter's
Damian Królikee937e62020-12-07 15:46:30 +010047[nRF Connect platform overview](../../../docs/guides/nrfconnect_platform_overview.md)
48to read more about the platform structure and dependencies.
Damian Królik34a4a932020-07-20 20:07:50 +020049
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010050By default, the Matter accessory device has IPv6 networking disabled. You must
51pair it with the Matter controller over Bluetooth® LE to get the configuration
52from the controller to use the device within a Thread or Wi-Fi network. You have
53to make the device discoverable manually (for security reasons). See
54[Bluetooth LE advertising](#bluetooth-le-advertising) to learn how to do this.
55The controller must get the commissioning information from the Matter accessory
56device and provision the device into the network.
Damian Królik34a4a932020-07-20 20:07:50 +020057
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010058The sample uses buttons for changing the lock and device states, and LEDs to
59show the state of these changes. You can test it in the following ways:
60
61- Standalone, using a single DK that runs the door lock application.
62
63- Remotely over the Thread or the Wi-Fi protocol, which in either case
64 requires more devices, including a Matter controller that you can configure
65 either on a PC or a mobile device.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +020066
Damian Królikee937e62020-12-07 15:46:30 +010067### Bluetooth LE advertising
68
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +020069In this example, to commission the device onto a Matter network, it must be
doru919d0d48f2021-01-28 20:45:01 +020070discoverable over Bluetooth LE. For security reasons, you must start Bluetooth
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010071LE advertising manually after powering up the device by pressing:
72
73- On nRF52840 DK, nRF5340 DK, and nRF21540 DK: **Button 4**.
74
75- On nRF7002 DK: **Button 2**.
Damian Królikee937e62020-12-07 15:46:30 +010076
77### Bluetooth LE rendezvous
78
Damian Królikc3edd9a2021-07-03 03:59:59 +020079In this example, the commissioning procedure is done over Bluetooth LE between a
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +020080Matter device and the Matter controller, where the controller has the
81commissioner role.
Damian Królikee937e62020-12-07 15:46:30 +010082
83To start the rendezvous, the controller must get the commissioning information
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +020084from the Matter device. The data payload is encoded within a QR code, printed to
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010085the UART console, and shared using an NFC tag. The emulation of the NFC tag
86emulation starts automatically when Bluetooth LE advertising is started and
87stays enabled until Bluetooth LE advertising timeout expires.
Damian Królikee937e62020-12-07 15:46:30 +010088
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010089#### Thread or Wi-Fi provisioning
Damian Królikee937e62020-12-07 15:46:30 +010090
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +010091The provisioning operation, which is the Last part of the rendezvous procedure,
92involves sending the Thread or Wi-Fi network credentials from the Matter
93controller to the Matter device. As a result, the device joins the Thread or
94Wi-Fi network and can communicate with other devices in the network.
Damian Królikee937e62020-12-07 15:46:30 +010095
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +020096### Device Firmware Upgrade
97
Damian Królik967d6fd2022-03-02 18:37:05 +010098The example supports over-the-air (OTA) device firmware upgrade (DFU) using one
99of the two available methods:
100
101- Matter OTA update that is mandatory for Matter-compliant devices and enabled
102 by default
103- [Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt)
104 over Bluetooth LE, an optional proprietary method that can be enabled to
105 work alongside the default Matter OTA update. Note that this protocol is not
106 a part of the Matter specification.
107
108For both methods, the
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200109[MCUboot](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/index.html)
Damian Królik967d6fd2022-03-02 18:37:05 +0100110bootloader solution is used to replace the old firmware image with the new one.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200111
Damian Królik967d6fd2022-03-02 18:37:05 +0100112#### Matter Over-the-Air Update
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200113
Damian Królik967d6fd2022-03-02 18:37:05 +0100114The Matter over-the-air update distinguishes two types of nodes: OTA Provider
115and OTA Requestor.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200116
Damian Królik967d6fd2022-03-02 18:37:05 +0100117An OTA Provider is a node that hosts a new firmware image and is able to respond
118on an OTA Requestor's queries regarding availability of new firmware images or
119requests to start sending the update packages.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200120
Damian Królik967d6fd2022-03-02 18:37:05 +0100121An OTA Requestor is a node that wants to download a new firmware image and sends
122requests to an OTA Provider to start the update process.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200123
124#### Simple Management Protocol
125
126Simple Management Protocol (SMP) is a basic transfer encoding that is used for
127device management purposes, including application image management. SMP supports
128using different transports, such as Bluetooth LE, UDP, or serial USB/UART.
129
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +0200130In this example, the Matter device runs the SMP Server to download the
131application update image using the Bluetooth LE transport.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200132
133See the
134[Building with Device Firmware Upgrade support](#building-with-device-firmware-upgrade-support)
135section to learn how to enable SMP and use it for the DFU purpose in this
136example.
137
Damian Królik967d6fd2022-03-02 18:37:05 +0100138#### Bootloader
139
140MCUboot is a secure bootloader used for swapping firmware images of different
141versions and generating proper build output files that can be used in the device
142firmware upgrade process.
143
144The bootloader solution requires an area of flash memory to swap application
145images during the firmware upgrade. Nordic Semiconductor devices use an external
146memory chip for this purpose. The memory chip communicates with the
147microcontroller through the QSPI bus.
148
149See the
150[Building with Device Firmware Upgrade support](#building-with-device-firmware-upgrade-support)
151section to learn how to change MCUboot and flash configuration in this example.
152
Damian Królikee937e62020-12-07 15:46:30 +0100153<hr>
154
Damian Królikee937e62020-12-07 15:46:30 +0100155## Requirements
156
Kamil Kasperczyke4ab6f42021-03-11 15:17:03 +0100157The application requires a specific revision of the nRF Connect SDK to work
158correctly. See [Setting up the environment](#setting-up-the-environment) for
159more information.
Damian Królikee937e62020-12-07 15:46:30 +0100160
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100161### Supported devices
162
Damian Królikee937e62020-12-07 15:46:30 +0100163The example supports building and running on the following devices:
164
Grzegorz Ferenca2e32062023-03-17 20:07:17 +0100165| Hardware platform | Build target | Platform image |
166| ----------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200167| [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_info-medium.jpg" alt="nRF52840 DK"/></details> |
168| [nRF5340 DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK) | `nrf5340dk/nrf5340/cpuapp` | <details><summary>nRF5340 DK</summary><img src="../../platform/nrfconnect/doc/images/nRF5340_DK_info-medium.jpg" alt="nRF5340 DK"/></details> |
169| [nRF7002 DK](https://www.nordicsemi.com/Products/Development-hardware/nRF7002-DK) | `nrf7002dk/nrf5340/cpuapp` | <details><summary>nRF7002 DK</summary><img src="../../platform/nrfconnect/doc/images/nRF7002-DK_Front-small.png" alt="nRF7002 DK"/></details> |
Damian Królikee937e62020-12-07 15:46:30 +0100170
171<hr>
Damian Królik34a4a932020-07-20 20:07:50 +0200172
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100173### IPv6 network support
174
175The development kits for this sample offer the following IPv6 network support
176for Matter:
177
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200178- Matter over Thread is supported for `nrf52840dk/nrf52840` and
179 `nrf5340dk/nrf5340/cpuapp`.
180- Matter over Wi-Fi is supported for `nrf7002dk/nrf5340/cpuapp`.
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100181
Damian Królik34a4a932020-07-20 20:07:50 +0200182## Device UI
183
Damian Królikee937e62020-12-07 15:46:30 +0100184This section lists the User Interface elements that you can use to control and
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100185monitor the state of the device. These correspond to PCB components on the
186platform image.
Damian Królik34a4a932020-07-20 20:07:50 +0200187
Damian Królikee937e62020-12-07 15:46:30 +0100188**LED 1** shows the overall state of the device and its connectivity. The
189following states are possible:
190
191- _Short Flash On (50 ms on/950 ms off)_ &mdash; The device is in the
Damian Królik34a4a932020-07-20 20:07:50 +0200192 unprovisioned (unpaired) state and is waiting for a commissioning
193 application to connect.
194
Damian Królikee937e62020-12-07 15:46:30 +0100195- _Rapid Even Flashing (100 ms on/100 ms off)_ &mdash; The device is in the
196 unprovisioned state and a commissioning application is connected through
197 Bluetooth LE.
Damian Królik34a4a932020-07-20 20:07:50 +0200198
Damian Królik994af3c2020-10-12 16:50:50 +0200199- _Short Flash Off (950ms on/50ms off)_ &mdash; The device is fully
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100200 provisioned, but does not yet have full connectivity for Thread or Wi-Fi
201 network.
Damian Królik34a4a932020-07-20 20:07:50 +0200202
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100203- _Solid On_ &mdash; The device is fully provisioned.
Damian Królik34a4a932020-07-20 20:07:50 +0200204
Damian Królikee937e62020-12-07 15:46:30 +0100205**LED 2** simulates the lock bolt and shows the state of the lock. The following
206states are possible:
Damian Królik34a4a932020-07-20 20:07:50 +0200207
Damian Królikee937e62020-12-07 15:46:30 +0100208- _Solid On_ &mdash; The bolt is extended and the door is locked.
Damian Królik34a4a932020-07-20 20:07:50 +0200209
Damian Królikee937e62020-12-07 15:46:30 +0100210- _Off_ &mdash; The bolt is retracted and the door is unlocked.
Damian Królik34a4a932020-07-20 20:07:50 +0200211
Damian Królikee937e62020-12-07 15:46:30 +0100212- _Rapid Even Flashing (100 ms on/100 ms off during 2 s)_ &mdash; The
213 simulated bolt is in motion from one position to another.
Damian Królik34a4a932020-07-20 20:07:50 +0200214
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100215 Additionally, the LED starts blinking evenly (500 ms on/500 ms off) when the
216 Identify command of the Identify cluster is received on the endpoint 1. The
217 command’s argument can be used to specify the duration of the effect.
Krzysztof Taborowski6bb7ff62020-08-21 21:22:46 +0200218
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100219**Button 1** can be used for the following purposes:
Kamil Kasperczyk8a84d972020-10-28 19:57:37 +0100220
Damian Królikee937e62020-12-07 15:46:30 +0100221- _Pressed for less than 3 s_ &mdash; Initiates the OTA software update
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200222 process. This feature is disabled by default, but can be enabled by
223 following the
224 [Building with Device Firmware Upgrade support](#building-with-device-firmware-upgrade-support)
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100225 instructions.
226
227- _Pressed for more than 3 s_ &mdash; initiates the factory reset of the
228 device. Releasing the button within the 3-second window cancels the factory
229 reset procedure.
Kamil Kasperczyk005b7ae2020-11-05 17:42:51 +0100230
Damian Królikee937e62020-12-07 15:46:30 +0100231**Button 2** &mdash; Pressing the button once changes the lock state to the
232opposite one.
Kamil Kasperczyk005b7ae2020-11-05 17:42:51 +0100233
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100234- On nRF52840 DK, nRF5340 DK, and nRF21540 DK: Changes the lock state to the
235 opposite one.
236
237- On nRF7002 DK:
238
239 - If pressed for less than three seconds, it changes the lock state to the
240 opposite one.
241
242 - If pressed for more than three seconds, it starts the NFC tag emulation,
243 enables Bluetooth LE advertising for the predefined period of time (15
244 minutes by default), and makes the device discoverable over Bluetooth
245 LE.
246
247**Button 4**:
248
249- On nRF52840 DK, nRF5340 DK, and nRF21540 DK: Starts the NFC tag emulation,
250 enables Bluetooth LE advertising for the predefined period of time (15
251 minutes by default), and makes the device discoverable over Bluetooth LE.
252 This button is used during the commissioning procedure.
253
254- On nRF7002 DK: Not available.
Damian Królikee937e62020-12-07 15:46:30 +0100255
256**SEGGER J-Link USB port** can be used to get logs from the device or
257communicate with it using the
258[command line interface](../../../docs/guides/nrfconnect_examples_cli.md).
259
260**NFC port with antenna attached** can be used to start the
261[rendezvous](#bluetooth-le-rendezvous) by providing the commissioning
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +0200262information from the Matter device in a data payload that can be shared using
263NFC.
Damian Królikee937e62020-12-07 15:46:30 +0100264
265<hr>
266
267## Setting up the environment
268
Grzegorz Ferencbae3e7d2021-10-19 15:49:45 +0200269Before building the example, check out the Matter repository and sync submodules
Damian Królikee937e62020-12-07 15:46:30 +0100270using the following command:
271
Lipinski Patryk907a4862023-11-14 12:07:46 +0100272 $ python3 scripts/checkout_submodules.py --shallow --platform nrfconnect
Damian Królikee937e62020-12-07 15:46:30 +0100273
Lipinski Patryk907a4862023-11-14 12:07:46 +0100274> **Note**:
275>
276> For Linux operating system install
277> [SEGGER J-Link Software](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack).
Damian Królikee937e62020-12-07 15:46:30 +0100278
Lipinski Patryk907a4862023-11-14 12:07:46 +0100279### Install Command Line Tools
Damian Królikee937e62020-12-07 15:46:30 +0100280
Lipinski Patryk907a4862023-11-14 12:07:46 +0100281With admin permissions enabled, download and install the
282[nRF Command Line Tools](https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools).
Damian Królikee937e62020-12-07 15:46:30 +0100283
Lipinski Patryk907a4862023-11-14 12:07:46 +0100284### Install Toolchain Manager
Damian Królikee937e62020-12-07 15:46:30 +0100285
Lipinski Patryk907a4862023-11-14 12:07:46 +0100286Toolchain Manager is available from
287[nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nrf-connect-for-desktop),
288a cross-platform tool that provides different applications that simplify
289installing the nRF Connect SDK. Both the tool and the application are available
290for Windows, Linux, and macOS.
Damian Królikee937e62020-12-07 15:46:30 +0100291
Lipinski Patryk907a4862023-11-14 12:07:46 +0100292To install the Toolchain Manager app, complete the following steps:
Damian Królikee937e62020-12-07 15:46:30 +0100293
Lipinski Patryk907a4862023-11-14 12:07:46 +01002941. [Download nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nrf-connect-for-desktop/download#infotabs)
295 for your operating system.
Damian Królikee937e62020-12-07 15:46:30 +0100296
Lipinski Patryk907a4862023-11-14 12:07:46 +01002972. Install and run the tool on your machine.
Damian Królikee937e62020-12-07 15:46:30 +0100298
Lipinski Patryk907a4862023-11-14 12:07:46 +01002993. In the **APPS** section, click **Install** button on the Toolchain Manager
300 tab.
Damian Królikee937e62020-12-07 15:46:30 +0100301
Lipinski Patryk907a4862023-11-14 12:07:46 +0100302### Install nRF Connect SDK
Damian Królikee937e62020-12-07 15:46:30 +0100303
Lipinski Patryk907a4862023-11-14 12:07:46 +0100304Complete the following steps to install the nRF Connect SDK:
Damian Królikee937e62020-12-07 15:46:30 +0100305
Lipinski Patryk907a4862023-11-14 12:07:46 +01003061. Open Toolchain Manager in nRF Connect for Desktop.
Damian Królikee937e62020-12-07 15:46:30 +0100307
Lipinski Patryk907a4862023-11-14 12:07:46 +01003082. Click the **Install** button next to the
309 [recommended](../../../config/nrfconnect/.nrfconnect-recommended-revision)
310 version of the nRF Connect SDK.
Damian Królikee937e62020-12-07 15:46:30 +0100311
Lipinski Patryk907a4862023-11-14 12:07:46 +01003123. A pop-up window will inform you about the current installation directory. If
313 you want to change the directory, click the **Change directory** button.
314 Otherwise, click the **Continue installation** button.
315
3164. When the nRF Connect SDK is installed on your machine, the **Install**
317 button changes to the **Open VS Code** button.
318
3195. Click the dropdown menu next to the **Open VS Code** button for the
320 installed nRF Connect SDK version, and select **Open terminal**.
321
3226. Make sure that the nRF Connect SDK version is compatible with the Matter SDK
323 version:
324
325 ```
326 $ cd {connectedhomeip directory}
Kamil Kasperczyke4ab6f42021-03-11 15:17:03 +0100327 $ python3 scripts/setup/nrfconnect/update_ncs.py --update
Lipinski Patryk907a4862023-11-14 12:07:46 +0100328 ```
Kamil Kasperczyke4ab6f42021-03-11 15:17:03 +0100329
Damian Królikee937e62020-12-07 15:46:30 +0100330Now you can proceed with the [Building](#building) instruction.
331
332<hr>
Damian Królik34a4a932020-07-20 20:07:50 +0200333
Damian Królik34a4a932020-07-20 20:07:50 +0200334## Building
335
Lipinski Patryk907a4862023-11-14 12:07:46 +0100336Complete the following steps to build the sample:
Damian Królik1ace1932020-09-08 17:51:37 +0200337
Damian Królikee937e62020-12-07 15:46:30 +01003381. Navigate to the example's directory:
Damian Królik994af3c2020-10-12 16:50:50 +0200339
Damian Królikee937e62020-12-07 15:46:30 +0100340 $ cd examples/lock-app/nrfconnect
Damian Królik1ace1932020-09-08 17:51:37 +0200341
Łukasz Duda4b61b4f2021-03-04 21:44:51 +01003422. Run the following command to build the example, with _build-target_ replaced
343 with the build target name of the Nordic Semiconductor's kit you own, for
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200344 example `nrf52840dk/nrf52840`:
Damian Królik1ace1932020-09-08 17:51:37 +0200345
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200346 $ west build -b build-target --sysbuild
Damian Królik1ace1932020-09-08 17:51:37 +0200347
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100348 You only need to specify the build target on the first build. See
349 [Requirements](#requirements) for the build target names of compatible kits.
Damian Królik1ace1932020-09-08 17:51:37 +0200350
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200351The output `zephyr.hex` file will be available in the `build/nrfconnect/zephyr/`
352directory.
Damian Królik1ace1932020-09-08 17:51:37 +0200353
Damian Królikee937e62020-12-07 15:46:30 +0100354### Removing build artifacts
Damian Królik1ace1932020-09-08 17:51:37 +0200355
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100356If you're planning to build the example for a different kit or make changes to
Damian Królikee937e62020-12-07 15:46:30 +0100357the configuration, remove all build artifacts before building. To do so, use the
358following command:
Damian Królik1ace1932020-09-08 17:51:37 +0200359
Damian Królikee937e62020-12-07 15:46:30 +0100360 $ rm -r build
Damian Królik1ace1932020-09-08 17:51:37 +0200361
Damian Królikee937e62020-12-07 15:46:30 +0100362### Building with release configuration
Damian Królik1ace1932020-09-08 17:51:37 +0200363
Damian Królikee937e62020-12-07 15:46:30 +0100364To build the example with release configuration that disables the diagnostic
365features like logs and command-line interface, run the following command:
Damian Królik34a4a932020-07-20 20:07:50 +0200366
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200367 $ west build -b build-target --sysbuild -- -DFILE_SUFFIX=release
Damian Królik34a4a932020-07-20 20:07:50 +0200368
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100369Remember to replace _build-target_ with the build target name of the Nordic
370Semiconductor's kit you own.
Damian Królik34a4a932020-07-20 20:07:50 +0200371
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200372### Building with Device Firmware Upgrade support
373
Damian Królik967d6fd2022-03-02 18:37:05 +0100374Support for DFU using Matter OTA is enabled by default.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200375
Damian Królik967d6fd2022-03-02 18:37:05 +0100376To enable DFU over Bluetooth LE, run the following command with _build-target_
377replaced with the build target name of the Nordic Semiconductor kit you are
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200378using (for example `nrf52840dk/nrf52840`):
Damian Królik967d6fd2022-03-02 18:37:05 +0100379
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200380 $ west build -b build-target --sysbuild -- -DCONFIG_CHIP_DFU_OVER_BT_SMP=y
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200381
Kamil Kasperczyk109214f2021-10-01 15:12:35 +0200382> **Note**:
383>
384> There are two types of Device Firmware Upgrade modes: single-image DFU and
385> multi-image DFU. Single-image mode supports upgrading only one firmware image,
386> the application image, and should be used for single-core nRF52840 DK devices.
387> Multi-image mode allows to upgrade more firmware images and is suitable for
388> upgrading the application core and network core firmware in two-core nRF5340
389> DK devices.
390
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200391#### Changing bootloader configuration
392
Kamil Kasperczykfcf08c82022-04-07 21:41:37 +0200393To change the default MCUboot configuration, edit the `prj.conf` file located in
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200394the `sysbuild/mcuboot` directory.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200395
Kamil Kasperczyk109214f2021-10-01 15:12:35 +0200396Make sure to keep the configuration consistent with changes made to the
397application configuration. This is necessary for the configuration to work, as
398the bootloader image is a separate application from the user application and it
399has its own configuration file.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200400
401#### Changing flash memory settings
402
403In the default configuration, the MCUboot uses the
404[Partition Manager](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html#partition-manager)
405to configure flash partitions used for the bootloader application image slot
406purposes. You can change these settings by defining
407[static partitions](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html#ug-pm-static).
408This example uses this option to define using an external flash.
409
410To modify the flash settings of your board (that is, your _build-target_, for
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200411example `nrf52840dk/nrf52840`), edit the `pm_static_<build_target>.yml` file
412(for example `pm_static_nrf52840dk_nrf52840.yml`), located in the main
413application directory.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200414
Damian Królikee937e62020-12-07 15:46:30 +0100415<hr>
Damian Królik19a520e2020-11-16 17:59:16 +0100416
Damian Królik34a4a932020-07-20 20:07:50 +0200417## Configuring the example
418
Damian Królikee937e62020-12-07 15:46:30 +0100419The Zephyr ecosystem is based on Kconfig files and the settings can be modified
420using the menuconfig utility.
Damian Królik34a4a932020-07-20 20:07:50 +0200421
Damian Królikee937e62020-12-07 15:46:30 +0100422To open the menuconfig utility, run the following command from the example
423directory:
Damian Królik34a4a932020-07-20 20:07:50 +0200424
Kamil Kasperczyk275c8c92024-07-29 22:09:45 +0200425 $ west build -b build-target --sysbuild -t menuconfig
Damian Królik34a4a932020-07-20 20:07:50 +0200426
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100427Remember to replace _build-target_ with the build target name of the Nordic
428Semiconductor's kit you own.
Damian Królik34a4a932020-07-20 20:07:50 +0200429
Damian Królikee937e62020-12-07 15:46:30 +0100430Changes done with menuconfig will be lost if the `build` directory is deleted.
431To make them persistent, save the configuration options in the `prj.conf` file.
Kamil Kasperczykdcca2432022-04-05 12:46:55 +0200432
433### Example build types
434
435The example uses different configuration files depending on the supported
436features. Configuration files are provided for different build types and they
Kamil Kasperczyk3be5bc42022-04-11 16:28:39 +0200437are located in the application root directory.
Kamil Kasperczykdcca2432022-04-05 12:46:55 +0200438
439The `prj.conf` file represents a debug build type. Other build types are covered
440by dedicated files with the build type added as a suffix to the prj part, as per
441the following list. For example, the release build type file name is
442`prj_release.conf`. If a board has other configuration files, for example
443associated with partition layout or child image configuration, these follow the
444same pattern.
445
446Before you start testing the application, you can select one of the build types
447supported by the sample. This sample supports the following build types,
448depending on the selected board:
449
450- debug -- Debug version of the application - can be used to enable additional
451 features for verifying the application behavior, such as logs or
452 command-line shell.
453- release -- Release version of the application - can be used to enable only
454 the necessary application functionalities to optimize its performance.
Kamil Kasperczykdcca2432022-04-05 12:46:55 +0200455
Damian Królikee937e62020-12-07 15:46:30 +0100456For more information, see the
457[Configuring nRF Connect SDK examples](../../../docs/guides/nrfconnect_examples_configuration.md)
458page.
Damian Królik34a4a932020-07-20 20:07:50 +0200459
Damian Królikee937e62020-12-07 15:46:30 +0100460<hr>
Damian Królik34a4a932020-07-20 20:07:50 +0200461
Damian Królik34a4a932020-07-20 20:07:50 +0200462## Flashing and debugging
463
Damian Królikee937e62020-12-07 15:46:30 +0100464To flash the application to the device, use the west tool and run the following
465command from the example directory:
Damian Królik34a4a932020-07-20 20:07:50 +0200466
Damian Królik35dfbc42021-04-06 18:54:18 +0200467 $ west flash --erase
Damian Królik34a4a932020-07-20 20:07:50 +0200468
Łukasz Duda4b61b4f2021-03-04 21:44:51 +0100469If you have multiple development kits connected, west will prompt you to pick
Damian Królikee937e62020-12-07 15:46:30 +0100470the correct one.
Damian Królik34a4a932020-07-20 20:07:50 +0200471
Damian Królikee937e62020-12-07 15:46:30 +0100472To debug the application on target, run the following command from the example
473directory:
Damian Królik34a4a932020-07-20 20:07:50 +0200474
Damian Królik34a4a932020-07-20 20:07:50 +0200475 $ west debug
476
Damian Królikee937e62020-12-07 15:46:30 +0100477<hr>
Damian Królik34a4a932020-07-20 20:07:50 +0200478
Damian Królikee937e62020-12-07 15:46:30 +0100479## Testing the example
Damian Królik34a4a932020-07-20 20:07:50 +0200480
Damian Królikee937e62020-12-07 15:46:30 +0100481Check the [CLI tutorial](../../../docs/guides/nrfconnect_examples_cli.md) to
482learn how to use command-line interface of the application.
Kamil Kasperczyk1073ccf2021-02-01 17:35:59 +0100483
Kamil Kasperczyk3b966522022-10-10 19:04:49 +0200484### Testing using Linux CHIPTool
485
486Read the [CHIP Tool user guide](../../../docs/guides/chip_tool_guide.md) to see
487how to use [CHIP Tool for Linux or mac OS](../../chip-tool/README.md) to
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100488commission and control the application within a Matter-enabled Thread or Wi-Fi
489network.
Kamil Kasperczyk3b966522022-10-10 19:04:49 +0200490
491### Testing using Android CHIPTool
Kamil Kasperczyk1073ccf2021-02-01 17:35:59 +0100492
493Read the
494[Android commissioning guide](../../../docs/guides/nrfconnect_android_commissioning.md)
Yufeng Wanga3347142022-09-29 15:22:36 -0700495to see how to use [CHIPTool](../../../examples/android/CHIPTool/README.md) for
Kamil Kasperczyk1073ccf2021-02-01 17:35:59 +0100496Android smartphones to commission and control the application within a
Arkadiusz Bałyse6a1e8e2022-11-25 15:50:18 +0100497Matter-enabled Thread or Wi-Fi network.
Kamil Kasperczyk329ea7c2021-05-10 15:44:39 +0200498
499### Testing Device Firmware Upgrade
500
Kamil Kasperczyk17821b92021-06-02 00:10:40 +0200501Read the
502[DFU tutorial](../../../docs/guides/nrfconnect_examples_software_update.md) to
503see how to upgrade your device firmware.