Matter Lighting-App NRF52840 Dongle Cannot Run

Hello,

I am facing an issue with the firmware I compiled for the nrf52840dongle using the lighting-app example. The firmware is not functioning properly, and the LED is not blinking as expected. I would appreciate your assistance in identifying the problem.

Additionally, we are looking for a Matter firmware that can run on the dongle, but it doesn't have to be the lighting-app. Could you please suggest any project examples that meet our requirements? We mainly intend to use it for testing purposes.

Here are the project details:
Repository: https://github.com/project-chip/connectedhomei
Commit ID: 4e5cf298f1fd82045efb1fde705a8d2ab4dc3e0e
prj.conf:

# Enable CHIP
CONFIG_CHIP=y
CONFIG_CHIP_PROJECT_CONFIG="main/include/CHIPProjectConfig.h"
# 32773 == 0x8005 (example lighting-app)
CONFIG_CHIP_DEVICE_PRODUCT_ID=32773
CONFIG_STD_CPP17=y

# Enable CHIP pairing automatically on application start.
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y

# Add support for LEDs and buttons on Nordic development kits
CONFIG_DK_LIBRARY=y
CONFIG_PWM=y

# General networking settings
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=14


# Bluetooth Low Energy configuration
CONFIG_BT_DEVICE_NAME="MatterLight"

# Stack size settings
CONFIG_IEEE802154_NRF5_RX_STACK_SIZE=1024

# Other settings
CONFIG_THREAD_NAME=y
CONFIG_MPU_STACK_GUARD=y
CONFIG_RESET_ON_FATAL_ERROR=n

# Reduce application size
CONFIG_USE_SEGGER_RTT=n

# Disable Matter OTA DFU
CONFIG_CHIP_OTA_REQUESTOR=n

# Disable QSPI NOR
CONFIG_CHIP_QSPI_NOR=n

CONFIG_OPENTHREAD_MTD=y
CONFIG_OPENTHREAD_FTD=n

CONFIG_SHELL=n

CMakeLists.txt: 
cmake_minimum_required(VERSION 3.13.1)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH)
get_filename_component(LIGHTING_COMMON ${CHIP_ROOT}/examples/lighting-app/lighting-common REALPATH)
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)

include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)

# Set Kconfig root files that will be processed as a first Kconfig for used child images.
set(mcuboot_KCONFIG_ROOT ${CHIP_ROOT}/config/nrfconnect/chip-module/Kconfig.mcuboot.root)
set(multiprotocol_rpmsg_KCONFIG_ROOT ${CHIP_ROOT}/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.root)
set(hci_rpmsg_KCONFIG_ROOT ${CHIP_ROOT}/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root)

# if(NOT CONF_FILE STREQUAL "prj_no_dfu.conf" AND NOT BOARD STREQUAL "nrf52840dongle_nrf52840")
#     set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static_dfu.yml)
# endif()

set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/pm_static_nrf52840dongle_nrf52840_no_dfu.yml)

list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

project(chip-nrfconnect-lighting-example)

include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake)
include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake)
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)

# -Wmaybe-uninitialized has too many false positives, including on std::optional
# and chip::Optional.  Make it nonfatal.
#
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
target_compile_options(app PRIVATE -Werror -Wno-error=maybe-uninitialized)

target_include_directories(app PRIVATE
                           main/include
                           ${LIGHTING_COMMON}
                           ${GEN_DIR}
                           ${GEN_DIR}/app-common
                           ${GEN_DIR}/lighting-app
                           ${NRFCONNECT_COMMON}/util/include
                           ${NRFCONNECT_COMMON}/app/include)

target_sources(app PRIVATE
               main/AppTask.cpp
               main/main.cpp
               main/ZclCallbacks.cpp
               ${NRFCONNECT_COMMON}/util/LEDWidget.cpp
               ${NRFCONNECT_COMMON}/util/PWMDevice.cpp)

chip_configure_data_model(app
    INCLUDE_SERVER
    ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lighting-common/lighting-app.zap
)

if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
    target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()

if(CONFIG_MCUMGR_TRANSPORT_BT)
    target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()

if (CONFIG_SHELL AND BOARD STREQUAL "nrf52840dongle_nrf52840")
  target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUTrigger.cpp)
endif()

if (CONFIG_CHIP_PW_RPC)

# Make all targets created below depend on zephyr_interface to inherit MCU-related compilation flags
link_libraries($<BUILD_INTERFACE:zephyr_interface>)

set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)

pw_set_module_config(pw_rpc_CONFIG pw_rpc.disable_global_mutex_config)
pw_set_backend(pw_log pw_log_basic)
pw_set_backend(pw_assert.check pw_assert_log.check_backend)
pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend)
pw_set_backend(pw_sys_io pw_sys_io.nrfconnect)
set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE)

add_subdirectory(third_party/connectedhomeip/examples/platform/nrfconnect/pw_sys_io)
add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)

pw_proto_library(attributes_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.proto
  INPUTS
    ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.options
  PREFIX
    attributes_service
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  DEPS
    pw_protobuf.common_proto
)

pw_proto_library(button_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/button_service.proto
  PREFIX
    button_service
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  DEPS
    pw_protobuf.common_proto
)

pw_proto_library(descriptor_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto
  PREFIX
    descriptor_service
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  DEPS
    pw_protobuf.common_proto
)

pw_proto_library(device_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.proto
  INPUTS
    ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.options
  PREFIX
    device_service
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  DEPS
    pw_protobuf.common_proto
)

pw_proto_library(lighting_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/lighting_service.proto
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  PREFIX
    lighting_service
  DEPS
    pw_protobuf.common_proto
)

pw_proto_library(ot_cli_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/ot_cli_service.proto
  INPUTS
    ${CHIP_ROOT}/examples/common/pigweed/protos/ot_cli_service.options
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  PREFIX
    ot_cli_service
  DEPS
    pw_protobuf.common_proto
)

pw_proto_library(thread_service
  SOURCES
    ${CHIP_ROOT}/examples/common/pigweed/protos/thread_service.proto
  INPUTS
    ${CHIP_ROOT}/examples/common/pigweed/protos/thread_service.options
  STRIP_PREFIX
    ${CHIP_ROOT}/examples/common/pigweed/protos
  PREFIX
    thread_service
  DEPS
    pw_protobuf.common_proto
)

target_sources(app PRIVATE
  ../../common/pigweed/RpcService.cpp
  ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp
  ${NRFCONNECT_COMMON}/Rpc.cpp
  ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp
)

target_include_directories(app PRIVATE
  ${CHIP_ROOT}/src/lib/support
  ${CHIP_ROOT}/src/system
  ${NRFCONNECT_COMMON}
  ../../common
  ../../common/pigweed
  ../../common/pigweed/nrfconnect)

target_compile_options(app PRIVATE
                       "-DPW_RPC_ATTRIBUTE_SERVICE=1"
                       "-DPW_RPC_BUTTON_SERVICE=1"
                       "-DPW_RPC_DESCRIPTOR_SERVICE=1"
                       "-DPW_RPC_DEVICE_SERVICE=1"
                       "-DPW_RPC_LIGHTING_SERVICE=1"
                       "-DPW_RPC_THREAD_SERVICE=1"
                       )

target_link_libraries(app PRIVATE
  attributes_service.nanopb_rpc
  button_service.nanopb_rpc
  descriptor_service.nanopb_rpc
  device_service.nanopb_rpc
  lighting_service.nanopb_rpc
  thread_service.nanopb_rpc
  pw_checksum
  pw_hdlc
  pw_hdlc.pw_rpc
  pw_log
  pw_rpc.server
  pw_sys_io
)

endif(CONFIG_CHIP_PW_RPC)

Build command: west build -b nrf52840dongle_nrf52840

Your assistance in resolving this issue and providing guidance on alternative Matter firmware examples would be highly appreciated.

Thank you

  • Hi GaryZheng,

    I am unfamiliar with building examples from the Matter repository and have been having some environment issues trying to build the example. However, from the example setup, I can see that the nrf52840dongle_nrf52840 target is intended to be built with the prj_no_dfu.conf file instead of the normal prj.conf. Please try building with: 

    By the way, are you using a nRF52840 Dongle? Please know that it is not the best tool for development. If you are looking into developing an application on a nRF52 SoC, I recommend getting a Development Kit instead of the Dongle.

    We also have Matter sample projects in our nRF Connect SDK. You can find them here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/nrf/samples/matter.html

    However, they are also designed to work with the Development Kits rather than the Dongle.

    Hieu

  • Hi Hieu,

    Thank you for your reply.

    We need to connect a large number of Matter devices under the gateway for testing purposes. We believe that using nRF52840 Dongle as Matter devices for testing would be more convenient, especially considering that we have many dongles available. However, Development Kits are in short supply. Since the examples in the Matter repository are provided by your team, can you resolve this issue and enable the dongles to run?

    Thank you

  • Hi GaryZheng,

    Hieu said:
    I can see that the nrf52840dongle_nrf52840 target is intended to be built with the prj_no_dfu.conf file instead of the normal prj.conf. Please try building with: 

    It looks like I forgot to put in the build command, but have you tried building with prj_no_dfu.conf? If you haven't yet figured out how, the command is: west build . -b nrf52840dongle_nrf52840 -DCONF_FILE="./prj_no_dfu.conf"

    GaryZheng said:
    Since the examples in the Matter repository are provided by your team, can you resolve this issue and enable the dongles to run?

    Please understand that I haven't said that there is an issue with the example on the connectedhomeip (CHIP) repository.

    In case you misunderstood, what I said is that: the samples in the nRF Connect SDK are created for the Development Kit, and make use of the buttons and LEDs available.

    On the dongle, you only have access to one button, so you cannot evaluate the samples fully. You can still make modification to the samples to get it to work. For example, instead of triggering specific tasks on a button press, trigger such tasks when the application receives a '1', '2' or '3' over USB CDC ACM UART instead.

    Alternatively, you can also solder an additional circuit with a button to the dongle, and setup new the buttons in a DTS overlay file.

    Once again, please understand that what I have just said is regarding the samples in the nRF Connect SDK. Regarding the example in the CHIP repository, please try my suggestion above first.

  • Hi Hieu,


    We prefer to use the Matter repository example. I compiled the firmware using the command 'west build . -b nrf52840dongle_nrf52840 -DCONF_FILE="./prj_no_dfu.conf"' and tested it, but I am still encountering the same problem. The firmware is unable to run.

  • Hi GaryZheng,

    I find that the example has an issue on the dongle due to USB peripheral initialization. Could you please apply this change to the example and see if it works now.

    diff --git a/examples/lighting-app/nrfconnect/main/main.cpp b/examples/lighting-app/nrfconnect/main/main.cpp
    index 69e83a6935..aad6ced174 100644
    --- a/examples/lighting-app/nrfconnect/main/main.cpp
    +++ b/examples/lighting-app/nrfconnect/main/main.cpp
    @@ -40,9 +40,9 @@ static int InitUSB()
     {
         int err = usb_enable(nullptr);
    -    if (err)
    +    if (err != (-EALREADY))
         {
    -        LOG_ERR("Failed to initialize USB device");
    +        LOG_ERR("usb_enable %d", err);
             return err;
         }

Related