Kconfig CONFIG_LOG_OVERRIDE_LEVEL=4 breaks logging system

Using the Zephyr logging system, setting Kconfig option in prj.conf to override logging to level 4 (output LOG_DBG messages) breaks the console and no output is sent at all.

CONFIG_LOG_OVERRIDE_LEVEL=4
Setting the override level to 1-3 works as expected.
We are using nRF SDK v2.0.2.  This can be reproduced using the "Blinky" sample in the SDK and enabling logging.  The blinky sample is in:
C:\ncs\v2.0.0\zephyr\samples\basic\blinky
I'm attaching the modified prj.conf and main.c files that show the issue.
The following is added to the blinky sample prj.conf file:
CONFIG_GPIO=y

CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BUFFER_SIZE=2048
CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=0
CONFIG_LOG_DEFAULT_LEVEL=2

CONFIG_LOG_OVERRIDE_LEVEL=3
The following lines are added to the blinky sample main.c
...
#include <zephyr/logging/log.h>
...
LOG_MODULE_REGISTER(Blinky, CONFIG_LOG_DEFAULT_LEVEL);

...

void main(void)
{

    ...

	while (1) {
		ret = gpio_pin_toggle_dt(&led);
		if (ret < 0) {
			return;
		}

        ret = gpio_pin_get_dt(&led);
        if (ret) {
            LOG_INF("LED is on"); // shows up with override level 3 & 4
        } else {
            LOG_DBG("LED is off"); // shows up with override level 4
        }

		k_msleep(SLEEP_TIME_MS);
	}
}
We ran this on a BDM-340 evaluation board, which uses the nRF52840.  The project board configuration is set to 
ubx-bmd340eval-nrf52840
To reproduce:
1) Connect a serial terminal (e.g. PuTTY) to the demo board debug COM port at 115200.
2) Build the project with the attached, modified files.
3) Flash the image on the demo board.
4) In the serial Terminal, the following output appears:
*** Booting Zephyr OS build v3.0.99-ncs1 ***
[00:00:00.340,484] <inf> Blinky: LED is on
[00:00:01.340,606] <inf> Blinky: LED is on
NOTE that "LED is off" does not show up because it is LOG_DBG and will not be shown with CONFIG_LOG_OVERRIDE_LEVEL=3
 
5) Edit prj.conf to set CONFIG_LOG_OVERRIDE_LEVEL=4  
6) Do a pristine Build, and flash to the demo board.
7) Note that after flash completes, NO OUTPUT appears, not even "*** Booting Zephyr OS build v3.0.99-ncs1 ***"
The override level can be set back to 3 and it will work again, just not show the LOG_DBG() "off" message again.  Setting it to 2 shows only the boot message, as expected, since LOG_INF() and LOG_DBG() are both above level 2.
Why does override of level 4 not work?
Parents
  • /*
     * Copyright (c) 2016 Intel Corporation
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <zephyr/logging/log.h>
    #include <drivers/gpio.h>
    
    LOG_MODULE_REGISTER(Blinky, CONFIG_LOG_DEFAULT_LEVEL);
    
    /* 1000 msec = 1 sec */
    #define SLEEP_TIME_MS   1000
    
    /* The devicetree node identifier for the "led0" alias. */
    #define LED0_NODE DT_ALIAS(led0)
    
    /*
     * A build error on this line means your board is unsupported.
     * See the sample documentation for information on how to fix this.
     */
    static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
    
    void main(void)
    {
    	int ret;
    
    	if (!device_is_ready(led.port)) {
    		return;
    	}
    
    	ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
    	if (ret < 0) {
    		return;
    	}
    
    	while (1) {
    		ret = gpio_pin_toggle_dt(&led);
    		if (ret < 0) {
    			return;
    		}
    
            ret = gpio_pin_get_dt(&led);
            if (ret) {
                LOG_INF("LED is on"); // shows up with override level 3 & 4
            } else {
                LOG_DBG("LED is off"); // shows up with override level 4
            }
    
    		k_msleep(SLEEP_TIME_MS);
    	}
    }
    

    The "prj.conf" file won't upload as that file type is not allowed, but the full contents are shown above in the original post.

Reply
  • /*
     * Copyright (c) 2016 Intel Corporation
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <zephyr/logging/log.h>
    #include <drivers/gpio.h>
    
    LOG_MODULE_REGISTER(Blinky, CONFIG_LOG_DEFAULT_LEVEL);
    
    /* 1000 msec = 1 sec */
    #define SLEEP_TIME_MS   1000
    
    /* The devicetree node identifier for the "led0" alias. */
    #define LED0_NODE DT_ALIAS(led0)
    
    /*
     * A build error on this line means your board is unsupported.
     * See the sample documentation for information on how to fix this.
     */
    static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
    
    void main(void)
    {
    	int ret;
    
    	if (!device_is_ready(led.port)) {
    		return;
    	}
    
    	ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
    	if (ret < 0) {
    		return;
    	}
    
    	while (1) {
    		ret = gpio_pin_toggle_dt(&led);
    		if (ret < 0) {
    			return;
    		}
    
            ret = gpio_pin_get_dt(&led);
            if (ret) {
                LOG_INF("LED is on"); // shows up with override level 3 & 4
            } else {
                LOG_DBG("LED is off"); // shows up with override level 4
            }
    
    		k_msleep(SLEEP_TIME_MS);
    	}
    }
    

    The "prj.conf" file won't upload as that file type is not allowed, but the full contents are shown above in the original post.

Children
No Data
Related