Skip to content

Fetch cellular modem fixes from upstream#4072

Merged
rlubos merged 30 commits into
nrfconnect:mainfrom
SeppoTakalo:modem_fixes_from_upstream
May 21, 2026
Merged

Fetch cellular modem fixes from upstream#4072
rlubos merged 30 commits into
nrfconnect:mainfrom
SeppoTakalo:modem_fixes_from_upstream

Conversation

@SeppoTakalo
Copy link
Copy Markdown
Contributor

@SeppoTakalo SeppoTakalo commented May 12, 2026

This PR contains fixes from Zephyr main and two PRs that are still open:

I'll mark this as Do-not-merge until these are properly tested with nRF91 Serial Modem application.

@SeppoTakalo SeppoTakalo added this to the ncs-3.4.0 milestone May 12, 2026
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from 8a2ec27 to f318e73 Compare May 12, 2026 14:51
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 12, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from f318e73 to ff5074e Compare May 13, 2026 11:59
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 13, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from ff5074e to ee243ca Compare May 15, 2026 07:51
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 15, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from ee243ca to 61aca7f Compare May 18, 2026 12:11
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 18, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from 61aca7f to c3bf6c1 Compare May 19, 2026 08:24
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 19, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@SeppoTakalo SeppoTakalo removed the DNM label May 19, 2026
@SeppoTakalo
Copy link
Copy Markdown
Contributor Author

SeppoTakalo commented May 19, 2026

This is now rebased on top of main, and I have conducted manual testing against Serial Modem application and its samples.

From my point of view, this is OK to go in. Last PR that is still open, already have one approval and no change requests.

Removed the DNM label.

@rlubos
Copy link
Copy Markdown
Contributor

rlubos commented May 19, 2026

@SeppoTakalo Add 3.4 milestone, backwards-compatible label, and chase @shanthanordic for approval, won't be able to merge otherwise.

Copy link
Copy Markdown

@shanthanordic shanthanordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved scope

@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from c3bf6c1 to 686957a Compare May 20, 2026 13:15
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 20, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from 686957a to 9d1c200 Compare May 21, 2026 07:16
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 21, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
The driver transitions to this state upon registering to the LTE
network, not upon the internal Zephyr concept of `carrier_on`.
`carrier_on` is an internal (and incorrect) consequence of transitioning
to the registered state, and should not be the basis of the name.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 0a2ee3c)
The name of this state is misleading as it is the same as the internal
Zephyr networking interface state of dormant. Rename the state to match
what it is doing, in the same way other states are named.

The misapplication of the interface `dormant` state by `AWAIT_PPP_DEAD`
is fixed later.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 77bb728)
SeppoTakalo and others added 22 commits May 21, 2026 10:22
When PPP is terminated, add small delay before attempting
to run AT commands to restart the PPP.

Assume same delay is OK as switching from CMUX to plain AT
mode.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit 8ccc3c1)
When the CMUX control channel is closed, CMUX is shut down and
all pipes should be in closed state too.
Notify all modules of this by calling modem_cmux_dlci_pipes_release()
when disconnecting.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit 662f838)
…is open

If CMUX is not yet connected, or is doing a disconnection,
we should not accept any traffic into pipes.

Block the traffic by replacing the !cmux->attached test with
a runtime test is_connected() that compare states as well.

Rename previous is_connected() to is_active() as it was used
on runtime power management checks.

One exception to rule is pipe->open(), which should be allowed
to be called same time as CMUX connection is initiated.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit eecb164)
Reset the receive frame state on pipe attach, and re-attach the pipe
before each PPP test to ensure a clean state.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit c00c3a1)
DTE's can unconditionally emit a `NO CARRIER` event on the DLCI which
indicates that the channel has moved back into the command state. This
functionally means the PPP link is dead, as no more valid data will ever
be received on the channel.

Add the logic to detect this event in `modem_ppp`.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit f97bb71)
Instead of switching the DLCI channel used for AT commands from DLCI1 to
DLCI2 halfway through the setup process, always use DLCI1. For PPP, use
the clean DLCI2 channel. The only "command" sent on the DLCI2 channel
before handing over to the PPP module is the dial script.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 97c713c)
…D for nRF9160 SLM

The nRF9160 SLM init script does not query IMSI or ICCID. These fields
require SIM access, which is only available after the modem enters
airplane mode (AT+CFUN=4).

Add AT+CIMI (IMSI) and AT%XICCID (ICCID) to the dial script after
AT+CFUN=4, where the SIM is initialised and accessible. AT%XICCID is a
Nordic-proprietary command whose response carries a %XICCID: prefix,
distinct from the +ICCID: prefix used by other modems. Add a dedicated
xiccid_match for this response format alongside the existing iccid_match
and qccid_match definitions.

Signed-off-by: Nikita Schewtschuk <nik@schew.dev>

(cherry picked from commit be050ec)
Move the common 3GPP message handlers to the header to enable OOT modems
to use the common implementations.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 5d3d023)
…iles

Simplify the `modem_cellular.c` file by pulling out all the individual
modem macros and instantiation to a dedicated file per modem.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit fcde47f)
Explicitly casting a `const void *` to an end data type is unnecessary,
introduces the opportunity to mis-cast the `const` qualifier and goes
against the direction decided in:
    zephyrproject-rtos/zephyr#37616

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 12b601a)
Switch out the hardcoded 32 byte buffer for a Kconfig option.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 3eb2355)
Once `rx_full` has been set, the modem is instructed to no longer send
data on that DLCI channel until we notify the modem that the channel is
able to receive more data. This happens in the RX callback which drains
the pipe.

Currently the amount of free space required in the ring buffer to
release the flow control condition is hardcoded to
`CONFIG_MODEM_CMUX_MTU`. While this value is fine for the DLCI1 and
DLCI2 channels (which have buffers created as
`CONFIG_MODEM_CMUX_MTU + N` bytes large), the user pipes with size
`MODEM_CELLULAR_USER_PIPE_BUFFER_SIZES` are typically much smaller. This
lead to the flow control condition never being released on the user
pipe DLCI channels once it was set.

Fix the issue by limiting the threshold to the capacity of the ring
buffer, so that if the buffer is completely empty we will always release
the flow control condition.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 4679c69)
Rather than passing every possible script into the common modem
instantiation macro, use a struct to hold all the scripts and pass the
struct instead.

The advantage of this approach is that it makes adding new optional
scripts much less invasive. The script only needs to be added to the
struct and populated in the drivers that will use it, no need to modify
the global macro.

Signed-off-by: Jordan Yates <jordan@embeint.com>

(cherry picked from commit 4f55300)
`subsys/net/l2/ppp/misc.c` uses NET_DBG() inside
`validate_phase_transition()`, which is compiled only when
CONFIG_NET_L2_PPP_LOG_LEVEL is at LOG_LEVEL_DBG. The macro is
declared in <zephyr/net/net_log.h>, which the file does not include.

At log level INF (default) the function body is a no-op stub
(ARG_UNUSED), so the missing macro goes unnoticed. At log level DBG
the file fails to build:

  misc.c: implicit declaration of function 'NET_DBG'
          [-Wimplicit-function-declaration]

Other files in the same directory (e.g. `link.c`) include
<zephyr/net/net_log.h> correctly; only `misc.c` is missing it.

Signed-off-by: Petr Hlineny <development@hlineny.cz>

(cherry picked from commit 4f33728)
…ipt_async()

It is easier just check the NULL pointer in Chat module, so
the modem_cellular.c does not need to check the existence of
periodic scripts.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit c44bc42)
When modem_chat_attach() is called with same pipe,
do not reset the parser state.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit ecf68f7)
…twork setup and PPP

* Add separate state RUN_NETWORK_SCRIPT before running the PPP dial script.
* Allow defining modem with separate network setup script.

These changes allow modem to be defined with a separate script
that runs on DLC1 channel and configures URC messages and joins the
network.

The PPP dial command can then be refactored to be only a single ATD*99#
or AT+CGDATA which runs on DLC2.

URC channel is not switched, so it can be configured to be DLC1
if given modem has a command for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit 57e5450)
… script

Refactor "nordic,nrf91-slm" to configure URC and PPP in the
network setup script.

The dial script can be now left empty as AT#XPPP=1 automatically
starts the PPP on the secondary DLC.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit 1ead2a4)
Lift the unsol_matches table out of modem_cellular.c.
Each driver now declares its own match table via the new
MODEM_CELLULAR_UNSOL_DEFINE() helper, which generates the matches array
and a small modem_cellular_config_unsol descriptor in one go. Drivers
point at it through the new `unsol` field on modem_cellular_config.

Signed-off-by: Paulo Santos <paulo.santos-ext@hexagon.com>

(cherry picked from commit 15726bd)
If CMUX is going to be shut down while in power-saving mode,
we need to wake-up before doing the state transitioning.

If we directly transition from STATE_POWERSAVE to
STATE_DISCONNECTING, the UART is not woken up and the
disconnect commands are not send.

Use is_connection() helper on both disconnect and connect APIs
to clean up the state check.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit 7412f6a)
Add testcases to verify that CMUX powersaving feature works.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

(cherry picked from commit 0a06a0f)
When network is temporary lost, we might receive
PPP_DEAD event just before parsing "+CEREG: ..."

Therefore immediately redialing might lead to out-of-sync
states.

Delay the redial script by the PERIODIC_SCRIPT_TIMEOUT
as any other script failures do.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>

Upstream PR #: 108986
@SeppoTakalo SeppoTakalo force-pushed the modem_fixes_from_upstream branch from 9d1c200 to 64d0ea3 Compare May 21, 2026 07:22
@SeppoTakalo
Copy link
Copy Markdown
Contributor Author

I have now dropped commits regarding 3rd party modem drivers from this PR as these are not relevant for nRF Connect SDK.
This causes some commits in the serial to cause conflicts, which I have fixed manually.

That is the reason for "Commit tags" check to not pass.

The 3rd party drivers were originally causing CI checks in nrfconnect/sdk-nrf#28730 to fail when unknown Kconfig variables were seen. So for us it is cleaner to fix the conflicts instead of pulling tons of unrelated fromtree-patches.

I have agreed with @rlubos about this approach.

NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 21, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@rlubos rlubos merged commit 76c2f94 into nrfconnect:main May 21, 2026
10 of 11 checks passed
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 21, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
rlubos pushed a commit to nrfconnect/sdk-nrf that referenced this pull request May 21, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4072

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
MarkusLassila added a commit to nrfconnect/ncs-serial-modem that referenced this pull request May 21, 2026
Brings the following:

Cellular modem fixes:
nrfconnect/sdk-zephyr#4072

SO_POLLCB:
nrfconnect/sdk-zephyr#4075

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants