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

Parents
  • 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



  • Actually I had that in my main.c, but also had a bunch of other stuff from the subways/usb/console that may have been breaking bits using it as a console.

    So I added to prj.conf ( I may see if the CONFIG_USB_UART_CONSOLE is needed, but hey this works...)

    CONFIG_GPIO=y
    CONFIG_USB=y
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_MANUFACTURER="SER Consulting LLC"
    CONFIG_USB_DEVICE_PRODUCT="BaseBoard Thermostat"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x520F
    CONFIG_USB_CDC_ACM=y
    CONFIG_USB_UART_CONSOLE=y

    CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"

    I created a nrf52840dongle_nrf52840.overlay that is just a duplicate of the dk version

    It just needed the include and usb_enable in main.c to work. I think the extra code tried to use it as a console instead of a shell... So I may be trying to create a multi device with 2 CDC's on it, one for shell and one for console, but I'll experiment with this first. May want to add this in to the SDK as an overlay for the dongle.

Reply
  • Actually I had that in my main.c, but also had a bunch of other stuff from the subways/usb/console that may have been breaking bits using it as a console.

    So I added to prj.conf ( I may see if the CONFIG_USB_UART_CONSOLE is needed, but hey this works...)

    CONFIG_GPIO=y
    CONFIG_USB=y
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_MANUFACTURER="SER Consulting LLC"
    CONFIG_USB_DEVICE_PRODUCT="BaseBoard Thermostat"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x520F
    CONFIG_USB_CDC_ACM=y
    CONFIG_USB_UART_CONSOLE=y

    CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"

    I created a nrf52840dongle_nrf52840.overlay that is just a duplicate of the dk version

    It just needed the include and usb_enable in main.c to work. I think the extra code tried to use it as a console instead of a shell... So I may be trying to create a multi device with 2 CDC's on it, one for shell and one for console, but I'll experiment with this first. May want to add this in to the SDK as an overlay for the dongle.

Children
Related