"Approved Solution" for adding serial output over USB from nRF52840 Dongle apps

Background:

In pursuing development of Thread-enabled devices for use in home automation, especially using the just announced Matter 1.0 protocol, the nRF52840 Dongle is potentially a very useful tool. It's inexpensive and, unlike many alternatives, actually available for purchase now.  The excellent development environment provided by NCS, coupled with VS Code, is extra motivation.  Even the clumsiness of having to route the hex file through the Programmer tool in the nRF for Connect app to flash the code isn't too burdensome.

One addition which would be a great benefit in building prototypes (especially since the Dongle lacks an embedded debugger) would be the easy addition of console output (e.g., using printk) over the USB connection.  So I've been investigating the best way to do this.  This topic has been dealt with before in this forum, but I've discovered that some of the answers are dated -- the answers are several years old and broken in the current SDK (v2.1.0).

Spent some time with your Developer Academy videos, especially the one dealing with dts file, kconfig, etc., the configuration approach inherited with zephyr.  Unfortunately, the relevant video is mainly a rehash of the zephyr docs, thin on practical examples, leaving the discussion as obtuse as ever.

Experiments:

Thought I had discovered a way to "break the code" without deep study of device trees and kconfig.  There are two examples in the current SDK, simple apps that do essentially the same thing, except the second adds serial communication over USB., They are "Hello World" (found at zephyr/samples/hello_world) and "Console over CDC ACM UART Sample" (at zephyr/samples/subsys/usb/console).  They both issue serial output every timer period and sleep in between, differing only in channel for the serial data.  So, I could simply build both of them for the nRF52840 Dongle and compare "differences".  Unfortunately, there are a large number of such "differences"

  • I anticipated that it was best to compare the apps as early in the build process as possible.  So (with the VS Code extension), I did "Create a new application" once for each sample app.
  • Then specified a Build configuration for each with the Dongle as target board and clicking "Build Configuration",  but without checking "Build after generating configuration"
  • This resulted in a number of copied and generated files, with a few lines in prj.conf, but about fifteen hundred lines(!) in the generated .config files
  • I compared the two .config files and found there are still about 75 lines of differences (copied below)

So with that many configuration setting differences, this clearly isn't early enough in the build process.  Looks like I need to modify the application template itself, even before the target is set to be the nRF52840 Dongle.

Questions:

  1. To solve my immediate problem, can you outline a specific set-by-step procedure to modify the template of the Hello World app to direct serial output from printk statements over the USB connection with CDC ACM UART?
  2. Does there exist in either the Nordic or Zephyr documentation a more complete description of the Zephyr configuration files and tools, including not only the formal definition, but more examples?  Visual diagrams?  Catalog of configuration properties, with logical groupings?  Anything to make it easier to understand the process from a practical point of view.
  3. Given that these kinds of mods need to be done on "templates" of sample apps, how does this fit into the development process with the VS code extension?
  4. On a related topic, it's been noted earlier on DevZone that the nRF52840 might not be a good prototyping platform for most Matter apps because of flash memory limits (1 MB) vs. the DK and other nRF52840 boards which have external flash.  
    1. Are there any sample apps in the SDK that require/use external flash?
    2. Besides the nRF52840 Datasheet, are there any app notes, etc., on using external flash in a software perspective for other than just data (i.e., executable code)?  Especially within the Zephyr framework?

TIA,

Mike

PS: I've written this ticket with motivation and background info included in the hope that that will make this thread more useful for other developers. Comments?

CONFIG_USB_DEVICE_PID=0x0004
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_SERIAL=y
CONFIG_SERIAL_INIT_PRIORITY=55
# CONFIG_USB_MCUX is not set
# CONFIG_USB_KINETIS is not set

CONFIG_NRFX_POWER=y
CONFIG_NRFX_PPI=y
CONFIG_NRFX_USBD=y

CONFIG_DT_HAS_ZEPHYR_CDC_ACM_UART_ENABLED=y
# end of Devicetree Info

# Device Drivers
CONFIG_CONSOLE=y
CONFIG_CONSOLE_INPUT_MAX_LINE_LEN=128
CONFIG_CONSOLE_HAS_DRIVER=y
# CONFIG_CONSOLE_HANDLER is not set
CONFIG_CONSOLE_INIT_PRIORITY=60
CONFIG_UART_CONSOLE=y
# CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS is not set
# CONFIG_UART_CONSOLE_MCUMGR is not set
CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
CONFIG_UART_CONSOLE_INPUT_EXPIRED_TIMEOUT=15000
# CONFIG_RAM_CONSOLE is not set
# CONFIG_IPM_CONSOLE_SENDER is not set
# CONFIG_IPM_CONSOLE_RECEIVER is not set
# CONFIG_UART_MCUMGR is not set
# CONFIG_GSM_MUX is not set
# CONFIG_EFI_CONSOLE is not set


# Capabilities
#
CONFIG_SERIAL_HAS_DRIVER=y
CONFIG_SERIAL_SUPPORT_ASYNC=y
CONFIG_SERIAL_SUPPORT_INTERRUPT=y
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
# CONFIG_UART_ASYNC_API is not set
CONFIG_UART_LINE_CTRL=y
# CONFIG_UART_DRV_CMD is not set
# CONFIG_UART_WIDE_DATA is not set
# CONFIG_UART_PIPE is not set

#
# Serial Drivers
#
CONFIG_UART_NRFX=y
CONFIG_UART_0_NRF_UARTE=y
CONFIG_UART_0_ENHANCED_POLL_OUT=y
CONFIG_UART_0_INTERRUPT_DRIVEN=y
# CONFIG_UART_0_NRF_PARITY_BIT is not set
CONFIG_UART_0_NRF_TX_BUFFER_SIZE=32
CONFIG_UART_ENHANCED_POLL_OUT=y
CONFIG_NRF_UARTE_PERIPHERAL=y

#
CONFIG_USB_DEVICE_DRIVER=y
# CONFIG_USB_DC_HAS_HS_SUPPORT is not set
CONFIG_USB_DEVICE_REMOTE_WAKEUP=y
# CONFIG_USB_DW is not set
CONFIG_USB_NRFX=y
CONFIG_USB_NRFX_EVT_QUEUE_SIZE=32
CONFIG_USB_NRFX_WORK_QUEUE_STACK_SIZE=1024
CONFIG_USB_NRFX_ATTACHED_EVENT_DELAY=0
# CONFIG_USB_NATIVE_POSIX is not set
CONFIG_HWINFO=y
CONFIG_HWINFO_NRF=y

CONFIG_STDOUT_CONSOLE=y
# end of C Library


# OS Support Library
#
# CONFIG_JSON_LIBRARY is not set
CONFIG_RING_BUFFER=y

Parents
  • Hello Mike, 

    On a related topic, it's been noted earlier on DevZone that the nRF52840 might not be a good prototyping platform for most Matter apps because of flash memory limits (1 MB) vs. the DK and other nRF52840 boards which have external flash.  

    As you might already know the Matter protocol is per our SDK not tested with the nRF52840 Dongle due to the lack of external flash which is used for e.g. Device Firmware Updgrade, and the dongle has less flash for application due to the pre-programmed bootloader. For that reason our Matter team focuses on providing full support for the development kits. That said, our team did add dongle support in Matter nRF Connect Lighting Example Application in the upstream Matter repository., Note that this is not tested with our samples or current version of the nRF Connect SDK.

    To solve my immediate problem, can you outline a specific set-by-step procedure to modify the template of the Hello World app to direct serial output from printk statements over the USB connection with CDC ACM UART?

    Will need to look into this part. I have not been successful in running CDC ACM on the dongle.

    Does there exist in either the Nordic or Zephyr documentation a more complete description of the Zephyr configuration files and tools, including not only the formal definition, but more examples?  Visual diagrams?  Catalog of configuration properties, with logical groupings?  Anything to make it easier to understand the process from a practical point of view

    Nothing more than what is available in the documentation I'm afraid. Circuit Dojo have several videos covering configurations in the Zephyr environment. Have a look at the Circuit Dojo YouTube channel.

    If this does not provide any more answer, please specify exactly what you are looking for and I will try to provide better answers.

    Given that these kinds of mods need to be done on "templates" of sample apps, how does this fit into the development process with the VS code extension?

    I'm not sure I understand what you are asking. You can add "modifications" to overlay files and add them as extra cmake arguments in the build configuration. 

    Spent some time with your Developer Academy videos, especially the one dealing with dts file, kconfig, etc., the configuration approach inherited with zephyr.  Unfortunately, the relevant video is mainly a rehash of the zephyr docs, thin on practical examples, leaving the discussion as obtuse as ever.

    Have your provided this feedback in the survey? If not, please provide this valuable feedback there. You may also contact the Academy team directly via [email protected]. Also, each session has its own feedback button on the right hand side.

    Kind regards,
    Øyvind

Reply
  • Hello Mike, 

    On a related topic, it's been noted earlier on DevZone that the nRF52840 might not be a good prototyping platform for most Matter apps because of flash memory limits (1 MB) vs. the DK and other nRF52840 boards which have external flash.  

    As you might already know the Matter protocol is per our SDK not tested with the nRF52840 Dongle due to the lack of external flash which is used for e.g. Device Firmware Updgrade, and the dongle has less flash for application due to the pre-programmed bootloader. For that reason our Matter team focuses on providing full support for the development kits. That said, our team did add dongle support in Matter nRF Connect Lighting Example Application in the upstream Matter repository., Note that this is not tested with our samples or current version of the nRF Connect SDK.

    To solve my immediate problem, can you outline a specific set-by-step procedure to modify the template of the Hello World app to direct serial output from printk statements over the USB connection with CDC ACM UART?

    Will need to look into this part. I have not been successful in running CDC ACM on the dongle.

    Does there exist in either the Nordic or Zephyr documentation a more complete description of the Zephyr configuration files and tools, including not only the formal definition, but more examples?  Visual diagrams?  Catalog of configuration properties, with logical groupings?  Anything to make it easier to understand the process from a practical point of view

    Nothing more than what is available in the documentation I'm afraid. Circuit Dojo have several videos covering configurations in the Zephyr environment. Have a look at the Circuit Dojo YouTube channel.

    If this does not provide any more answer, please specify exactly what you are looking for and I will try to provide better answers.

    Given that these kinds of mods need to be done on "templates" of sample apps, how does this fit into the development process with the VS code extension?

    I'm not sure I understand what you are asking. You can add "modifications" to overlay files and add them as extra cmake arguments in the build configuration. 

    Spent some time with your Developer Academy videos, especially the one dealing with dts file, kconfig, etc., the configuration approach inherited with zephyr.  Unfortunately, the relevant video is mainly a rehash of the zephyr docs, thin on practical examples, leaving the discussion as obtuse as ever.

    Have your provided this feedback in the survey? If not, please provide this valuable feedback there. You may also contact the Academy team directly via [email protected]. Also, each session has its own feedback button on the right hand side.

    Kind regards,
    Øyvind

Children
No Data
Related