Cellular modem with Sara-R5 turning off fail #74982
-
I am using the Description of my environment Describe the bug
static void sleep_mode_entering(struct k_work *work)
{
const struct device *modem = DEVICE_DT_GET(DT_ALIAS(modem));
// disconnect mqtt
ret = mqtt_disconnect(&client_ctx);
if (ret < 0){
LOG_ERR("Error during MQTT disconnection, %d", ret);
return;
}
mqtt_connected = false;
LOG_INF("MQTT client disconnecting...");
// wait until MQTT client is disconnected
k_sem_take(&mqtt_stop, K_FOREVER);
// Turn off modem
ret = pm_device_action_run(modem, PM_DEVICE_ACTION_SUSPEND);
if (ret < 0){
LOG_ERR("Error turning off the modem, %d", ret);
return;
}
// Turn off UART
ret = pm_device_action_run(uart, PM_DEVICE_ACTION_SUSPEND);
if (ret < 0){
LOG_ERR("Error turning off the uart, %d", ret);
return;
}
// Entering SoC into sleep. Waking up only wakeup_pin by reset
sys_poweroff();
return;
} However, the result of the Expected behavior Additional context Thus, I wonder how can I enter into idle state before turning off the modem or what should be the correct steps to powering off the modem. Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
Hi, this is likely because you are calling the sync pm commands from the system work queue thread :) The modem subsystem including the cellular modem device driver run in the system work queue using k_work items. Since the pm_device_action_run() blocks the thread that calls it, the cellular modem driver is deadlocked :) Try calling suspend from another thread, main for example :) or create a dedicated work queue for the application to use :) |
Beta Was this translation helpful? Give feedback.
Hi, this is likely because you are calling the sync pm commands from the system work queue thread :) The modem subsystem including the cellular modem device driver run in the system work queue using k_work items. Since the pm_device_action_run() blocks the thread that calls it, the cellular modem driver is deadlocked :)
Try calling suspend from another thread, main for example :) or create a dedicated work queue for the application to use :)