This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NCS Uart Console Suspend Before Log Outpput

Hi Nordic:

Test with board nrf5340-dk ncs v1.9.1

prj.conf

# Console
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_DEFAULT_LEVEL=3
# UartConsole
CONFIG_UART_CONSOLE=y
CONFIG_LOG_BACKEND_UART=y
# RttConsole
CONFIG_RTT_CONSOLE=n
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n
# Power Manager
CONFIG_PM=y
CONFIG_PM_DEVICE=y
in test.c
printk("disable_console\n");
k_sleep(K_MSEC(500));
pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
The Log message "disable_console" woun't disaplay on uart console.
Is there any APIs that can process the log output before console suspend.
Thanks
  • I tested this myself with NCS v1.9.1 and the nRF5340 DK, and was not able to reproduce. Test it yourself with the same sample:

    disable_console.zip

    Best regards,

    Simon

  • Hi Simon:

    Thanks for the quick reply. I test your case and the console output was OK.

    But if i keep Suspend & Resume the console device. The consle will have no output.

    Below is my change on the main.c of your code.

    #include <zephyr.h>
    #include <sys/printk.h>
    #include <pm/device.h>
    
    #define TEST_DELAY 500
    
    #define UART_DEVICE_NAME DT_LABEL(DT_CHOSEN(zephyr_console))
    
    void main(void)
    {
    	const struct device *console_dev;
    	console_dev = device_get_binding(UART_DEVICE_NAME);
        printk("output1\n");
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME);
        printk("output2\n");
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME);
        printk("output3\n");
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME);
        printk("output4\n");
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME);
        printk("output5\n");
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME);
        printk("output6\n");
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        k_sleep(K_MSEC(TEST_DELAY));
        pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME);
    	printk("disable_console\n");
    	k_sleep(K_MSEC(TEST_DELAY));
    	pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);
        printk("console disabled\n");
        k_sleep(K_MSEC(TEST_DELAY));
    }
    
    

    If i increase the TEST_DELAY to 2000ms , The Console Output will be Normal.

    Thanks

    Best Regards

    Chen

  • Try setting CONFIG_LOG_PRINTK=n, then your sample should work with a delay of 500ms.

    disable_console_v2.zip

    Is this an acceptable fix for you?

  • Hi Simon:

    Thanks .

    And we found that there was a API That can make the consle output without delay.

    #include <logging/log_ctrl.h>
    
    printk("disable_console\n");
    while(log_process(false));
    pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);

Related