From 3f59cd75e9349c76ac05181f0b7bcb433dcd2412 Mon Sep 17 00:00:00 2001 From: Markus Lassila Date: Mon, 7 Jul 2025 13:10:33 +0300 Subject: [PATCH] applications: serial_lte_modem: Use downstream UART backend Use downstream UART backend, which is optimized for use with SLM. Signed-off-by: Markus Lassila --- applications/serial_lte_modem/overlay-cmux.conf | 8 ++++++-- .../serial_lte_modem/overlay-ppp-cmux-linux.conf | 16 ++++++++++------ applications/serial_lte_modem/overlay-ppp.conf | 9 ++++++--- applications/serial_lte_modem/src/slm_cmux.c | 9 +++++---- applications/serial_lte_modem/src/slm_ppp.c | 8 ++++---- west.yml | 2 +- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/applications/serial_lte_modem/overlay-cmux.conf b/applications/serial_lte_modem/overlay-cmux.conf index 258277b8a728..d2f4bd4e03e8 100644 --- a/applications/serial_lte_modem/overlay-cmux.conf +++ b/applications/serial_lte_modem/overlay-cmux.conf @@ -10,8 +10,12 @@ CONFIG_SLM_SKIP_READY_MSG=y # Zephyr modem subsystem CONFIG_MODEM_MODULES=y CONFIG_MODEM_CMUX=y -CONFIG_MODEM_BACKEND_UART=y -CONFIG_MODEM_BACKEND_UART_ASYNC_TRANSMIT_TIMEOUT_MS=1000 + +# Enable SLM UART backend +CONFIG_MODEM_BACKEND_UART=n +CONFIG_MODEM_BACKEND_UART_ASYNC=n +CONFIG_MODEM_BACKEND_UART_SLM=y +CONFIG_MODEM_BACKEND_UART_SLM_TRANSMIT_TIMEOUT_MS=1000 # debug options #CONFIG_MODEM_CMUX_LOG_LEVEL_DBG=y diff --git a/applications/serial_lte_modem/overlay-ppp-cmux-linux.conf b/applications/serial_lte_modem/overlay-ppp-cmux-linux.conf index bbae28e93c89..676b1d9d3d9d 100644 --- a/applications/serial_lte_modem/overlay-ppp-cmux-linux.conf +++ b/applications/serial_lte_modem/overlay-ppp-cmux-linux.conf @@ -9,16 +9,21 @@ CONFIG_SLM_CMUX=y CONFIG_SLM_PPP=y CONFIG_SLM_CR_TERMINATION=y -# Assume at least baudrate 115200 for UART -# so CMUX frame can be received in 12 ms (134*10/115200) -CONFIG_MODEM_BACKEND_UART_ASYNC_RECEIVE_IDLE_TIMEOUT_MS=12 CONFIG_MODEM_CMUX_MTU=127 CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE=536 CONFIG_SLM_CMUX_UART_BUFFER_SIZE=6000 + +# Enable SLM UART backend +CONFIG_MODEM_BACKEND_UART=n +CONFIG_MODEM_BACKEND_UART_ASYNC=n +CONFIG_MODEM_BACKEND_UART_SLM=y + # For sending full 6000 bytes at 115200 baudrate # 6000 * 10 / 115200 = 521 ms -CONFIG_MODEM_BACKEND_UART_ASYNC_TRANSMIT_TIMEOUT_MS=521 -CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC=y +CONFIG_MODEM_BACKEND_UART_SLM_TRANSMIT_TIMEOUT_MS=521 +# Assume at least baudrate 115200 for UART +# so CMUX frame can be received in 12 ms (134*10/115200) +CONFIG_MODEM_BACKEND_UART_SLM_RECEIVE_IDLE_TIMEOUT_MS=12 # These buffers are unused after AT#CMUX is enabled # so use minimal buffer size @@ -43,7 +48,6 @@ CONFIG_NET_L2_PPP=y CONFIG_MODEM_MODULES=y CONFIG_MODEM_CMUX=y CONFIG_MODEM_PPP=y -CONFIG_MODEM_BACKEND_UART=y # L2 protocol CONFIG_NET_L2_PPP_MGMT=y diff --git a/applications/serial_lte_modem/overlay-ppp.conf b/applications/serial_lte_modem/overlay-ppp.conf index 8e01582a2228..81a72f2a7e99 100644 --- a/applications/serial_lte_modem/overlay-ppp.conf +++ b/applications/serial_lte_modem/overlay-ppp.conf @@ -23,9 +23,12 @@ CONFIG_NET_NATIVE=y CONFIG_NET_L2_PPP=y CONFIG_MODEM_MODULES=y CONFIG_MODEM_PPP=y -CONFIG_MODEM_BACKEND_UART=y -CONFIG_MODEM_BACKEND_UART_ASYNC_TRANSMIT_TIMEOUT_MS=1000 -CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC=y + +# Enable SLM UART backend +CONFIG_MODEM_BACKEND_UART=n +CONFIG_MODEM_BACKEND_UART_ASYNC=n +CONFIG_MODEM_BACKEND_UART_SLM=y +CONFIG_MODEM_BACKEND_UART_SLM_TRANSMIT_TIMEOUT_MS=1000 # L2 protocol CONFIG_NET_L2_PPP_MGMT=y diff --git a/applications/serial_lte_modem/src/slm_cmux.c b/applications/serial_lte_modem/src/slm_cmux.c index 142b8965f04b..781662b8d18b 100644 --- a/applications/serial_lte_modem/src/slm_cmux.c +++ b/applications/serial_lte_modem/src/slm_cmux.c @@ -10,7 +10,7 @@ #endif #include "slm_util.h" #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ static struct { /* UART backend */ struct modem_pipe *uart_pipe; bool uart_pipe_open; - struct modem_backend_uart uart_backend; + struct modem_backend_uart_slm uart_backend; uint8_t uart_backend_receive_buf[CONFIG_SLM_CMUX_UART_BUFFER_SIZE] __aligned(sizeof(void *)); uint8_t uart_backend_transmit_buf[CONFIG_SLM_CMUX_UART_BUFFER_SIZE]; @@ -348,7 +348,7 @@ static int cmux_start(void) } { - const struct modem_backend_uart_config uart_backend_config = { + const struct modem_backend_uart_slm_config uart_backend_config = { .uart = DEVICE_DT_GET(DT_CHOSEN(ncs_slm_uart)), .receive_buf = cmux.uart_backend_receive_buf, .receive_buf_size = sizeof(cmux.uart_backend_receive_buf), @@ -356,7 +356,8 @@ static int cmux_start(void) .transmit_buf_size = sizeof(cmux.uart_backend_transmit_buf), }; - cmux.uart_pipe = modem_backend_uart_init(&cmux.uart_backend, &uart_backend_config); + cmux.uart_pipe = + modem_backend_uart_slm_init(&cmux.uart_backend, &uart_backend_config); if (!cmux.uart_pipe) { return -ENODEV; } diff --git a/applications/serial_lte_modem/src/slm_ppp.c b/applications/serial_lte_modem/src/slm_ppp.c index 5e8dcb4d338b..2c9628650b35 100644 --- a/applications/serial_lte_modem/src/slm_ppp.c +++ b/applications/serial_lte_modem/src/slm_ppp.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -594,12 +594,12 @@ int slm_ppp_init(void) } { - static struct modem_backend_uart ppp_uart_backend; + static struct modem_backend_uart_slm ppp_uart_backend; static uint8_t ppp_uart_backend_receive_buf[sizeof(ppp_data_buf)] __aligned(sizeof(void *)); static uint8_t ppp_uart_backend_transmit_buf[sizeof(ppp_data_buf)]; - const struct modem_backend_uart_config uart_backend_config = { + const struct modem_backend_uart_slm_config uart_backend_config = { .uart = ppp_uart_dev, .receive_buf = ppp_uart_backend_receive_buf, .receive_buf_size = sizeof(ppp_uart_backend_receive_buf), @@ -607,7 +607,7 @@ int slm_ppp_init(void) .transmit_buf_size = sizeof(ppp_uart_backend_transmit_buf), }; - ppp_pipe = modem_backend_uart_init(&ppp_uart_backend, &uart_backend_config); + ppp_pipe = modem_backend_uart_slm_init(&ppp_uart_backend, &uart_backend_config); if (!ppp_pipe) { return -ENOSYS; } diff --git a/west.yml b/west.yml index 42ec0ad72d7d..1293b920f48a 100644 --- a/west.yml +++ b/west.yml @@ -65,7 +65,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: 926fafbe9f0745eb3c3f0b37e8bfa9c0afc1db13 + revision: 964736df4b123d94117477fd05337f999b025026 import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above