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.

  • 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

  • Hi, Marte:

    Fantastic!  I need to get a few more hours of sleep, but I will verify your solution later today.

    You rock!

    Many thanks & best regards,

    Jody

  • Hi, Marte:

    I just verified your solution and it is PERFECT!  Thank you so much for your superb assistance.  Clap tone2Clap tone2Clap tone2Thumbsup tone2

    Best regards,

    Jody

  • Hi Jody,

    Great to hear that it is working on your end as well! I am happy to help Slight smile

    Best regards,

    Marte

Related