From 7f9ed8695c25c3afefe19b27d6bb1344bbb88efb Mon Sep 17 00:00:00 2001 From: Tomi Fontanilles Date: Thu, 22 Feb 2024 14:54:45 +0200 Subject: [PATCH] samples: net: cellular_modem: add nRF9160 DK's nRF52840 The added configuration files allow the sample to be run on the nRF52840 present on the nRF9160 DK with the nRF9160 (running SLM) being the modem and communication happening through pins that are routed internally between the two. Signed-off-by: Tomi Fontanilles --- .../boards/nrf9160dk_nrf52840.conf | 13 +++++++++++++ .../boards/nrf9160dk_nrf52840.overlay | 18 ++++++++++++++++++ .../modem/backends/modem_backend_uart_async.c | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 samples/net/cellular_modem/boards/nrf9160dk_nrf52840.conf create mode 100644 samples/net/cellular_modem/boards/nrf9160dk_nrf52840.overlay diff --git a/samples/net/cellular_modem/boards/nrf9160dk_nrf52840.conf b/samples/net/cellular_modem/boards/nrf9160dk_nrf52840.conf new file mode 100644 index 00000000000..2af3b6d2a41 --- /dev/null +++ b/samples/net/cellular_modem/boards/nrf9160dk_nrf52840.conf @@ -0,0 +1,13 @@ +CONFIG_UART_ASYNC_API=y + +# Align with the Serial LTE Modem (SLM) application. +CONFIG_MODEM_CELLULAR_CMUX_MAX_FRAME_SIZE=1500 +CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES=1500 + +# Allow large UART TXs to go through @115200. +CONFIG_MODEM_BACKEND_UART_ASYNC_TRANSMIT_TIMEOUT_MS=200 + +# Print logs and printk() output on uart0. +CONFIG_LOG=y +CONFIG_LOG_BACKEND_UART=y +CONFIG_MODEM_LOG_LEVEL_DBG=y diff --git a/samples/net/cellular_modem/boards/nrf9160dk_nrf52840.overlay b/samples/net/cellular_modem/boards/nrf9160dk_nrf52840.overlay new file mode 100644 index 00000000000..c639ec8b305 --- /dev/null +++ b/samples/net/cellular_modem/boards/nrf9160dk_nrf52840.overlay @@ -0,0 +1,18 @@ +#include + +/ { + aliases { + modem = &modem; + }; +}; + +&uart1 { + current-speed = <115200>; + hw-flow-control; + + modem: modem { + compatible = "nordic,nrf91-slm"; + status = "okay"; + mdm-power-gpios = <&interface_to_nrf9160 4 GPIO_ACTIVE_LOW>; + }; +}; diff --git a/subsys/modem/backends/modem_backend_uart_async.c b/subsys/modem/backends/modem_backend_uart_async.c index 0fa3684780e..9c06885aec1 100644 --- a/subsys/modem/backends/modem_backend_uart_async.c +++ b/subsys/modem/backends/modem_backend_uart_async.c @@ -114,7 +114,7 @@ static void modem_backend_uart_async_event_handler(const struct device *dev, if (received < evt->data.rx.len) { ring_buf_reset(&backend->async.receive_rb); k_spin_unlock(&backend->async.receive_rb_lock, key); - LOG_WRN("Receive buffer overrun (%u/%u dropped)", + LOG_WRN("Receive buffer overrun (%zu/%zu dropped)", evt->data.rx.len - received, evt->data.rx.len); break; }