CONFIG_LOG over uart and power management

Hi,

I am starting the migration of a product from Zephyr/SoC STM32 to NCS/nRF5340.
To reach the lowest power consumption level, I know that Nordic SoC require to configure
```CONFIG_LOG=n
CONFIG_SERIAL=n

```

I feel like this is a recurring topic, but I haven't seen a solution on the support forum.

I am surprised, because on an STM32, it is possible to evacuate the traces and the uart goes to sleep by itself.
I think that this is due to the implementation of the functions in uart_stm32.c :

```pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);```

To get around the problem, I implemented the callbacks for pm_notifier_register() in order to do the suspend/resume of the uart myself.

The problem is that the nRF5340 does not declare its cpu-power-states, so the callbacks are not called.

By defining a simple overlay, the callbacks are called in a loop and the CPU doesn't stay in idle anymore:
```/ {

power-states {
idle: idle {
compatible = "zephyr,power-state";
power-state-name = "suspend-to-idle";
min-residency-us = <100000>;
exit-latency-us = <100000>;
};
};
};

&cpu0 {
cpu-power-states = <&idle>;
};```

In short, is it possible to be notified of the wake up and sleep of the CPU, in order to do the resume/suspend of the uart?
Conversely, is it possible to configure the uart in auto-resume, so that the uart can be used without having to manually resume/suspend?

Using uart logs (TX only) in combination with power management would be really useful.

For the context:
We are developing a product that interfaces via AT commands with a host.
The host client, which already has a UART link for AT commands may want to activate traces through the same link. This is something that worked on STM32, and I would like to be able to offer it on the nRF5340 base.

Parents Reply Children
No Data
Related