Working UART and Console configuration for NRF52840 does not work for NRF5340

Hi,

I've run into a problem where a codebase build for NRF52840dk and NRF5340dk boards successfully but running it on the NRF5340 results in logs not working.

I have included the relevant configuration content below which comes from two configuration files that we are applying in the build: "prj.conf" & "nrf5340dk_nrf5340_cpuapp.conf"

We have a custom library running on UART 1 that handles custom protocol building/parsing, error checking and UART TX & RX, and we have the logs running on the default UART 0.

Can you advise what configuration changes we need to make to allow this to work for both the NRF52840dk and the NRF5340dk?

sdk-nrf version: v2.5.1

nrf5340dk_nrf5340_cpuapp.conf Contents:

CONFIG_UART_1_ASYNC=y
CONFIG_UART_1_INTERRUPT_DRIVEN=n

CONFIG_UART_0_INTERRUPT_DRIVEN=y
CONFIG_UART_0_ASYNC=n

prj.conf Contents:

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This file contains selected Kconfig options for the application.
CONFIG_ASSERT=y

CONFIG_LOG=y
CONFIG_BOOT_BANNER=n
CONFIG_APP_LOG_LEVEL_INF=y
CONFIG_APP_BUTTON_LOG_LEVEL_INF=y
CONFIG_APP_LED_LOG_LEVEL_INF=y
CONFIG_APP_UART_LOG_LEVEL_DBG=y

CONFIG_INTER_MCU_COMMS_LOG_LEVEL=4

CONFIG_ZBUS=y
CONFIG_ZBUS_LOG_LEVEL_INF=y
CONFIG_ZBUS_RUNTIME_OBSERVERS=y

CONFIG_ZBUS_CHANNEL_NAME=y
CONFIG_ZBUS_OBSERVER_NAME=y

CONFIG_GPIO=y

CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y

CONFIG_SHELL=y
CONFIG_LOG_CMDS=y
CONFIG_DEVICE_SHELL=y
CONFIG_GPIO_SHELL=y

# Task Watchdog
CONFIG_TASK_WDT=y
CONFIG_TASK_WDT_CHANNELS=11
CONFIG_TASK_WDT_MIN_TIMEOUT=10000

# Device power management
CONFIG_PM_DEVICE=y

#Debug
CONFIG_DEBUG=y
CONFIG_DEBUG_OPTIMIZATIONS=y

# BT
CONFIG_BT_LL_SW_SPLIT=n
CONFIG_BT=y
CONFIG_BT_ID_MAX=1
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_BAS=y
CONFIG_BT_HRS=n
CONFIG_BT_DEVICE_NAME="XXXX"
CONFIG_BT_DEVICE_APPEARANCE=31368
# 32 Seconds
CONFIG_BT_LIM_ADV_TIMEOUT=32
# 12.5ms to 15ms COnnection Interval
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=10
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=12

# Enable the NUS service
CONFIG_BT_NUS=y

# BT Pairing
CONFIG_BT_SMP=y
CONFIG_BT_SMP_APP_PAIRING_ACCEPT=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=2
CONFIG_BT_FIXED_PASSKEY=y
CONFIG_BT_FILTER_ACCEPT_LIST=y
# The use of RPA is not enabled
CONFIG_BT_PRIVACY=n

# # DIS Items
CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=n
CONFIG_BT_DIS_SERIAL_NUMBER=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_SW_REV=y
CONFIG_BT_DIS_SERIAL_NUMBER_STR="X.X.X.X"
CONFIG_BT_DIS_FW_REV_STR="FW V00.00.00.00"
CONFIG_BT_DIS_HW_REV_STR="Zephyr Hardware"
CONFIG_BT_DIS_SW_REV_STR="Zephyr Software"

# Below is setup to let DIS information be read from settings
CONFIG_BT_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NONE=y

CONFIG_BT_DIS_SETTINGS=y
CONFIG_BT_DIS_STR_MAX=31

# Below is setup to let DIS information be read from settings
CONFIG_SETTINGS_NONE=y

# Enable BT Bonding and DIS info read from settings
CONFIG_BT_SETTINGS=y
CONFIG_SETTINGS=y
CONFIG_NVS=y
CONFIG_SETTINGS_NVS=y
CONFIG_SETTINGS_RUNTIME=y
CONFIG_BT_BONDABLE=y
CONFIG_BT_ID_UNPAIR_MATCHING_BONDS=y

# Stacks & threads
CONFIG_MPU_STACK_GUARD=y
CONFIG_BT_RX_STACK_SIZE=2048
# Note: This stack must be 2K or higher to avoid stack overflow when pairing to Android Devices
CONFIG_MPSL_WORK_STACK_SIZE=2048
CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
CONFIG_BT_HCI_TX_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4608
CONFIG_IDLE_STACK_SIZE=1024
CONFIG_MAIN_STACK_SIZE=4096

# Priority
# We set the main thread priority low to ensure all other threads have a chance to run first and block on their
# semaphores. Doing this is better since we do not have to wait for the other threads to run first
CONFIG_MAIN_THREAD_PRIORITY=10

# Helps make breakpoint debugging more reliable - otherwise will often not break at main
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n
CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=n

# Logging & Console
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_TIMESTAMP_64BIT=y

CONFIG_USE_SEGGER_RTT=n
CONFIG_RTT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_SENSOR=y
# Inter-MCU Comms Module
CONFIG_INTER_MCU_COMMS_MODULE=y
CONFIG_RING_BUFFER=y
CONFIG_CRC=y
CONFIG_INTER_MCU_COMMS_MAX_PAYLOAD_SIZE=1024
CONFIG_MW_COBS=y
CONFIG_HEAP_MEM_POOL_SIZE=4096
Parents
  • Hi Sigurd,

    Thanks for following up. I managed to get the uart0 logs working again Slight smile

    This is what my cpuapp.conf file looked like when I was finished:

    #################################################

    # Enable both APIs
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_INTERRUPT_DRIVEN=y

    # Flag UART0 as not ASYNC, but INTERRUPT
    CONFIG_UART_0_INTERRUPT_DRIVEN=y
    CONFIG_UART_0_ASYNC=n

    # Flag UART1 as not INTERRUPT, but ASYNC

    # We have to use CONFIG_UART_1_NRF_HW_ASYNC to use hardware RX Byte counting
    # "If default driver uses interrupts to count incoming bytes, it is possible
    # that with higher speeds and/or high cpu load some data can be lost.
    # It is recommended to use hardware byte counting in such scenarios.
    # Hardware RX byte counting requires timer instance and one PPI channel"

    CONFIG_UART_1_ASYNC=y
    CONFIG_UART_1_INTERRUPT_DRIVEN=n
    CONFIG_UART_1_NRF_HW_ASYNC=y
    CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2
    CONFIG_NRFX_TIMER2=y
    #################################################

    With this setup and the UART 1 pin forwarding issue resolved I was able to have logs and console running on UART0 as expected while having the UART1 peripheral used for our custom communications library in async mode without bytes lost at high baud rates

Reply
  • Hi Sigurd,

    Thanks for following up. I managed to get the uart0 logs working again Slight smile

    This is what my cpuapp.conf file looked like when I was finished:

    #################################################

    # Enable both APIs
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_INTERRUPT_DRIVEN=y

    # Flag UART0 as not ASYNC, but INTERRUPT
    CONFIG_UART_0_INTERRUPT_DRIVEN=y
    CONFIG_UART_0_ASYNC=n

    # Flag UART1 as not INTERRUPT, but ASYNC

    # We have to use CONFIG_UART_1_NRF_HW_ASYNC to use hardware RX Byte counting
    # "If default driver uses interrupts to count incoming bytes, it is possible
    # that with higher speeds and/or high cpu load some data can be lost.
    # It is recommended to use hardware byte counting in such scenarios.
    # Hardware RX byte counting requires timer instance and one PPI channel"

    CONFIG_UART_1_ASYNC=y
    CONFIG_UART_1_INTERRUPT_DRIVEN=n
    CONFIG_UART_1_NRF_HW_ASYNC=y
    CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2
    CONFIG_NRFX_TIMER2=y
    #################################################

    With this setup and the UART 1 pin forwarding issue resolved I was able to have logs and console running on UART0 as expected while having the UART1 peripheral used for our custom communications library in async mode without bytes lost at high baud rates

Children
No Data
Related