Custom board for nRF52811 in nRFConnect - code halts on z_log_minimal_printk() in CONFIG_UART_CONSOLE=y, but if RTT console is used, code debugs fine.

Hi there

#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_DK_LIBRARY=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# CONFIG_BT=y
# CONFIG_BT_PERIPHERAL=y
# CONFIG_BT_DEVICE_NAME="ElixirS2-PPI"
# CONFIG_BT_MAX_CONN=2
# CONFIG_BT_SMP=y
# CONFIG_BT_MAX_PAIRED=2

# Enable the BMS service
# CONFIG_BT_BMS=y

# Enable bonding
# CONFIG_BT_SETTINGS=y
# CONFIG_FLASH=y
# CONFIG_FLASH_PAGE_LAYOUT=y
# CONFIG_FLASH_MAP=y
# CONFIG_NVS=y
# CONFIG_SETTINGS=y

# ADC Stuff
CONFIG_DYNAMIC_INTERRUPTS=y
CONFIG_NRFX_SAADC=y
CONFIG_NRFX_SPIM1=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_NRFX_RTC0=y

# Logging to RTT
#CONFIG_USE_SEGGER_RTT=y
#CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_MAX_LEVEL=4
CONFIG_LOG_PRINTK=y


CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
prj.conf

// Copyright (c) 2021 Nordic Semiconductor ASA
// SPDX-License-Identifier: Apache-2.0

/dts-v1/;
#include <nordic/nrf52811_qfaa.dtsi>

/ {
	model = "LX_ElixirS2";
	compatible = "LX-nrf52811";

	chosen {
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,uart-mcumgr = &uart0;
		zephyr,bt-mon-uart = &uart0;
		zephyr,bt-c2h-uart = &uart0;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
	};
};

&adc {
	status = "okay";
};

&gpiote {
	status = "okay";
};

&gpio0 {
	status = "okay";
};

&uart0 {
	status = "okay";
	compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	tx-pin = <9>;
	rx-pin = <8>;
//	rts-pin = <5>;
//	cts-pin = <7>;
};

&spi1 {
	compatible = "nordic,nrf-spi";
	status = "okay";
	sck-pin = <18>;
	mosi-pin = <17>;
	miso-pin = <16>;
};

&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 0xc000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0xc000 0xa000>;
		};
		slot1_partition: partition@16000 {
			label = "image-1";
			reg = <0x16000 0xa000>;
		};
		scratch_partition: partition@20000 {
			label = "image-scratch";
			reg = <0x20000 0xa000>;
		};
		storage_partition: partition@2a000 {
			label = "storage";
			reg = <0x2a000 0x6000>;
		};
	};
};
EXR-200-004.dts

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

#include <kernel.h>
#include <nrfx_timer.h>

#include "hal/nrf_clock.h"

#include "Application/App_Sampling.h"

void main(void)
{
    // This stage of the product won't necessarily have and external xtal. Default to using the inernal RC.
    //nrf_clock_lf_src_set(NRF_CLOCK, NRF_CLOCK_LFCLK_RC);

    AppSampling_InitModule();

    AppSampling_InitRegister();

    k_sleep(K_FOREVER);
}
main.c

Please refer the .dts custom board file.  We took a basic file generated from nRFConnect for nRF52811, and added in some missing bits which match our application, as found in the  board definition for the nRF52832 Dev Kit.  You will note on lines 41/42 we cannot decide what to do with the UART RTS/CTS pin definitions - we don't want to use any.  But we feel that the processor may be blocking, waiting for a hardware CTS signal prior to sending debug content out the serial port.  Is that what's going on?

In prj.conf, lines 38..40, if we enable the RTT instead, the application code works just fine (although we're not currently seeing any RTT output in the SeggerRTTViewer tool, perhaps beside the point, but worth mentioning.).

How would we best setup the configuration for TX/RX-only UART0 debug?

Thanks

Luke

Parents
  • Hi,

    I'll look into this, but as a start you can try these:

    CONFIG_DEBUG=y
    CONFIG_LOG_MINIMAL=n

    If that doesn't work, you can try removing this line:

    CONFIG_NCS_SAMPLES_DEFAULTS=y

  • Thanks.  I did a pristine build after trying the first combination.  I had to exclude the CONFIG_LOG_MINIMAL in my prj.conf file because that generated an error. "this is done somewhere else under another setting"

    As before, when I first enter the debug session, the MCU halts on:

       while ((DWT->CYCCNT - cyccnt_inital) < ANOMALY_132_DELAY_CYCLES)
        {}

    But after I 'reset,' then it consistently halts on:

    void z_log_minimal_printk(const char *fmt, ...)
    {

    When removing :CONFIG_NCS_SAMPLES_DEFAULTS=y, the behaviour is changed.  Now when entering debug, the processor halts in

    static int bus_fault(z_arch_esf_t *esf, int from_hard_fault, bool *recoverable)
    {

    on the return reason; line.  Thereafter it hatls on

        while ((DWT->CYCCNT - cyccnt_inital) < ANOMALY_132_DELAY_CYCLES)
        {}
    Note that my custom target board does not have an LF XTAL, only a 32MHz XTAL,
  • CONFIG_DEBUG=y should always be enabled when debugging, as it disables optimizations.

    Could you try removing CONFIG_NCS_SAMPLES_DEFAULTS=y, adding CONFIG_LOG=y, and then adding these:

    CONFIG_ASSERT=y
    
    CONFIG_HW_STACK_PROTECTION=y

    You can try CONFIG_ASSERT and CONFIG_HW_STACK_PROTECTION each alone and then both together.

Reply Children
No Data
Related