Skip to content

Commit

Permalink
feat(reboot_reason): msg in reboot handler and Memfault
Browse files Browse the repository at this point in the history
Move CAN msg from shutdown to reboot handler and publish event on Memfault

Signed-off-by: Srikar Chintapalli <[email protected]>
  • Loading branch information
sri9311 committed Jan 15, 2025
1 parent 9ec1791 commit 47dfdeb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions main_board/config/memfault_reboot_reason_user_config.def
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Defines "unexpected" reboots
MEMFAULT_UNEXPECTED_REBOOT_REASON_DEFINE(BatteryRemoved)
MEMFAULT_UNEXPECTED_REBOOT_REASON_DEFINE(HeartbeatFromJetsonTimeout)
MEMFAULT_EXPECTED_REBOOT_REASON_DEFINE(JetsonRequestedReboot)
28 changes: 18 additions & 10 deletions main_board/src/runner/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <memfault/metrics/connectivity.h>
#endif

#if defined(CONFIG_MEMFAULT)
#include <memfault/core/reboot_tracking.h>
#endif

LOG_MODULE_REGISTER(runner, CONFIG_RUNNER_LOG_LEVEL);

K_THREAD_STACK_DEFINE(runner_process_stack, THREAD_STACK_SIZE_RUNNER);
Expand Down Expand Up @@ -287,16 +291,6 @@ handle_shutdown(job_t *job)
if (delay > 30) {
job_ack(orb_mcu_Ack_ErrorCode_RANGE, job);
} else {
// Send out shutdown scheduled CAN message
orb_mcu_main_ShutdownScheduled shutdown;
shutdown.shutdown_reason =
orb_mcu_main_ShutdownScheduled_ShutdownReason_JETSON_REQUESTED_REBOOT;
shutdown.has_ms_until_shutdown = true;
shutdown.ms_until_shutdown = delay * 1000;
publish_new(&shutdown, sizeof(shutdown),
orb_mcu_main_McuToJetson_shutdown_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);

int ret = reboot(delay);

if (ret == RET_SUCCESS) {
Expand All @@ -321,6 +315,20 @@ handle_reboot_message(job_t *job)
job_ack(orb_mcu_Ack_ErrorCode_RANGE, job);
LOG_ERR("Reboot with delay > 60 seconds: %u", delay);
} else {
// Send out shutdown scheduled CAN message
orb_mcu_main_ShutdownScheduled shutdown;
shutdown.shutdown_reason =
orb_mcu_main_ShutdownScheduled_ShutdownReason_JETSON_REQUESTED_REBOOT;
shutdown.has_ms_until_shutdown = true;
shutdown.ms_until_shutdown = delay * 1000;
publish_new(&shutdown, sizeof(shutdown),
orb_mcu_main_McuToJetson_shutdown_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
#ifdef CONFIG_MEMFAULT
MEMFAULT_REBOOT_MARK_RESET_IMMINENT(
kMfltRebootReason_JetsonRequestedReboot);
#endif

int ret = reboot(delay);

if (ret == RET_SUCCESS) {
Expand Down

0 comments on commit 47dfdeb

Please sign in to comment.