Skip to content

Commit 7d0a506

Browse files
committed
doc: Refactor PPP documentation to use standard commands
Refactor PPP related documentation to use standard AT+CMUX and AT+CGDATA commands. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent ec2fe6e commit 7d0a506

7 files changed

Lines changed: 1100 additions & 610 deletions

File tree

doc/app/at_cmux.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ Example
122122
CMUX setup #XCMUX
123123
=================
124124

125+
.. note::
126+
127+
``AT#XCMUX`` is a compatibility command for Serial Modem v1.x.x and is not recommended for new designs.
128+
Use the standard ``AT+CMUX=0`` command instead.
129+
125130
The ``#XCMUX`` command manages the configuration of CMUX over the serial link.
126131

127132
Set command
@@ -156,10 +161,10 @@ This means that after successfully running this command, you must set up the CMU
156161
The AT channel will be available at the configured address.
157162
You can send an empty ``AT`` command to make sure that the protocol is set up properly.
158163

159-
.. note::
164+
.. caution::
160165

161-
This command can be run when CMUX is already running to change the address of the AT channel.
162-
However, this is not allowed when PPP is running.
166+
Using ``AT#XCMUX`` to switch the AT command channel at runtime is error-prone and not recommended.
167+
The channel switching might run out of sync with automatic PPP startup and recovery enabled by ``AT#XPPP=1``.
163168

164169
Read command
165170
------------

doc/app/at_ppp.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ Example
9595
Control PPP #XPPP
9696
=================
9797

98+
.. note::
99+
100+
``AT#XPPP`` is a compatibility command for Serial Modem v1.x.x and is not recommended for new designs.
101+
It depends on the channel assignment configured by the ``AT#XCMUX`` command.
102+
Use the standard ``AT+CGDATA`` command instead.
103+
98104
Set command
99105
-----------
100106

@@ -312,7 +318,7 @@ For the process described here, |SM|'s UARTs must be connected to the Linux host
312318

313319
.. code-block:: console
314320
315-
$ sudo pppd noauth <UART_dev> <baud_rate> local crtscts debug noipdefault connect "/usr/sbin/chat -v -t60 '' AT+CFUN=1 OK AT#XPPP=1 '#XPPP: 1,'" disconnect "/usr/sbin/chat -v -t10 '' AT+CFUN=0 OK" nodetach
321+
$ sudo pppd noauth <UART_dev> <baud_rate> local crtscts debug noipdefault connect "/usr/sbin/chat -v -t60 '' AT+CFUN=1 OK AT+CGDATA CONNECT" nodetach
316322
317323
Replace ``<UART_dev>`` by the device file assigned to the Serial Modem's UART and ``<baud_rate>`` by the baud rate of the UART.
318324
Typically, the device file assigned to it is :file:`/dev/ttyACM0` for an nRF9151 DK.

doc/app/sm_cellular_modem.rst

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PPP and CMUX
2929
:alt: CMUX multiplexes AT and PPP over one UART.
3030
:align: center
3131

32-
CMUX multiplexes AT (DLC1) and PPP (DLC2) over one UART.
32+
CMUX multiplexes AT and PPP over one UART using separate DLC channels.
3333

3434
|SM| supports PPP both with or without CMUX (GSM 07.10 multiplexing).
3535
This allows you to choose the setup that best fits your use case.
@@ -39,38 +39,47 @@ PPP without CMUX
3939
================
4040

4141
Without CMUX, PPP runs on the current UART.
42-
Once PPP starts, the UART is in PPP data mode and cannot be used for AT commands until PPP is terminated.
43-
This also means that no more AT notifications are delivered over that UART while PPP is active.
42+
Send ``AT+CFUN=1`` to activate the modem, then ``AT+CGDATA`` to start PPP.
43+
The modem responds with ``CONNECT`` and the UART immediately enters PPP data mode.
44+
You cannot use the UART for AT commands until PPP is terminated by LCP negotiation.
45+
No AT notifications are delivered over the UART while PPP is active.
4446

4547
Example
4648
-------
4749

4850
Switching UART from AT mode to PPP mode and back:
4951

5052
.. figure:: ../images/ppp-uart-sequence.svg
51-
:alt: PPP session without CMUX.
53+
:alt: PPP session without CMUX using AT+CGDATA.
5254
:align: center
5355

5456
PPP session without CMUX.
5557

58+
.. _ppp_with_cmux:
59+
5660
PPP with CMUX
5761
=============
5862

5963
With CMUX, AT traffic and PPP traffic can share a single UART by using separate CMUX channels.
6064

61-
By default, |SM| uses the AT channel on DLC channel 1 and PPP on DLC channel 2.
62-
If you want PPP on DLC channel 1, start CMUX with ``AT#XCMUX=2`` before starting PPP. This moves the AT-channel to DLC channel 2.
65+
Start CMUX with ``AT+CMUX=0``, then issue ``AT+CGDATA`` on the chosen DLC channel to start PPP on that channel.
66+
The following example uses DLC channel 1 for PPP and DLC channel 2 for AT commands, with ``AT#XCMUXURC=2`` directing URCs to DLC channel 2.
6367

6468
Example
6569
-------
6670

67-
Start CMUX, then start PPP on DLC channel 2 while keeping AT on DLC channel 1:
71+
Send ``AT#XCMUXURC=2`` to route URCs to DLC channel 2, start CMUX with ``AT+CMUX=0``, then start PPP on DLC channel 1 using ``AT+CGDATA``:
6872

6973
.. figure:: ../images/ppp-cmux-sequence.svg
70-
:alt: PPP session with CMUX showing split into DLC1 (AT) and DLC2 (PPP).
74+
:alt: PPP session with CMUX showing DLC1 (PPP) and DLC2 (AT), with URCs routed to DLC2.
7175
:align: center
7276

73-
PPP session with CMUX.
77+
PPP on DLC1, AT commands and URCs on DLC2.
78+
79+
.. note::
80+
81+
The ``AT#XCMUXURC=2`` is optional, but it is recommended to route URCs to a static channel.
82+
When the URC channel is not selected, URCs are sent to the first open AT channel, which is not in data mode.
7483

7584

7685
Use case: Linux host
@@ -109,15 +118,16 @@ Option A: PPP over CMUX (recommended)
109118
=====================================
110119

111120
|SM| provides start and stop scripts for Linux in the application's :file:`scripts` directory.
121+
The :file:`sm2_start_ppp.sh` script uses standard 3GPP AT commands (``AT+CMUX`` and ``AT+CGDATA``) and is the recommended way to establish a PPP connection over CMUX.
112122
If needed, adjust the serial port settings with command line parameters.
113-
Run ``sm_start_ppp.sh -h`` to see all available options.
123+
Run ``sm2_start_ppp.sh -h`` to see all available options.
114124
Default settings assume that the modem is available at ``/dev/ttyACM0`` with a baud rate of ``115200``.
115125

116126
1. Start the connection (requires superuser privileges for PPPD and CMUX):
117127

118128
.. code-block:: shell
119129
120-
$ sudo scripts/sm_start_ppp.sh [-s serial_port] [-b baud_rate] [-t timeout]
130+
$ sudo scripts/sm2_start_ppp.sh [-s serial_port] [-b baud_rate] [-t timeout]
121131
122132
#. Verify that the PPP interface is up (for example, with ``ip addr show ppp0``) and test connectivity.
123133

@@ -156,7 +166,7 @@ This setup is useful for quick testing, but the UART cannot be used for AT comma
156166

157167
.. code-block:: console
158168
159-
$ sudo pppd noauth <UART_dev> <baud_rate> local crtscts debug noipdefault connect "/usr/sbin/chat -v -t60 '' AT+CFUN=1 OK AT#XPPP=1 '#XPPP: 1,'" disconnect "/usr/sbin/chat -v -t10 '' AT+CFUN=0 OK" nodetach
169+
$ sudo pppd noauth <UART_dev> <baud_rate> local crtscts debug noipdefault connect "/usr/sbin/chat -v -t60 '' AT+CFUN=1 OK AT+CGDATA CONNECT" nodetach
160170
161171
Replace ``<UART_dev>`` by the device file assigned to the Serial Modem's UART and ``<baud_rate>`` by the baud rate of the UART.
162172
Typically, the device file assigned to it is :file:`/dev/ttyACM0` for an nRF9151 DK.
@@ -176,8 +186,8 @@ This setup is useful for quick testing, but the UART cannot be used for AT comma
176186

177187
#. Terminate the PPP connection with CTRL+C in the terminal where ``pppd`` is running or ``sudo poff`` in another terminal.
178188

179-
Use case: Zephyr host (Zephyr-compatible modem)
180-
***********************************************
189+
Use case: Zephyr host
190+
*********************
181191

182192
This section describes how to use |SM| as a modem that is controlled by Zephyr's cellular modem driver.
183193
The controlling chip runs a Zephyr application, which uses Zephyr's native IP stack.
@@ -192,19 +202,18 @@ The controlling chip runs a Zephyr application, which uses Zephyr's native IP st
192202
* Power saving feature requires UART with DTR and RI pins connected between the controlling chip and the SiP.
193203
See :ref:`uart_configuration` for more information.
194204
* System mode is not configured. See the `%XSYSTEMMODE`_ command in the AT command Reference Guide for more details.
195-
* The Zephyr cellular modem driver is written with the expectation that the PPP session starts on the DLC channel used for AT commands, which is DLC channel 1 by default.
196205

197206
Example
198207
=======
199208

200-
The Zephyr modem driver requires the AT channel and PPP channel to be switched so that the PPP starts at DLC channel 1, while the AT channel is moved to DLC channel 2.
201-
This is achieved by starting CMUX with ``AT#XCMUX=2`` before the network is attached and starting the PPP.
209+
The Zephyr modem driver sends ``AT+CMUX=0`` to start the CMUX, then uses DLC channel 1 for AT commands and DLC channel 2 for PPP.
210+
The dial script issues ``AT+CGDATA`` on DLC channel 2, which starts PPP on that channel and leaves DLC channel 1 free for AT commands and URCs.
202211

203212
.. figure:: ../images/ppp-zephyr-sequence.svg
204-
:alt: PPP session with CMUX showing Zephyr host control.
213+
:alt: PPP session with CMUX using standard AT+CMUX and AT+CGDATA commands from a Zephyr host.
205214
:align: center
206215

207-
The Zephyr modem driver does extra DLC channel switching when starting the PPP session.
216+
Zephyr modem driver uses DLC1 as the AT command channel and starts PPP on DLC2 using AT+CGDATA.
208217

209218
Configuration
210219
=============
@@ -231,6 +240,28 @@ In particular:
231240
* :file:`boards/nrf54l15dk_nrf54l15_cpuapp.overlay` - Configure UART (pins, baud rate), DTR and RI pins used between the MCU and the SiP.
232241

233242
Depending on your hardware, a devicetree overlay is needed to describe the modem UART and power control pins.
243+
The modem node in the overlay must use ``compatible = "nordic,nrf91-sm-v2"`` to select the |SM| modem driver:
244+
245+
.. code-block:: devicetree
246+
247+
&uart0 {
248+
status = "okay";
249+
current-speed = <115200>;
250+
hw-flow-control;
251+
252+
modem: modem {
253+
compatible = "nordic,nrf91-sm-v2";
254+
status = "okay";
255+
mdm-ring-gpios = <&gpio0 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
256+
mdm-dtr-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
257+
cmux-enable-runtime-power-save;
258+
cmux-close-pipe-on-power-save;
259+
cmux-idle-timeout-ms = <5000>;
260+
autostarts;
261+
};
262+
};
263+
264+
The ``nordic,nrf91-sm-v2`` binding is compatible with |SM| application v2.0.0 and later.
234265
Devicetree settings also control the CMUX power-saving behavior.
235266

236267
Flashing and running
@@ -241,9 +272,10 @@ When the Zephyr's modem driver starts up, it will perform the following steps:
241272

242273
* Enable the UART interface.
243274
* Enable notifications and query modem information.
244-
* Enable CMUX.
275+
* Configure URCs to DLC channel 1 with ``AT#XCMUXURC=1``.
276+
* Enable CMUX with ``AT+CMUX=0``.
245277
* Set the modem to normal mode with ``AT+CFUN=1``.
246-
* Start PPP.
278+
* Start PPP on DLC channel 2 with ``AT+CGDATA``.
247279

248280
The Zephyr host can then use standard Zephyr networking APIs to use the PPP link for network communication.
249281
Only exception for normal network interfaces is that the PPP interface cannot be automatically started at boot.
@@ -254,23 +286,29 @@ You must start the PPP interface manually when required.
254286
struct net_if *ppp_iface = net_if_get_default();
255287
net_if_up(ppp_iface);
256288
289+
Using legacy nrf91-slm Zephyr driver
290+
====================================
291+
292+
Zephyr provides an older upstream cellular modem driver that uses ``compatible = "nordic,nrf91-slm"``.
293+
It was developed for the Serial LTE Modem (SLM) sample application and is not recommended for new designs.
294+
295+
Unlike the ``nordic,nrf91-sm-v2`` driver, the legacy ``nrf91-slm`` driver uses the proprietary ``AT#XCMUX=2`` command to switch the AT command channel to DLC channel 2 at runtime and ``AT#XPPP=1`` to allow PPP to start automatically on the secondary DLC channel.
296+
This approach is unreliable in various recovery scenarios, because PPP startup and AT channel switching might run out of sync, leading to a loss of AT control.
297+
298+
.. figure:: ../images/ppp-zephyr-sequence-legacy.svg
299+
:alt: Legacy PPP session with CMUX using AT#XCMUX=1 and AT#XCMUX=2 commands from a Zephyr host.
300+
:align: center
301+
302+
Legacy ``nrf91-slm`` driver starts CMUX using ``AT#XCMUX=1``, then uses ``AT#XCMUX=2`` to switch the AT channel to DLC2 and starts PPP on DLC1.
303+
257304
Operational notes
258305
*****************
259306

260307
* nRF91 Series SiP automatically activates the default PDP context.
261308
Manually configuring the APN is typically not required.
262309

263310
* nRF91 Series SiP automatically restarts a network scan when connectivity is lost.
264-
Manual dial-up scripts are typically not required for recovery.
265-
266-
* |SM| uses only one AT channel.
267-
Therefore, the controlling chip must use only one CMUX channel for AT commands and notifications.
268-
269-
* CMUX channel allocation (by default, allocating DLC channel 1 to PPP and DLC channel 2 to AT) is controlled by ``AT#XCMUX``.
270-
See :ref:`SM_AT_CMUX` for details.
271-
272-
* PPP link start/stop behavior and recovery from network loss depend on how PPP is configured and which CMUX channel is used.
273-
See :ref:`SM_AT_PPP` for the ``#XPPP`` status notification format and PPP termination behavior.
311+
Manual dial-up scripts are typically not required for LTE connection recovery.
274312

275-
* You might encounter a packet domain event (``+CGEV: IPV6 FAIL 0``) indicating a failure in obtaining an IPv6 address.
276-
You can ignore this since not all carriers provide IPv6 address for default PDN.
313+
* When you use the proprietary ``AT#XCMUX=1`` and ``AT#XPPP=1`` commands, CMUX channel allocation is static (by default, allocating DLC channel 1 to PPP and DLC channel 2 to AT).
314+
See :ref:`SM_AT_CMUX` and :ref:`SM_AT_PPP` for details.

0 commit comments

Comments
 (0)