This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

use NrfConnect SDK with 52840 dongle USB CDC Shell/console

I would like to use the USB dongle with the Openthread CLI example (and eventually an open thread app) as the SDK is just too big and overpowered for my prototypes, I would like to use the USB CDC as the Shell to communicate with the CLI and zephyr.

https://github.com/zephyrproject-rtos/zephyr/issues/16761

I also looked at the Thingy applications/connectivity bridge which is similar

I can program using nrfconnect or nrfutil, but I never see the USB CDC serial port come up after programming.

I'm using nrfconnect sdk 1.4.0 os OS X 

I have added to boards

nrf52840dongle_nrf52840.overlay

/* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/

&uart0 {
status = "okay";
};

/ {
/*
* In some default configurations within the nRF Connect SDK,
* e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell.
* This devicetree overlay ensures that default is overridden wherever it
* is set, as this application uses the RNG node for entropy exclusively.
*/
chosen {
zephyr,entropy = &rng;
};
};

Also added a config overlay, I tried with and without some UART interrupt setting mentioned in other posts.

#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

# Enable Thread 1.2 features
CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y
CONFIG_OPENTHREAD_DUA=y
CONFIG_OPENTHREAD_MLR=y
CONFIG_OPENTHREAD_BACKBONE_ROUTER=y

CONFIG_GPIO=y
CONFIG_SENSOR=y
#CONFIG_BME280=y
#CONFIG_MCP9600=y
#CONFIG_ACS71020=y

# USB
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x9100
CONFIG_USB_DEVICE_PRODUCT="Zephyr UART"
CONFIG_USB_CDC_ACM=y

CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"

I also added the dongle to  Allow to sample.yaml

sample:

  description: Test OpenThread Command Line Interface.

  name: OpenThread CLI sample

tests:

  samples.openthread.cli:

    build_only: true

    build_on_all: true

    tags: openthread cli

    platform_allow: nrf52840dk_nrf52840 nrf52833dk_nrf52833 nrf52840dongle_nrf52840

  • Could you try to get the sample zephyr\samples\subsys\usb\console\src\main.c to work with the 52840 Dongle? If you do, then you can port it to the openthread sample. I was able to use that sample to log via USB on the nRF52840 DK at least.

    Best regards,

    Simon

  • Quite well hidden, but that does seem to work for the console. I will try using those parameters (and the code in main.c). One possible issue is that it seems there is a difference between the zephyr console and shell, and the CLI example needs the shell. But I also have the dual cdc_acm_composite example, and may be able to use that to figure out how to get both console and shell off of the USB port

  • The console by itself worked and printed to the USB and I had a usb device to connect to. I pulled a clean 1.4.0 dev environment. then copied the modifications to Kconfig, prj.conf, CMakeLists.txt (Hmm, do I need do do a zephyr update or something for the Cmake? and main.c. I don't get a usb device to connect to. Since the console did not have a board overlay file, I did not create one for the USB dongle. I will also try that.

  • Tried just about everything I can think of. As an alternative, can I get the console/shell over bluetooth UART? I was looking at the shell_bt_nus and chi_lpuart (what does chi stand for?)

  • I was literally trying the same thing today! In addition to the changes to the config that you already added you also need to enable the USB subsystem in samples/openthread/cli/src/main.c by adding a call to usb_enable. With that change I got the OpenThread CLI working on the PCA10059:

    diff --git a/samples/openthread/cli/src/main.c b/samples/openthread/cli/src/main.c
    index 40178f72..8f70d190 100644
    --- a/samples/openthread/cli/src/main.c
    +++ b/samples/openthread/cli/src/main.c
    @@ -6,6 +6,7 @@

    #include <zephyr.h>
    #include <logging/log.h>
    +#include <usb/usb_device.h>

    #if CONFIG_BT
    #include "ble.h"
    @@ -27,6 +28,8 @@ void main(void)
    {
    LOG_INF(WELLCOME_TEXT);

    + usb_enable(NULL);
    +
    #if CONFIG_BT
    ble_enable();
    #endif



Related