RAK11720 Power Management in Zephyr OS

Hello devs, I am trying to reduce power consumption in my application developed in Zephyr OS and RAK11720. The application makes use of several peripherals and radios such as UART, I2C, Lora and BLE. That clearly makes the power optimization more challenging than usual. Using system power management enabled on Zephyr, the application, in an idle state where no peripherals are on, really shows low consumption. The issue rises once we activate UART; then, consumption increases of more than 100 μA. I tried to disable UART at runtime using zephyr PM APIs for device handling like pm_device_action_run() or UART APIs but nothing worked. Has anyone had dealt with it before?

Hello @Giovanni

Welcome to forum. I also tried to suspend UART peripheral of the RAK11720 on Zephyr RTOS v4.2.0 and I am also seeing 65uA constant current consumption. In my opinion, this is Zephyr’s UART driver problem. I will check your case and inform you when I have solved it.

Best regards,
Sercan.

Thank you very much @sercan, looking forward to it.

Hello @Giovanni

The reason of the problem is Zephyr’s UART driver. If you can apply following patch to your Zephyr RTOS repo (v4.2.0), it is solving UART sleep problem.

0005-Fixing-Apollo3-UART-sleep-problem.patch.zip (2.7 KB)

I used this project to check sleep current and I see that it is okay on my side. Let’s see how it will behave on your side.

This is my test project.

uart_sleep.zip (9.2 KB)

Best regards,
Sercan.

We have just tested it and it actually worked well! Thank you for your help @sercan. We are measuring an average consumption of 7 μA running your project on a rak11722. Is it a value you have measured as well?

You are welcome, @Giovanni . Yes, 7uA is expected value.

1 Like

Hello @sercan,

I reopen this thread because I tried to do the same power optimization on a RAK3172 and it didn’t work as it did on the rak11720. I used the same project you previously attached, configuring a dedicated overlay for the rak3172:

/ {
	aliases {
		test-uart = &usart1;
	};
};

&usart1 {
    status = "okay";
    current-speed = <115200>;
    pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;
    pinctrl-1 = <&usart1_tx_pb6_sleep &usart1_rx_pb7_sleep>;
    pinctrl-names = "default", "sleep";
};

&pinctrl {
    usart1_tx_pb6: usart1_tx_pb6 {
        pinmux = <STM32_PINMUX('B', 6, AF7)>;
    };
    
    usart1_rx_pb7: usart1_rx_pb7 {
        pinmux = <STM32_PINMUX('B', 7, AF7)>;
        bias-pull-up;
    };

    usart1_tx_pb6_sleep: usart1_tx_pb6_sleep {
        pinmux = <STM32_PINMUX('B', 6, ANALOG)>;
    };
    
    usart1_rx_pb7_sleep: usart1_rx_pb7_sleep {
        pinmux = <STM32_PINMUX('B', 7, ANALOG)>;
    };
};

I didn’t find an equivalent property of “low-power-enable” used in rak11720 overlay sleep pinctrl. I tried to set the pins to analog then, but it didn’t work. Current values keeps staying around 115 uA. Can you help us?

ps: we are already using lpuart for another purpose, so we need to test low power on usart

Hello @Giovanni

On my side, if I enabled PM, I am not able to see any data on my serial terminal. I feel there is a bug for STM32 UART driver on Zephyr RTOS. If you are able to see UART activity on your side while PM is active, please try to enabled following flags.

CONFIG_PINCTRL=y
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_PM_DEVICE_SYSTEM_MANAGED=n

Let’s see how MCU will behave. I will continue to check UART PM problem and inform you.

Best regards,
Sercan.

Hi @sercan,

some days ago while trying to test UART PM on RAK3172 we stumbled upon the same issue and found out some others devs had already reported the same bug and fixed the next day:

If you pull zephyr repo and west update the bug should fix.
Let us know any further updates,
hearing from you soon.

Thanks @Giovanni to inform me about this fix. I tested it on Zephyr RTOS v4.2.0 with following patch. (The patch file does the same thing as the fix. ) Please use following example project on your side. I am able to reach lowest sleep current.

0006-Fixing-STM32-Usart-PM-problem.patch.zip (3.6 KB)

uart_sleep.zip (11.2 KB)

Best regards,
Sercan.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.