diff --git a/examples/all-clusters-app/nrfconnect/CMakeLists.txt b/examples/all-clusters-app/nrfconnect/CMakeLists.txt
index aa1d64716f67da..7be0cb1b8d3458 100644
--- a/examples/all-clusters-app/nrfconnect/CMakeLists.txt
+++ b/examples/all-clusters-app/nrfconnect/CMakeLists.txt
@@ -69,3 +69,7 @@ chip_configure_data_model(app
if(CONFIG_CHIP_OTA_REQUESTOR)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
+
+if (CONFIG_SHELL AND BOARD STREQUAL "nrf52840dongle_nrf52840")
+ target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUTrigger.cpp)
+endif()
diff --git a/examples/all-clusters-app/nrfconnect/README.md b/examples/all-clusters-app/nrfconnect/README.md
index 0b21af970bb412..f2b0657e1faa52 100644
--- a/examples/all-clusters-app/nrfconnect/README.md
+++ b/examples/all-clusters-app/nrfconnect/README.md
@@ -37,6 +37,8 @@ into an existing Matter network and can be controlled by this network.
- [Configuring the example](#configuring-the-example)
- [Example build types](#example-build-types)
- [Flashing and debugging](#flashing-and-debugging)
+ - [Flashing on the development kits](#nrfdks_flashing)
+ - [Flashing on the nRF52840 Dongle](#nrf52840dongle_flashing)
- [Testing the example](#testing-the-example)
- [Testing using CHIPTool](#testing-using-chiptool)
@@ -98,10 +100,11 @@ more information.
The example supports building and running on the following devices:
-| Hardware platform | Build target | Platform image |
-| ----------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
-| [nRF52840 DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK) | `nrf52840dk_nrf52840` | nRF52840 DK
|
-| [nRF5340 DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK) | `nrf5340dk_nrf5340_cpuapp` | nRF5340 DK
|
+| Hardware platform | Build target | Platform image |
+| ------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [nRF52840 DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK) | `nrf52840dk_nrf52840` | nRF52840 DK
|
+| [nRF5340 DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK) | `nrf5340dk_nrf5340_cpuapp` | nRF5340 DK
|
+| [nRF52840 Dongle](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle) | `nrf52840dongle_nrf52840` | nRF52840 Dongle
|
@@ -113,6 +116,15 @@ This section lists the User Interface elements that you can use to control and
monitor the state of the device. These correspond to PCB components on the
platform image.
+> **Note**:
+>
+> The following Device UI elements are missing on the nRF52840 Dongle: **Button
+> 2**, **Button 3**, **Button 4**, **SEGGER J-Link USB port**, and **NFC port
+> with antenna attached**. You can collect logs from the nRF52840 Dongle using
+> the **nRF USB port** instead of the **SEGGER J-Link USB port**.
+> Functionalities associated with the remaining missing elements are
+> inaccessible.
+
**LED 1** shows the overall state of the device and its connectivity. The
following states are possible:
@@ -381,9 +393,11 @@ depending on the selected board:
command-line shell.
- release -- Release version of the application - can be used to enable only
the necessary application functionalities to optimize its performance. It
- has Device Firmware Upgrade feature enabled.
+ has Device Firmware Upgrade feature enabled. It can be used only for the
+ nRF52840 DK and nRF5340 DK, as only those platforms support the DFU.
- dfu -- Debug version of the application with Device Firmware Upgrade feature
- support.
+ support. It can be used only for the nRF52840 DK and nRF5340 DK, as only
+ those platforms support the DFU.
For more information, see the
[Configuring nRF Connect SDK examples](../../../docs/guides/nrfconnect_examples_configuration.md)
@@ -395,6 +409,13 @@ page.
## Flashing and debugging
+The flashing and debugging procedure is different for the development kits and
+the nRF52840 Dongle.
+
+
+
+### Flashing on the development kits
+
To flash the application to the device, use the west tool and run the following
command from the example directory:
@@ -408,6 +429,14 @@ directory:
$ west debug
+
+
+### Flashing on the nRF52840 Dongle
+
+Visit
+[Programming and Debugging nRF52840 Dongle](https://docs.zephyrproject.org/latest/boards/arm/nrf52840dongle_nrf52840/doc/index.html#programming-and-debugging)
+to read more about flashing on the nRF52840 Dongle.
+
## Testing the example
diff --git a/examples/all-clusters-app/nrfconnect/boards/nrf52840dongle_nrf52840.conf b/examples/all-clusters-app/nrfconnect/boards/nrf52840dongle_nrf52840.conf
new file mode 100644
index 00000000000000..dc8c38ed741291
--- /dev/null
+++ b/examples/all-clusters-app/nrfconnect/boards/nrf52840dongle_nrf52840.conf
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2022 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Configure logging over USB
+# - do enable shell to reduce flash usage
+# - disable CDC ACM logs as it may lead to infinite loop when CDC ACM is used as the log backend
+CONFIG_USB_DEVICE_STACK=y
+CONFIG_CONSOLE=y
+CONFIG_UART_CONSOLE=y
+CONFIG_LOG_BACKEND_UART=y
+CONFIG_SHELL_LOG_BACKEND=n
+CONFIG_UART_LINE_CTRL=y
+CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
+
+# The minimal logging mode does not work properly with the USB CDC device, so use the deferred mode
+CONFIG_LOG_MODE_MINIMAL=n
+CONFIG_LOG2_MODE_DEFERRED=y
+CONFIG_LOG_BUFFER_SIZE=8192
+
+# Reduce the code size as the dongle reserves some space for MBR and Open Bootloader
+CONFIG_ASSERT_VERBOSE=n
+CONFIG_SHELL=n
+CONFIG_OPENTHREAD_SHELL=n
+CONFIG_MATTER_LOG_LEVEL_INF=y
+
+# Use partition manager to configure the settings partition not to overlap with Open Bootloader
+CONFIG_PM_SINGLE_IMAGE=y
+
+# Enable CHIP pairing automatically on application start.
+CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y
diff --git a/examples/all-clusters-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay b/examples/all-clusters-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay
new file mode 100644
index 00000000000000..848566b5f43702
--- /dev/null
+++ b/examples/all-clusters-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http: //www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ / {
+ chosen {
+ zephyr,console = &cdc_acm_uart0;
+ };
+};
+
+&zephyr_udc0 {
+ cdc_acm_uart0: cdc_acm_uart0 {
+ compatible = "zephyr,cdc-acm-uart";
+ label = "CDC_ACM_0";
+ };
+};
diff --git a/examples/all-clusters-app/nrfconnect/main/main.cpp b/examples/all-clusters-app/nrfconnect/main/main.cpp
index bb67947911cad1..eaeca122fb52f2 100644
--- a/examples/all-clusters-app/nrfconnect/main/main.cpp
+++ b/examples/all-clusters-app/nrfconnect/main/main.cpp
@@ -19,14 +19,41 @@
#include
+#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart)
+#include
+#include
+#endif
+
LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL);
using namespace ::chip;
int main()
{
- CHIP_ERROR err = AppTask::Instance().StartApp();
+ CHIP_ERROR err = CHIP_NO_ERROR;
+
+#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart)
+ const struct device * dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
+ uint32_t dtr = 0;
+
+ err = System::MapErrorZephyr(usb_enable(nullptr));
+
+ if (err != CHIP_NO_ERROR)
+ {
+ LOG_ERR("Failed to initialize USB device");
+ goto exit;
+ }
+
+ while (!dtr)
+ {
+ uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
+ k_sleep(K_MSEC(100));
+ }
+#endif
+
+ err = AppTask::Instance().StartApp();
+exit:
LOG_ERR("Exited with code %" CHIP_ERROR_FORMAT, err.Format());
return err == CHIP_NO_ERROR ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/examples/all-clusters-app/nrfconnect/pm_static_nrf52840dongle_nrf52840.yml b/examples/all-clusters-app/nrfconnect/pm_static_nrf52840dongle_nrf52840.yml
new file mode 100644
index 00000000000000..ad0f9426169e9d
--- /dev/null
+++ b/examples/all-clusters-app/nrfconnect/pm_static_nrf52840dongle_nrf52840.yml
@@ -0,0 +1,8 @@
+settings_storage:
+ address: 0xd8000
+ size: 0x8000
+ region: flash_primary
+open_bootloader:
+ address: 0xe0000
+ size: 0x20000
+ region: flash_primary
diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt
index d3684e4d7b8199..934b0baca23b39 100644
--- a/examples/lighting-app/nrfconnect/CMakeLists.txt
+++ b/examples/lighting-app/nrfconnect/CMakeLists.txt
@@ -78,7 +78,7 @@ if(CONFIG_MCUMGR_SMP_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
-if (BOARD STREQUAL "nrf52840dongle_nrf52840")
+if (CONFIG_SHELL AND BOARD STREQUAL "nrf52840dongle_nrf52840")
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUTrigger.cpp)
endif()
diff --git a/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay b/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay
index 5ccdd5561121ca..b9290884c459f3 100644
--- a/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay
+++ b/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840.overlay
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http: //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-/ {
- chosen {
- zephyr,shell-uart = &cdc_acm_uart0;
+ / {
+ chosen {
+ zephyr,console = &cdc_acm_uart0;
};
};
diff --git a/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf b/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf
index ccf3ef33664471..1525056853f5bd 100644
--- a/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf
+++ b/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf
@@ -14,14 +14,26 @@
# limitations under the License.
#
-# Configure shell and logging over USB
+# Configure logging over USB
+# - do enable shell to reduce flash usage
+# - disable CDC ACM logs as it may lead to infinite loop when CDC ACM is used as the log backend
CONFIG_USB_DEVICE_STACK=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
+CONFIG_CONSOLE=y
+CONFIG_UART_CONSOLE=y
+CONFIG_LOG_BACKEND_UART=y
+CONFIG_SHELL_LOG_BACKEND=n
CONFIG_UART_LINE_CTRL=y
-CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
+CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
# The minimal logging mode does not work properly with the USB CDC device, so use the deferred mode
CONFIG_LOG_MODE_MINIMAL=n
-CONFIG_LOG_MODE_DEFERRED=y
-CONFIG_LOG_STRDUP_MAX_STRING=128
-CONFIG_LOG_STRDUP_BUF_COUNT=24
+CONFIG_LOG2_MODE_DEFERRED=y
+CONFIG_LOG_BUFFER_SIZE=8192
+
+# Reduce the code size as the dongle reserves some space for MBR and Open Bootloader
+CONFIG_ASSERT_VERBOSE=n
+CONFIG_SHELL=n
+CONFIG_OPENTHREAD_SHELL=n
+
+# Use partition manager to configure the settings partition not to overlap with Open Bootloader
+CONFIG_PM_SINGLE_IMAGE=y
diff --git a/examples/lighting-app/nrfconnect/main/main.cpp b/examples/lighting-app/nrfconnect/main/main.cpp
index 1e9668b977bcd8..0fe27d587e5aa3 100644
--- a/examples/lighting-app/nrfconnect/main/main.cpp
+++ b/examples/lighting-app/nrfconnect/main/main.cpp
@@ -26,7 +26,8 @@
#include "Rpc.h"
#endif
-#ifdef CONFIG_USB_DEVICE_STACK
+#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart)
+#include
#include
#endif
@@ -42,19 +43,28 @@ int main()
rpc::Init();
#endif
-#ifdef CONFIG_USB_DEVICE_STACK
+#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart)
+ const struct device * dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
+ uint32_t dtr = 0;
+
err = System::MapErrorZephyr(usb_enable(nullptr));
+
if (err != CHIP_NO_ERROR)
{
LOG_ERR("Failed to initialize USB device");
+ goto exit;
}
-#endif
- if (err == CHIP_NO_ERROR)
+ while (!dtr)
{
- err = GetAppTask().StartApp();
+ uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
+ k_sleep(K_MSEC(100));
}
+#endif
+
+ err = GetAppTask().StartApp();
+exit:
LOG_ERR("Exited with code %" CHIP_ERROR_FORMAT, err.Format());
return err == CHIP_NO_ERROR ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/examples/lighting-app/nrfconnect/pm_static_nrf52840dongle_nrf52840_no_dfu.yml b/examples/lighting-app/nrfconnect/pm_static_nrf52840dongle_nrf52840_no_dfu.yml
new file mode 100644
index 00000000000000..ad0f9426169e9d
--- /dev/null
+++ b/examples/lighting-app/nrfconnect/pm_static_nrf52840dongle_nrf52840_no_dfu.yml
@@ -0,0 +1,8 @@
+settings_storage:
+ address: 0xd8000
+ size: 0x8000
+ region: flash_primary
+open_bootloader:
+ address: 0xe0000
+ size: 0x20000
+ region: flash_primary