Skip to content

Commit cce269b

Browse files
committed
app: Do not call LOG_PANIC() with reset or shutdown
Calling LOG_PANIC() can lead to RTT trace corruption and assert as the RTT trace is intended to be sent only from logging thread. This was observed with full modem FOTA. Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no> (cherry picked from commit 5945158)
1 parent 258d067 commit cce269b

6 files changed

Lines changed: 7 additions & 8 deletions

File tree

app/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int sm_main(void)
289289
return ret;
290290

291291
exit_reboot:
292-
LOG_PANIC();
292+
log_flush();
293293
sys_reboot(SYS_REBOOT_COLD);
294294
}
295295
SYS_INIT(sm_main, APPLICATION, 100);

app/src/sm_at_commands.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static void sm_shutdown(void)
141141
{
142142
sm_at_host_uninit();
143143
sm_power_off_modem();
144-
LOG_PANIC();
145144
sm_ctrl_pin_enter_shutdown();
146145
}
147146

@@ -160,7 +159,7 @@ FUNC_NORETURN void sm_reset(void)
160159
{
161160
sm_at_host_uninit();
162161
sm_power_off_modem();
163-
LOG_PANIC();
162+
log_flush();
164163
sys_reboot(SYS_REBOOT_COLD);
165164
}
166165

app/src/sm_at_dfu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static int handle_at_xdfu_init(enum at_parser_cmd_type cmd_type, struct at_parse
312312

313313
(void)set_full_mfw_dfu_segment_type(DFU_FULL_MFW_SEGMENT_BOOTLOADER);
314314

315-
LOG_PANIC();
315+
log_flush();
316316
sys_reboot(SYS_REBOOT_COLD);
317317
default:
318318
LOG_ERR("Invalid target type: %d", type);
@@ -566,7 +566,7 @@ static int handle_at_xdfu_apply(enum at_parser_cmd_type cmd_type, struct at_pars
566566
(void)set_full_mfw_dfu_segment_type(
567567
DFU_FULL_MFW_SEGMENT_BOOTLOADER);
568568
LOG_INF("Firmware update successful, rebooting...");
569-
LOG_PANIC();
569+
log_flush();
570570
sys_reboot(SYS_REBOOT_COLD);
571571
}
572572
}

app/src/sm_at_fota.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ FUNC_NORETURN static void handle_full_fota_activation_fail(int ret)
529529
LOG_INF("External flash erase succeeded");
530530

531531
LOG_WRN("Rebooting...");
532-
LOG_PANIC();
532+
log_flush();
533533
sys_reboot(SYS_REBOOT_COLD);
534534
}
535535

app/src/sm_at_host.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,6 @@ static void handle_bootloader_at_cmd(uint8_t *buf, size_t buf_size, char *at_cmd
10841084
}
10851085
} else if (strncasecmp(at_cmd, AT_XRESET_CMD, sizeof(AT_XRESET_CMD) - 1) == 0) {
10861086
LOG_INF("Rebooting device via %s command", AT_XRESET_CMD);
1087-
LOG_PANIC();
10881087
final_call(sm_reset);
10891088
} else {
10901089
LOG_ERR("AT command not supported in bootloader mode: %s", at_cmd);

app/src/sm_ctrl_pin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void sm_ctrl_pin_enter_sleep_no_uninit(bool at_host_power_off)
101101
}
102102

103103
LOG_INF("Entering sleep. No uninit.");
104-
LOG_PANIC();
104+
log_flush();
105105

106106
k_sleep(K_MSEC(100));
107107

@@ -155,6 +155,7 @@ void sm_ctrl_pin_enter_idle(void)
155155
void sm_ctrl_pin_enter_shutdown(void)
156156
{
157157
LOG_INF("Entering shutdown.");
158+
log_flush();
158159
k_sleep(K_MSEC(100));
159160

160161
nrf_regulators_system_off(NRF_REGULATORS_NS);

0 commit comments

Comments
 (0)