Using Zigbee with USB CDC ACM

I developed a small test app by adding logging and a blinking LED to the Console over CDC ACM UART Sample. The LED blinks, and I can see the logs by connecting to the USB CDC ACM. However, if I try enabling Zigbee support in the app, the USB CDC ACM no longer shows up on the host, and the LED does not light up. I am developing on nRF52840 Dongle, so I have limited debugging capabilities. What could be the cause of the app not starting at all when Zigbee is enabled?

main.c:

#include <zephyr.h>
#include <drivers/gpio.h>

#include <zephyr/kernel.h>
#include <zephyr/usb/usb_device.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/logging/log.h>

/* This was added to enable Zigbee support. */
#include <zigbee/zigbee_app_utils.h>
/* ---------------------------------------- */


BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
	     "Console device is not ACM CDC UART device");

LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);


/* This was added to enable Zigbee support. */
void zboss_signal_handler(zb_uint8_t param)
{
    zigbee_default_signal_handler(param);
    zb_buf_free(param);
}
/* ---------------------------------------- */


void main(void)
{
	int ret;

    LOG_INF("Starting Blinky");
	if (usb_enable(NULL)) {
		return;
	}
	if (!device_is_ready(led.port)) {
		return;
	}
	ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
	if (ret < 0) {
		return;
	}

    LOG_INF("Blinky started");

	while (1) {
		LOG_INF("Hello World! %s", CONFIG_ARCH);
        ret = gpio_pin_toggle_dt(&led);
		if (ret < 0) {
			return;
		}
		k_sleep(K_SECONDS(1));
	}
}

prj.conf:

CONFIG_GPIO=y

# Enable CDC ACM UART console
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Test"
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y
CONFIG_LOG=y
CONFIG_LOG_BACKEND_UART=y

# Enable Zigbee
CONFIG_ZIGBEE=y
CONFIG_ZIGBEE_APP_UTILS=y
CONFIG_ZIGBEE_ROLE_END_DEVICE=y

nrf52840dongle_nrf52840.overlay:

/ {
	chosen {
		zephyr,entropy = &rng;
        zephyr,console = &cdc_acm_uart0;
	};
};

&zephyr_udc0 {
    cdc_acm_uart0: cdc_acm_uart0 {
        compatible = "zephyr,cdc-acm-uart";
        label = "CDC_ACM_0";
    };
};

Hardware: nRF52840 Dongle
Host OS: macOS 13.0
Toolchain: nRF Connect SDK v2.1.2

Parents Reply Children
  • Hi, 

    I use your nrf52840dongle_nrf52840.overlay and create nrf52840dongle_nrf52840.conf under \boards with the following content:

    #
    # Copyright (c) 2022 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable nRF ECB driver
    CONFIG_CRYPTO=y
    CONFIG_CRYPTO_NRF_ECB=y
    CONFIG_CRYPTO_INIT_PRIORITY=80
    
    # Networking
    CONFIG_MPSL=y
    
    
    # Enable USB CDC ACM
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_DRIVER=y
    CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample"
    CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor ASA"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x0100
    
    CONFIG_UART_LINE_CTRL=y
    CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
    
    # Since the default LOG_MODE_MINIMAL is synchronous, it will mess with the USB
    # driver/subsys. Use the deferred mode instead.
    CONFIG_LOG_MODE_DEFERRED=y

    modify main.c as

    --- "a/C:\\ncs\\v2.1.2\\nrf\\samples\\zigbee\\light_switch\\src\\main.c"
    +++ "b/C:\\ncs\\v2.1.2\\Devzone\\light_switch_298447\\src\\main.c"
    @@ -14,6 +14,13 @@
     #include <dk_buttons_and_leds.h>
     #include <ram_pwrdn.h>
    
    +#include <zephyr/sys/printk.h>
    +#include <zephyr/usb/usb_device.h>
    +#include <zephyr/drivers/uart.h>
    +
    +BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
    +            "Console device is not ACM CDC UART device");
    +
     #include <zboss_api.h>
     #include <zboss_api_addons.h>
     #include <zigbee/zigbee_app_utils.h>
    @@ -22,6 +29,7 @@
     #include "zb_mem_config_custom.h"
     #include "zb_dimmer_switch.h"
    
    +
     #if CONFIG_ZIGBEE_FOTA
     #include <zigbee/zigbee_fota.h>
     #include <zephyr/sys/reboot.h>
    @@ -724,6 +732,26 @@ static struct nus_entry commands[] = {
    
     void main(void)
     {
    +
    +       //---------------
    +       const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
    +       uint32_t dtr = 0;
    +
    +       if (usb_enable(NULL)) {
    +               return;
    +       }
    +
    +       /* Poll if the DTR flag was set */
    +       while (!dtr) {
    +               uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
    +               /* Give CPU resources to low priority threads. */
    +               k_sleep(K_MSEC(100));
    +       }
    +
    +       printk("hello world\n");
    +
    +//----------------------------
    +
            LOG_INF("Starting ZBOSS Light Switch example");
    
            /* Initialize. */
    

    Get log as

    Here is the project light_switch.7z

    -Amanda H.

  • Thanks. The problem seemed to be a missing pm_static.yml file.

Related