Skip to content

Commit a855855

Browse files
committed
applications: serial_lte_modem: Add Linux PPP+CMUX support
Add documentation, scripts and configuration overlay for using Serial LTE Modem as a modem for Linux device. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent 6994d9b commit a855855

File tree

6 files changed

+285
-1
lines changed

6 files changed

+285
-1
lines changed

applications/serial_lte_modem/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ config SLM_CMUX
185185
bool "CMUX support in SLM"
186186

187187
config SLM_CMUX_UART_BUFFER_SIZE
188-
int "UART Buffer size for CMUX"
188+
int "UART buffer size for CMUX"
189189
depends on SLM_CMUX
190190
default 6000
191191
help

applications/serial_lte_modem/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ See the subpages for how to use the application, how to extend it, and informati
1818

1919
doc/slm_description
2020
doc/nRF91_as_Zephyr_modem
21+
doc/PPP_linux
2122
doc/slm_testing
2223
doc/slm_extending
2324
doc/slm_data_mode
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
.. _slm_as_linux_modem:
2+
3+
nRF91 Series SiP as a modem for Linux device
4+
############################################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
Overview
11+
********
12+
13+
You can use the Serial LTE Modem (SLM) application to make an nRF91 Series SiP work as a standalone modem that can be used with a Linux device.
14+
The Linux device can use a standard PPP daemon and ldattach utility to connect to the cellular network through the nRF91 Series SiP.
15+
16+
The setup differentiates from a typical dial-up modem connection as the GSM 0710 multiplexer protocol (CMUX) is used to multiplex multiple data streams over a single serial port.
17+
This allows you to use the same serial port for both AT commands and PPP data.
18+
19+
Prerequisites
20+
=============
21+
22+
The Linux device needs to have the following packages installed:
23+
24+
* pppd from the ppp package
25+
* ldattach from the util-linux package
26+
27+
These should be available on all standard Linux distributions.
28+
29+
Configuration
30+
=============
31+
32+
To build the SLM application, use the :file:`overlay-ppp-cmux-linux.conf` configuration overlay.
33+
34+
You can adjust the serial port baud rate using the devicetree overlay file.
35+
By default, the baud rate is set to 115200.
36+
If you change the baud rate, set the same rate in the :file:`scripts/slm_start_ppp.sh` and :file:`scripts/slm_stop_ppp.sh` scripts.
37+
38+
Building and running
39+
====================
40+
41+
To build and program the SLM application to the nRF91 Series device, use the :file:`overlay-ppp-cmux-linux.conf` overlay file.
42+
43+
Managing the connection
44+
=======================
45+
46+
The start and stop scripts are provided in the :file:`scripts` directory of the SLM application.
47+
The scripts assume that the nRF91 Series SiP is connected to the Linux device using the `/dev/ttyACM0` serial port.
48+
49+
If needed, adjust the serial port settings in the scripts as follows:
50+
51+
.. code-block:: none
52+
53+
MODEM=/dev/ttyACM0
54+
BAUD=115200
55+
56+
To start the PPP connection, run the :file:`scripts/slm_start_ppp.sh` script.
57+
To stop the PPP connection, run the :file:`scripts/slm_stop_ppp.sh` script.
58+
59+
The scripts need superuser privileges to run, so use `sudo`.
60+
The PPP link is set as a default route if there is no existing default route.
61+
The scripts do not manage the DNS settings from the Linux system.
62+
Read the distribution manuals to learn how to configure the DNS settings.
63+
64+
The following example shows how to start the connection and verify its operation with various command-line utilities:
65+
66+
.. code-block:: shell
67+
68+
$ sudo scripts/slm_start_ppp.sh
69+
Wait modem to boot
70+
Attach CMUX channel to modem...
71+
Connect and wait for PPP link...
72+
send (AT+CFUN=1^M)
73+
expect (OK)
74+
75+
76+
OK
77+
-- got it
78+
79+
send ()
80+
expect (#XPPP: 1,0)
81+
82+
83+
84+
85+
#XPPP: 1,0
86+
-- got it
87+
88+
$ ip addr show ppp0
89+
7: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1464 qdisc fq_codel state UNKNOWN group default qlen 3
90+
link/ppp
91+
inet 10.139.130.66/32 scope global ppp0
92+
valid_lft forever preferred_lft forever
93+
inet6 2001:14bb:69b:50a3:ade3:2fce:6cc:ba3c/64 scope global temporary dynamic
94+
valid_lft 604720sec preferred_lft 85857sec
95+
inet6 2001:14bb:69b:50a3:40f9:1c4e:7231:638b/64 scope global dynamic mngtmpaddr
96+
valid_lft forever preferred_lft forever
97+
inet6 fe80::40f9:1c4e:7231:638b peer fe80::3c29:6401/128 scope link
98+
valid_lft forever preferred_lft forever
99+
100+
$ ping -I ppp0 8.8.8.8 -c5
101+
PING 8.8.8.8 (8.8.8.8) from 10.139.130.66 ppp0: 56(84) bytes of data.
102+
64 bytes from 8.8.8.8: icmp_seq=1 ttl=60 time=320 ms
103+
64 bytes from 8.8.8.8: icmp_seq=2 ttl=60 time=97.6 ms
104+
64 bytes from 8.8.8.8: icmp_seq=3 ttl=60 time=140 ms
105+
64 bytes from 8.8.8.8: icmp_seq=4 ttl=60 time=132 ms
106+
64 bytes from 8.8.8.8: icmp_seq=5 ttl=60 time=145 ms
107+
108+
--- 8.8.8.8 ping statistics ---
109+
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
110+
rtt min/avg/max/mdev = 97.610/166.802/319.778/78.251 ms
111+
112+
$ iperf3 -c ping.online.net%ppp0 -p 5202
113+
Connecting to host ping.online.net, port 5202
114+
[ 5] local 10.139.130.66 port 54244 connected to 51.158.1.21 port 5202
115+
[ ID] Interval Transfer Bitrate Retr Cwnd
116+
[ 5] 0.00-1.00 sec 0.00 Bytes 0.00 bits/sec 1 17.6 KBytes
117+
[ 5] 1.00-2.00 sec 0.00 Bytes 0.00 bits/sec 0 25.8 KBytes
118+
[ 5] 2.00-3.00 sec 0.00 Bytes 0.00 bits/sec 0 32.5 KBytes
119+
[ 5] 3.00-4.00 sec 128 KBytes 1.05 Mbits/sec 0 35.2 KBytes
120+
[ 5] 4.00-5.00 sec 0.00 Bytes 0.00 bits/sec 0 35.2 KBytes
121+
[ 5] 5.00-6.00 sec 0.00 Bytes 0.00 bits/sec 0 35.2 KBytes
122+
[ 5] 6.00-7.00 sec 0.00 Bytes 0.00 bits/sec 0 35.2 KBytes
123+
[ 5] 7.00-8.00 sec 0.00 Bytes 0.00 bits/sec 0 35.2 KBytes
124+
[ 5] 8.00-9.00 sec 0.00 Bytes 0.00 bits/sec 0 35.2 KBytes
125+
[ 5] 9.00-10.00 sec 0.00 Bytes 0.00 bits/sec 0 35.2 KBytes
126+
- - - - - - - - - - - - - - - - - - - - - - - - -
127+
[ ID] Interval Transfer Bitrate Retr
128+
[ 5] 0.00-10.00 sec 128 KBytes 105 Kbits/sec 1 sender
129+
[ 5] 0.00-11.58 sec 89.5 KBytes 63.3 Kbits/sec receiver
130+
131+
$ sudo scripts/slm_stop_ppp.sh
132+
send (AT+CFUN=0^M)
133+
expect (#XPPP: 0,0)
134+
135+
136+
OK
137+
138+
139+
140+
#XPPP: 0,0
141+
-- got it
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_SLM_SKIP_READY_MSG=y
8+
CONFIG_SLM_CMUX=y
9+
CONFIG_SLM_PPP=y
10+
CONFIG_SLM_CR_TERMINATION=y
11+
12+
# Assume at least baudrate 115200 for UART
13+
# so CMUX frame can be received in 12 ms (134*10/115200)
14+
CONFIG_MODEM_BACKEND_UART_ASYNC_RECEIVE_IDLE_TIMEOUT_MS=12
15+
CONFIG_MODEM_CMUX_MTU=127
16+
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE=536
17+
CONFIG_SLM_CMUX_UART_BUFFER_SIZE=6000
18+
# For sending full 6000 bytes at 115200 baudrate
19+
# 6000 * 10 / 115200 = 521 ms
20+
CONFIG_MODEM_BACKEND_UART_ASYNC_TRANSMIT_TIMEOUT_MS=521
21+
22+
# These buffers are unused after AT#CMUX is enabled
23+
# so use minimal buffer size
24+
CONFIG_SLM_UART_RX_BUF_COUNT=3
25+
CONFIG_SLM_UART_RX_BUF_SIZE=128
26+
CONFIG_SLM_UART_TX_BUF_SIZE=128
27+
28+
# When using PPP, disable commands of IP-based protocols to save flash space.
29+
CONFIG_SLM_FTPC=n
30+
CONFIG_SLM_TFTPC=n
31+
CONFIG_SLM_HTTPC=n
32+
CONFIG_SLM_MQTTC=n
33+
34+
# nRF Connect SDK modules
35+
CONFIG_PDN=y
36+
CONFIG_AT_CMD_CUSTOM=y
37+
CONFIG_NRF_MODEM_LIB_SHMEM_TX_SIZE=22528
38+
39+
# Zephyr modules
40+
CONFIG_NET_NATIVE=y
41+
CONFIG_NET_L2_PPP=y
42+
CONFIG_MODEM_MODULES=y
43+
CONFIG_MODEM_CMUX=y
44+
CONFIG_MODEM_PPP=y
45+
CONFIG_MODEM_BACKEND_UART=y
46+
47+
# L2 protocol
48+
CONFIG_NET_L2_PPP_MGMT=y
49+
CONFIG_NET_L2_PPP_OPTION_MRU=y
50+
CONFIG_NET_L2_PPP_OPTION_SERVE_IP=y
51+
CONFIG_NET_L2_PPP_OPTION_SERVE_DNS=y
52+
CONFIG_NET_L2_PPP_TIMEOUT=5000
53+
54+
# IP stack
55+
CONFIG_NET_IP_ADDR_CHECK=n
56+
CONFIG_NET_SOCKETS_PACKET=y
57+
58+
# network buffering
59+
CONFIG_NET_BUF=y
60+
CONFIG_NET_BUF_POOL_USAGE=y
61+
CONFIG_NET_PKT_RX_COUNT=44
62+
CONFIG_NET_BUF_RX_COUNT=88
63+
CONFIG_NET_PKT_TX_COUNT=44
64+
CONFIG_NET_BUF_TX_COUNT=88
65+
CONFIG_NET_TC_RX_COUNT=0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash -eu
2+
#
3+
# Copyright (c) 2025 Nordic Semiconductor ASA
4+
#
5+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6+
7+
#
8+
# Script to start PPP link inside CMUX channel
9+
# using Serial LTE Modem
10+
#
11+
12+
MODEM=/dev/ttyACM0
13+
BAUD=115200
14+
PPP_CMUX=/dev/gsmtty2
15+
AT_CMUX=/dev/gsmtty1
16+
CHATOPT="-vs"
17+
18+
cleanup() {
19+
set +eu
20+
pkill pppd
21+
pkill ldattach
22+
echo "Failed to start..."
23+
exit 1
24+
}
25+
trap cleanup ERR
26+
27+
if [[ ! -c $MODEM ]]; then
28+
echo "Serial port not found: $MODEM"
29+
exit 1
30+
fi
31+
32+
stty -F $MODEM $BAUD pass8 raw crtscts clocal
33+
34+
echo "Wait modem to boot"
35+
chat -t5 "" "AT" "OK" <$MODEM >$MODEM || true
36+
37+
echo "Attach CMUX channel to modem..."
38+
ldattach -c $'AT#XCMUX=1\r' GSM0710 $MODEM
39+
40+
sleep 1
41+
stty -F $AT_CMUX clocal
42+
43+
echo "Connect and wait for PPP link..."
44+
test -c $AT_CMUX
45+
chat $CHATOPT -t60 "" "AT+CFUN=1" "OK" "\c" "#XPPP: 1,0" >$AT_CMUX <$AT_CMUX
46+
47+
pppd $PPP_CMUX noauth novj nodeflate nobsdcomp debug noipdefault passive +ipv6 \
48+
noremoteip local linkname nrf91 defaultroute defaultroute-metric -1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash -u
2+
#
3+
# Copyright (c) 2025 Nordic Semiconductor ASA
4+
#
5+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6+
7+
#
8+
# Script to stop PPP link inside CMUX channel
9+
# using Serial LTE Modem
10+
#
11+
12+
MODEM=/dev/ttyACM0
13+
BAUD=115200
14+
PPP_CMUX=/dev/gsmtty2
15+
AT_CMUX=/dev/gsmtty1
16+
CHATOPT="-vs"
17+
18+
if [[ ! -c $AT_CMUX ]]; then
19+
echo "AT CMUX channel not found: $AT_CMUX"
20+
pkill pppd
21+
pkill ldattach
22+
exit 1
23+
fi
24+
25+
chat $CHATOPT -t30 "" "AT+CFUN=0" "#XPPP: 0,0" >$AT_CMUX <$AT_CMUX
26+
27+
sleep 1
28+
test -f /var/run/ppp-nrf91.pid && kill $(head -1 </var/run/ppp-nrf91.pid)
29+
pkill ldattach

0 commit comments

Comments
 (0)