LOG only shows full ring buffer.

Hello,

I'm currently trying to implement a simple scenario: Using the nRF52840_Dongle, provide LOG output to the console.

This is the main program:

#include <zephyr.h>
#include <sys/printk.h>
#include <usb/usb_device.h>
#include "utils/usb_console.h"

LOG_MODULE_REGISTER(meen, 3);

void main(void)
{
	// Only run if console was properly set up
	if (!usb_console_setup()) {
		return;
	}
	k_sleep(K_SECONDS(5));
	printk("INIT\n");
	while(1) {
		printk("NEXT\n");
		LOG_DBG("test debug");
		LOG_ERR("test error");
		LOG_INF("test info");
		k_sleep(K_SECONDS(1));
	}
}

This is the usb_console.c:

#include "usb_console.h"

BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
	     "Console device is not ACM CDC UART device");

bool usb_console_setup() {
    DEVICE_DT_GET(DT_CHOSEN(zephyr_console));

    if (usb_enable(NULL)) {
		return false;
	}

    return true;
}

Development setup:

- nRF52840 DONGLE

- nRF Connect SDK 1.8.0

- VSCode with nrf Connect extension

- win 10

- nrf Connect programmer

What I tried:

- usb/console example, this is actually the basis of my program (result: works, but it uses printk, not LOG_)

- cdc_acm_composite (result: I can send messages from one terminal to another, but I don't see any of the LOG_ messages anywhere.)

- messing with config, can't list everything that I tried here (result: absolutely nothing changed, no matter what I tried.)

What works:

- printk messages are viewed in the console just fine

What doesn't work:

- log messages don't show up

Now that the basics are down, let me introduce you to some weird behaviour:

When I build my small program, it first spams (like 20 messages): <inf> usb_cdc_acm: Ring buffer full, drain buffer

After that it continues to print "NEXT" to the console every second, which obviously corresponds to the printk as shown in the code.

But sometimes when I build my code, for some reason especially after building the cdc_acm_composite example, the aforementioned "spam" does contain some of the LOG messages I expected. If it does though, then it seems to only contain LOGs, not the printk message.

My questions:

Why is the ring buffer full? (seems to fill up with LOG messages that I can't read, I guess)

How can I get LOG messages to show up correctly?

Used Config:

# USB Config
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_DRIVER=y
CONFIG_USB_DEVICE_PRODUCT="My USB Device"

# Logging
CONFIG_LOG=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_DEFAULT_LEVEL=4

If you made it this far: Thank you very much for your time and effort.

Parents Reply Children
No Data
Related