nrf52840 zephyr disable uart0 warning

It has been asked before but I couldn't find a satisfying answer so far. To reduce base power consumption of 600uA to roughly 3uA I disabled serial by setting CONFIG_SERIAL=n in prj.conf. But I get the following warning:

warning: UART_CONSOLE (defined at drivers/console/Kconfig:43) was assigned the value 'y' but got the
value 'n'. Check these unsatisfied dependencies: SERIAL (=n), SERIAL_HAS_DRIVER (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_CONSOLE and/or look up UART_CONSOLE in
the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

It does work however, and the powerconsumption is reduced. I'm on SDK v2.3.0.

I also tried to just disable serial in the device tree, but it's called somewhere in the project (probably <zephyr/logging/log.h>, so the build crashes unless I do the above.)

&pinctrl {
    uart0_default: uart0_default {
    		status="disabled";
    };
};

I also tried disabling using setting the powerstate at runtime, but I cannot figure the arguments I've to put in the function, as the signature has changed over time and I'm unable to find a current example. The latest I could find is of Zephyr 1.4.

int pm_device_state_set(conststructdevice*dev, uint32_t device_power_state,pm_device_cbcb,void*arg)

Question why is this warning and what is the right way to disable serial (or reduce power).

Edit: I guess it should be

err = pm_device_action_run(device, PM_DEVICE_ACTION_SUSPEND);

during runtime.

Parents
  • CONFIG_SERIAL=n in prj.conf. But I get the following warning:

    Use the "Kconfig" search in VS Code to determine what sets this to "y".
    Just looks like you set UART_CONSOLE in you project config somewhere, and it is automatically set to "n" when you disable SERIAL, which makes sense to me.

    I also tried to just disable serial in the device tree

    You try to disable uart0 inside pinctrl, and not inside the driver itself. Try:

    &uart0 {
        status = "disabled";
    };

    Then after you build, have a look at build/zephyr/zephyr.dts to verify that all the drivers have the expected status.

    Edit: I guess it should be

    Both DeviceTree and Power Management are good ways to disable a peripheral to save power.

    Use the DeviceTree if you never intend to use that peripheral.
    Use the Power Management if you intend to use the peripheral sporadically.

    Regards,
    Sigurd Hellesvik

  • Nope, disabling like that in the devicetree does not work,

    /home/bergm006/ncs/v2.3.0/zephyr/include/zephyr/device.h:83:41: error: '__device_dts_ord_114' undeclared here (not in a function); did you mean '__device_dts_ord_11'?
       83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)

    I did not include device.h in my project.

    #include <stdio.h>
    #include <zephyr/kernel.h>
    #include <zephyr/types.h>
    #include <zephyr/pm/pm.h>
    #include <zephyr/pm/device.h>
    #include <stddef.h>
    #include <string.h>
    #include <errno.h>
    #include <zephyr/sys/byteorder.h>
    #include <zephyr/kernel.h>
    #include <zephyr/logging/log.h>
    #include <zephyr/settings/settings.h>
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/hci.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/uuid.h>
    #include <zephyr/bluetooth/gatt.h>
    #include <zephyr/drivers/gpio.h>
    #include <zephyr/logging/log.h>
    #include <zephyr/drivers/i2c.h>

  • Hi,

    Can you post your prj.conf as well?

    Regards,
    Sigurd Hellesvik

  • CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    
    CONFIG_BT=y
    
    CONFIG_BT_SMP=y
    CONFIG_BT_SIGNING=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DIS=y
    CONFIG_BT_ATT_PREPARE_COUNT=5
    CONFIG_BT_PRIVACY=y
    CONFIG_BT_DEVICE_NAME="xxx"
    CONFIG_BT_DEVICE_APPEARANCE=3137
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=65
    
    
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    CONFIG_I2C=y
    CONFIG_EVENTS=y
    CONFIG_SERIAL=n
    CONFIG_LOG=n
    CONFIG_PM=y
    CONFIG_PM_DEVICE=y
    

    (The error only occures when CONFIG_SERIAL=y, when '=n, the warning of the first post appears.)

  • To make things simpler the hello world project has the same issue.

    #include <zephyr/kernel.h>
    
    void main(void)
    {
    	while(1) {
    		k_sleep(K_MSEC(1000));
    	}
    }
    

    &uart0 {
        status = "disabled";
    };
    
     

    proj.conf empty (and when I add CONFIG_SERIAL=n the same warning appears)

  • CONFIG_CONSOLE is enabled by default, and it selects UART_CONSOLE, which depends on CONFIG_SERIAL.

    So to get rid of the warning, set:

    CONFIG_UART_CONSOLE=n

    or

    CONFIG_CONSOLE=n

    By the way, if you are doing power optimization, maybe this page can be helpful later.

    Regards,
    Sigurd Hellesvik

  • No, that is not the solution:

    CMake Warning at /home/bergm006/ncs/v2.3.0/zephyr/CMakeLists.txt:824 (message):
      No SOURCES given to Zephyr library: drivers__console
    
      Excluding target from build.
    

Reply Children
Related