Hi there,
I have been trying to implement a low-power mode that basically suspends UART, I2C, etc before entering sys_poweroff() when critical battery level is triggered.
As a test, I used the following main() script to suspend console - something that is physically observable to me without disabling the GPIO wakeup source
My goal was to resume it when a GPIO interrupt is triggered - which will later be my charging IC interrupt when device is connected to power.
int main(void)
{
printk("system starting...\n");
if (!device_is_ready(button.port))
{
printk("button device not ready\n");
return 1;
}
if (!device_is_ready(led.port))
{
printk("LED device not ready\n");
return 1;
}
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
gpio_pin_set_dt(&led, 1);
// configure button with interrupt
gpio_pin_configure_dt(&button, GPIO_INPUT);
gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_TO_ACTIVE);
gpio_init_callback(&button_cb_data, button_pressed_isr, BIT(button.pin));
gpio_add_callback(button.port, &button_cb_data);
printk("entering simulated low power mode\n");
printk("console will suspend. Press button to wake up\n");
// suspend UART console (to simulate print being "lost" during sleep)
if (pm_device_action_run(uart_console_dev, PM_DEVICE_ACTION_SUSPEND) == 0)
{
printk("console suspended. This should NOT be visible\n");
}
else
{
printk("failed to suspend console device\n");
}
// simulate "sleep" by waiting for wake-up event
while (!wake_up)
{
k_sleep(K_MSEC(100)); // light sleep
}
// resume UART console
pm_device_action_run(uart_console_dev, PM_DEVICE_ACTION_RESUME);
printk("system resumed from low power mode\n");
gpio_pin_set_dt(&led, 0);
return 0;
}
My issue is that I can no longer print anything to UART console, even after resuming it.
I created a separate script for debugging that only tries to resume the console, and found that pm_device_action_run(uart_console_dev, PM_DEVICE_ACTION_RESUME) was returning:
-EALREADY "If device is already at the requested state."
This makes sense if I didn't try to suspend it, however I am quite confused why I can no longer see serial output across re-flashing and reboot from either COM port despite UART console apparently being active

I am using nrf54L15dk on v3.1.0 SDK
Any help would be much appreciated. Thanks