This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to port the Zigbee Network Coordinator sample from the nRF52840DK to the nRF52840 dongle

I'm trying to implement the Zigbee coordinator sample on the nRF52840 dongle.  Although I've received a little bit of guidance on how to adapt the nRF52840DK implementation from my local Nordic rep, neither he nor I are enjoying any success.  Surely there must be others that have done this before, no?  Once I get this sample working, I would like to add the CLI shell to the same sample.  Can anyone provide some desperately-needed assistance?  I am building my code using nRF Connect SDK v1.8.0 in VS Code on a Windows 10 machine and have successfully built and tested the very same sample on the DK board without issue.

Parents
  • Hi,

    To get the network coordinator to work on the Dongle you need to do the following:

    1. Create a board file overlay nrf52840dongle_nrf52840.overlay under network_coordinator/boards with the following:

    /*
     * Copyright (c) 2021 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    / {
    	chosen {
    		zephyr,entropy = &rng;
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		rst_button0: rst_button_0 {
    			gpios = <&gpio0 19 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Reset button";
    		};
    	};
    
    	aliases {
    		rst0 = &rst_button0;
    	};
    };
    

    2. Create a static partition manager file to create partitions for MBR and the bootloader on the Dongle. This should be located directly under network_coordinator/. Call it pm_static_nrf52840dongle_nrf52840.yml and add the following:

    EMPTY_0:
      address: 0x0e0000
      end_address: 0x100000
      region: flash_primary
      size: 0x20000
    # SRAM reserved to be used by the nRF5 Bootloader
    EMPTY_1:
      address: 0x20000000
      end_address: 0x20000400
      region: sram_primary
      size: 0x0400
    

    3. The last thing is to add the dongle to the existing sample.yaml file. Simply add nrf52840dongle_nrf52840 to platform_allow and integration_platforms.

    I have also uploaded the sample with dongle support here.

    I would like to add the CLI shell to the same sample

    By this, do you mean the Zigbee shell library or CLI in general? The issue with using the Zigbee shell with the Dongle is that as of now it is only supports using UART and RTT as serial transports, as can be seen in Zigbee shell » Supported backends, and the Dongle only has USB, so you would need to use USB CDC ACM. It might be possible to implement this, but I have not tested it myself. If you want to look into it, you can take a look at the USB overlay extension in the Thread: CLI sample, and the USB CDC ACM Sample Application.

    Best regards,

    Marte

    network_coordinator_dongle.zip

  • Hi, again:

    To be more specific, what I would like is the equivalent of the old Zigbee CLI Agent example from the legacy nRF5 SDK for Thread and Zigbee v4.1.0 running on a dongle using the nRF Connect SDK v1.8.0.

    Best regards,

    Jody

  • Hi Jody,

    The Zigbee Shell library is in a way the nRF Connect SDK version of Zigbee CLI from nRF5 SDK. The implementation differs, as it is implemented using the Shell interface from Zephyr, but the way it is used is almost the same, with many of the same commands. You can read more about it and see the supported commands in Zigbee shell. So in your case, you would want to use Zigbee Shell.

    Best regards,

    Marte

Reply
  • Hi Jody,

    The Zigbee Shell library is in a way the nRF Connect SDK version of Zigbee CLI from nRF5 SDK. The implementation differs, as it is implemented using the Shell interface from Zephyr, but the way it is used is almost the same, with many of the same commands. You can read more about it and see the supported commands in Zigbee shell. So in your case, you would want to use Zigbee Shell.

    Best regards,

    Marte

Children
  • Hi Jody,

    I decided to test this myself. All the changes I made can be seen in the file zigbee_shell.diff, but I have also written it out here:

    First I created a nrf52840dongle_nrf52840.conf file for configurations specific to nrf52840 Dongle:

    CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
    CONFIG_SHELL_BACKEND_SERIAL=y
    
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_SHELL_BACKEND_SERIAL=y
    CONFIG_USB_DEVICE_PRODUCT="Zigbee Network Coordinator"
    CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor ASA"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x0100
    
    CONFIG_UART_LINE_CTRL=y

    I added the following to CMakeLists.txt so that the nrf52840dongle_nrf52840.conf file would be added to the configurations when nrf52840dongle_nrf52840 is chosen as board:

    set(CONF_FILE "prj.conf")
    
    if (EXISTS boards/${BOARD}.conf)
      list(APPEND CONF_FILE boards/${BOARD}.conf)
    endif()

    In nrf52840dongle_nrf52840.overlay I added the USB device controller by adding zephyr,shell-uart = &cdc_acm_uart0 and &zephyr_udc0:

    / {
    	chosen {
    		zephyr,entropy = &rng;
    		zephyr,shell-uart = &cdc_acm_uart0;
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		rst_button0: rst_button_0 {
    			gpios = <&gpio0 19 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Reset button";
    		};
    	};
    
    	aliases {
    		rst0 = &rst_button0;
    	};
    };
    
    &zephyr_udc0 {
    	cdc_acm_uart0: cdc_acm_uart0 {
    		compatible = "zephyr,cdc-acm-uart";
    		label = "CDC_ACM_0";
    	};
    };
    

    Removed the following configurations from prj.conf:

    CONFIG_SERIAL=y
     
    # Make sure printk is not printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y

    Then added the configurations for Zigbee Shell in the same file:

    # Shell
    CONFIG_SHELL=y
    CONFIG_ZIGBEE_SHELL=y

    Lastly, I enabled the USB device in main.c by including the file usb/usb_device.h, and calling usb_enable(NULL); right before configure_gpio();

    I have not tested this extensively, so there might be some issues, but I was able to issue Zigbee Shell commands to the Dongle successfully using this. I am uploading the sample here for you as well.

    diff --git a/zigbee/network_coordinator_dongle/CMakeLists.txt b/zigbee/network_coordinator_dongle/CMakeLists.txt
    index 2e6c804..5a0c733 100644
    --- a/zigbee/network_coordinator_dongle/CMakeLists.txt
    +++ b/zigbee/network_coordinator_dongle/CMakeLists.txt
    @@ -6,6 +6,12 @@
     
     cmake_minimum_required(VERSION 3.20.0)
     
    +set(CONF_FILE "prj.conf")
    +
    +if (EXISTS boards/${BOARD}.conf)
    +  list(APPEND CONF_FILE boards/${BOARD}.conf)
    +endif()
    +
     find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
     
     project("Zigbee coordinator")
    diff --git a/zigbee/network_coordinator_dongle/boards/nrf52840dongle_nrf52840.overlay b/zigbee/network_coordinator_dongle/boards/nrf52840dongle_nrf52840.overlay
    index b5f36b9..0f48d4b 100644
    --- a/zigbee/network_coordinator_dongle/boards/nrf52840dongle_nrf52840.overlay
    +++ b/zigbee/network_coordinator_dongle/boards/nrf52840dongle_nrf52840.overlay
    @@ -4,9 +4,12 @@
      * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
      */
     
    +
    +
     / {
     	chosen {
     		zephyr,entropy = &rng;
    +		zephyr,shell-uart = &cdc_acm_uart0;
     	};
     
     	buttons {
    @@ -21,3 +24,10 @@
     		rst0 = &rst_button0;
     	};
     };
    +
    +&zephyr_udc0 {
    +	cdc_acm_uart0: cdc_acm_uart0 {
    +		compatible = "zephyr,cdc-acm-uart";
    +		label = "CDC_ACM_0";
    +	};
    +};
    diff --git a/zigbee/network_coordinator_dongle/prj.conf b/zigbee/network_coordinator_dongle/prj.conf
    index 42155ec..109e624 100644
    --- a/zigbee/network_coordinator_dongle/prj.conf
    +++ b/zigbee/network_coordinator_dongle/prj.conf
    @@ -7,13 +7,8 @@
     CONFIG_NCS_SAMPLES_DEFAULTS=y
     
     CONFIG_UART_INTERRUPT_DRIVEN=y
    -CONFIG_SERIAL=y
     CONFIG_GPIO=y
     
    -# Make sure printk is not printing to the UART console
    -CONFIG_CONSOLE=y
    -CONFIG_UART_CONSOLE=y
    -
     CONFIG_HEAP_MEM_POOL_SIZE=2048
     CONFIG_MAIN_THREAD_PRIORITY=7
     
    @@ -21,6 +16,10 @@ CONFIG_ZIGBEE=y
     CONFIG_ZIGBEE_APP_UTILS=y
     CONFIG_ZIGBEE_ROLE_COORDINATOR=y
     
    +# Shell
    +CONFIG_SHELL=y
    +CONFIG_ZIGBEE_SHELL=y
    +
     # Enable DK LED and Buttons library
     CONFIG_DK_LIBRARY=y
     
    diff --git a/zigbee/network_coordinator_dongle/src/main.c b/zigbee/network_coordinator_dongle/src/main.c
    index 3023f83..d45a9bc 100644
    --- a/zigbee/network_coordinator_dongle/src/main.c
    +++ b/zigbee/network_coordinator_dongle/src/main.c
    @@ -10,6 +10,7 @@
     
     #include <zephyr.h>
     #include <device.h>
    +#include <usb/usb_device.h>
     #include <logging/log.h>
     #include <dk_buttons_and_leds.h>
     
    @@ -310,6 +311,9 @@ void main(void)
     
     	LOG_INF("Starting ZBOSS Coordinator example");
     
    +	/* Enable USB */
    +	usb_enable(NULL);
    +
     	/* Initialize */
     	configure_gpio();
     
    

    network_coordinator_shell_dongle.zip

    Best regards,

    Marte

Related