Skip to content

Commit 000e2d3

Browse files
committed
Add crash dump collection through CMUX.
1 parent c968c66 commit 000e2d3

File tree

11 files changed

+177
-4
lines changed

11 files changed

+177
-4
lines changed

app/boards/nrf9151dk_nrf9151_ns.overlay

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
&uart0 {
1515
status = "okay";
1616
hw-flow-control;
17+
current-speed = <1000000>;
1718

1819
dtr_uart0: dtr-uart {
1920
compatible = "nordic,dtr-uart";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
# CMUX trace backend for modem coredump
8+
CONFIG_NRF_MODEM_LIB_TRACE=y
9+
CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_CMUX=y
10+
# Configure the modem trace level to coredump only
11+
CONFIG_NRF_MODEM_LIB_TRACE_LEVEL_OVERRIDE=y
12+
CONFIG_NRF_MODEM_LIB_TRACE_LEVEL_COREDUMP_ONLY=y

app/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ CONFIG_SM_EXTERNAL_XTAL=n
136136
#CONFIG_LOG_MODE_IMMEDIATE=y
137137
#CONFIG_DEBUG_OPTIMIZATIONS=y
138138
#CONFIG_DTR_UART_LOG_LEVEL_DBG=y
139+
#CONFIG_THREAD_MONITOR=y
140+
#CONFIG_NRF_MODEM_LIB_LOG_LEVEL_DBG=y
139141

140142
# For using external GNSS antenna
141143
#CONFIG_MODEM_ANTENNA=y

app/scripts/sm_start_ppp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ PPP_CMUX=$(ls /dev/gsmtty* | sort -V | head -n 2 | tail -n 1)
185185
log_dbg "AT CMUX: $AT_CMUX"
186186
log_dbg "PPP CMUX: $PPP_CMUX"
187187

188-
sleep 1
188+
sleep 5
189189
stty -F $AT_CMUX clocal
190190

191191
echo "Connect and wait for PPP link..."

app/src/sm_cmux.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ static bool cmux_is_started(void)
296296
return (cmux.uart_pipe != NULL);
297297
}
298298

299+
bool sm_cmux_is_started(void)
300+
{
301+
return cmux_is_started();
302+
}
303+
299304
void sm_cmux_init(void)
300305
{
301306
const struct modem_cmux_config cmux_config = {
@@ -364,6 +369,18 @@ static struct cmux_dlci *cmux_get_dlci(enum cmux_channel channel)
364369
return &cmux.dlcis[!cmux.at_channel];
365370
}
366371
#endif
372+
#if defined(CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_CMUX)
373+
if (channel == CMUX_COREDUMP_CHANNEL) {
374+
#if defined(CONFIG_SM_GNSS_OUTPUT_NMEA_ON_CMUX_CHANNEL)
375+
/* The second to last DLCI. */
376+
return &cmux.dlcis[CHANNEL_COUNT - 2];
377+
#else
378+
/* The last DLCI. */
379+
return &cmux.dlcis[CHANNEL_COUNT - 1];
380+
#endif
381+
}
382+
#endif
383+
367384
#if defined(CONFIG_SM_GNSS_OUTPUT_NMEA_ON_CMUX_CHANNEL)
368385
if (channel == CMUX_GNSS_CHANNEL) {
369386
/* The last DLCI. */

app/src/sm_cmux.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ enum cmux_channel {
2121
#if defined(CONFIG_SM_PPP)
2222
CMUX_PPP_CHANNEL,
2323
#endif
24+
#if defined(CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_CMUX)
25+
CMUX_COREDUMP_CHANNEL,
26+
#endif
2427
#if defined(CONFIG_SM_GNSS_OUTPUT_NMEA_ON_CMUX_CHANNEL)
2528
CMUX_GNSS_CHANNEL,
2629
#endif
2730
CMUX_EXT_CHANNEL_COUNT
2831
};
2932
struct modem_pipe *sm_cmux_reserve(enum cmux_channel);
3033
void sm_cmux_release(enum cmux_channel, bool fallback);
34+
bool sm_cmux_is_started(void);
3135

3236
#endif

app/src/sm_uart_handler.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ static inline void uart_callback_notify_pipe_transmit_idle(void)
296296
{
297297
#if SM_PIPE
298298
if (atomic_test_bit(&sm_pipe.state, SM_PIPE_STATE_OPEN_BIT)) {
299-
k_work_submit_to_queue(&sm_work_q, &sm_pipe.notify_transmit_idle);
299+
/* This is done in system work queue to avoid deadlock in modem crash. */
300+
k_work_submit(&sm_pipe.notify_transmit_idle);
300301
}
301302
#endif
302303
}
@@ -308,8 +309,10 @@ static inline void uart_callback_notify_pipe_closure(void)
308309
!atomic_test_bit(&sm_pipe.state, SM_PIPE_STATE_OPEN_BIT) &&
309310
!atomic_test_bit(&uart_state, SM_UART_STATE_RX_ENABLED_BIT) &&
310311
!atomic_test_bit(&uart_state, SM_UART_STATE_TX_ENABLED_BIT)) {
311-
/* Pipe is closed, RX and TX are idle, notify the closure */
312-
k_work_submit_to_queue(&sm_work_q, &sm_pipe.notify_closed);
312+
/* Pipe is closed, RX and TX are idle, notify the closure.
313+
* This is done in system work queue to avoid deadlock in modem crash.
314+
*/
315+
k_work_submit(&sm_pipe.notify_closed);
313316
}
314317
#endif
315318
}

drivers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
44

55
add_subdirectory_ifdef(CONFIG_DTR_UART dtr_uart)
6+
add_subdirectory_ifdef(CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_CMUX trace_backend_cmux)

drivers/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55

6+
if NRF_MODEM_LIB_TRACE
7+
8+
choice NRF_MODEM_LIB_TRACE_BACKEND
9+
10+
config NRF_MODEM_LIB_TRACE_BACKEND_CMUX
11+
bool "Stream modem coredump to CMUX"
12+
depends on SM_CMUX
13+
help
14+
Use CMUX trace backend for modem coredump.
15+
16+
endchoice # NRF_MODEM_LIB_TRACE_BACKEND
17+
18+
endif
19+
620
menu "Drivers"
721
rsource "dtr_uart/Kconfig"
822
endmenu
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
zephyr_library()
8+
zephyr_library_sources(cmux.c)

0 commit comments

Comments
 (0)