Skip to content

Commit 5a7e8a3

Browse files
committed
modem_cellular: Add support for the simcom a76xx modem
Add support for the simcom a76xx modem which is similar to the simcom 7080 but has a few key differences. Tested with a simcom A7672SA module but as there is a single simcom A76XX AT commands manual, the driver should work with other modems of the series. Signed-off-by: Olivier Lalonde <o@syskall.com>
1 parent 2fc54ae commit 5a7e8a3

File tree

9 files changed

+138
-4
lines changed

9 files changed

+138
-4
lines changed

drivers/modem/Kconfig.cellular

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config MODEM_CELLULAR
1414
select NET_L2_PPP_OPTION_MRU
1515
select NET_L2_PPP_PAP
1616
select NET_L2_PPP_MGMT
17-
depends on (DT_HAS_QUECTEL_BG95_ENABLED || \
17+
depends on (DT_HAS_QUECTEL_BG95_ENABLED || DT_HAS_SIMCOM_A76XX_ENABLED || \
1818
DT_HAS_SIMCOM_SIM7080_ENABLED || DT_HAS_U_BLOX_SARA_R4_ENABLED || \
1919
DT_HAS_U_BLOX_SARA_R5_ENABLED || DT_HAS_SWIR_HL7800_ENABLED || \
2020
DT_HAS_TELIT_ME910G1_ENABLED || DT_HAS_TELIT_ME310G1_ENABLED || \

drivers/modem/modem_cellular.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ MODEM_CHAT_MATCHES_DEFINE(dial_abort_matches,
525525
MODEM_CHAT_MATCH("NO CARRIER", "", NULL),
526526
MODEM_CHAT_MATCH("NO DIALTONE", "", NULL));
527527

528-
#if DT_HAS_COMPAT_STATUS_OKAY(swir_hl7800) || DT_HAS_COMPAT_STATUS_OKAY(sqn_gm02s)
528+
#if DT_HAS_COMPAT_STATUS_OKAY(swir_hl7800) || \
529+
DT_HAS_COMPAT_STATUS_OKAY(sqn_gm02s) || \
530+
DT_HAS_COMPAT_STATUS_OKAY(simcom_a76xx)
529531
MODEM_CHAT_MATCH_DEFINE(connect_match, "CONNECT", "", NULL);
530532
#endif
531533

@@ -2064,6 +2066,51 @@ MODEM_CHAT_SCRIPT_DEFINE(simcom_sim7080_periodic_chat_script,
20642066
modem_cellular_chat_callback_handler, 4);
20652067
#endif
20662068

2069+
#if DT_HAS_COMPAT_STATUS_OKAY(simcom_a76xx)
2070+
MODEM_CHAT_SCRIPT_CMDS_DEFINE(simcom_a76xx_init_chat_script_cmds,
2071+
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
2072+
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
2073+
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
2074+
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
2075+
MODEM_CHAT_SCRIPT_CMD_RESP("ATE0", ok_match),
2076+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=4", ok_match),
2077+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CMEE=1", ok_match),
2078+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CREG=1", ok_match),
2079+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGREG=1", ok_match),
2080+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG=1", ok_match),
2081+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CREG?", ok_match),
2082+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG?", ok_match),
2083+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGREG?", ok_match),
2084+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGSN", imei_match),
2085+
MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
2086+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGMM", cgmm_match),
2087+
MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
2088+
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT+CMUX=0,0,5,127", 300));
2089+
2090+
MODEM_CHAT_SCRIPT_DEFINE(simcom_a76xx_init_chat_script, simcom_a76xx_init_chat_script_cmds,
2091+
abort_matches, modem_cellular_chat_callback_handler, 10);
2092+
2093+
MODEM_CHAT_SCRIPT_CMDS_DEFINE(simcom_a76xx_dial_chat_script_cmds,
2094+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGDCONT=1,\"IP\","
2095+
"\""CONFIG_MODEM_CELLULAR_APN"\"",
2096+
ok_match),
2097+
MODEM_CHAT_SCRIPT_CMD_RESP_MULT("AT+CGACT=0,1", allow_match),
2098+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=1", ok_match),
2099+
MODEM_CHAT_SCRIPT_CMD_RESP("ATD*99***1#", connect_match),);
2100+
2101+
MODEM_CHAT_SCRIPT_DEFINE(simcom_a76xx_dial_chat_script, simcom_a76xx_dial_chat_script_cmds,
2102+
dial_abort_matches, modem_cellular_chat_callback_handler, 10);
2103+
2104+
MODEM_CHAT_SCRIPT_CMDS_DEFINE(simcom_a76xx_periodic_chat_script_cmds,
2105+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CREG?", ok_match),
2106+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG?", ok_match),
2107+
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGREG?", ok_match));
2108+
2109+
MODEM_CHAT_SCRIPT_DEFINE(simcom_a76xx_periodic_chat_script,
2110+
simcom_a76xx_periodic_chat_script_cmds, abort_matches,
2111+
modem_cellular_chat_callback_handler, 4);
2112+
#endif
2113+
20672114
#if DT_HAS_COMPAT_STATUS_OKAY(u_blox_sara_r4)
20682115
MODEM_CHAT_SCRIPT_CMDS_DEFINE(u_blox_sara_r4_init_chat_script_cmds,
20692116
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
@@ -2567,6 +2614,25 @@ MODEM_CHAT_SCRIPT_DEFINE(sqn_gm02s_periodic_chat_script,
25672614
&simcom_sim7080_dial_chat_script, \
25682615
&simcom_sim7080_periodic_chat_script, NULL)
25692616

2617+
#define MODEM_CELLULAR_DEVICE_SIMCOM_A76XX(inst) \
2618+
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
2619+
\
2620+
static struct modem_cellular_data MODEM_CELLULAR_INST_NAME(data, inst) = { \
2621+
.chat_delimiter = "\r", \
2622+
.chat_filter = "\n", \
2623+
.ppp = &MODEM_CELLULAR_INST_NAME(ppp, inst), \
2624+
}; \
2625+
\
2626+
MODEM_CELLULAR_DEFINE_AND_INIT_USER_PIPES(inst, \
2627+
(user_pipe_0, 3), \
2628+
(user_pipe_1, 4)) \
2629+
\
2630+
MODEM_CELLULAR_DEFINE_INSTANCE(inst, 500, 100, 20000, 5000, false, \
2631+
NULL, \
2632+
&simcom_a76xx_init_chat_script, \
2633+
&simcom_a76xx_dial_chat_script, \
2634+
&simcom_a76xx_periodic_chat_script, NULL)
2635+
25702636
#define MODEM_CELLULAR_DEVICE_U_BLOX_SARA_R4(inst) \
25712637
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
25722638
\
@@ -2730,6 +2796,10 @@ DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_QUECTEL_EG25_G)
27302796
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_SIMCOM_SIM7080)
27312797
#undef DT_DRV_COMPAT
27322798

2799+
#define DT_DRV_COMPAT simcom_a76xx
2800+
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_SIMCOM_A76XX)
2801+
#undef DT_DRV_COMPAT
2802+
27332803
#define DT_DRV_COMPAT u_blox_sara_r4
27342804
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_U_BLOX_SARA_R4)
27352805
#undef DT_DRV_COMPAT

dts/bindings/modem/simcom,a76xx.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (C) 2021 metraTec GmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Simcom A76XX modem
5+
6+
compatible: "simcom,a76xx"
7+
8+
include: uart-device.yaml
9+
10+
properties:
11+
mdm-power-gpios:
12+
type: phandle-array
13+
required: true

samples/net/cellular_modem/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2025 Olivier Lalonde
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Configuration options for cellular modem sample
5+
6+
mainmenu "Cellular modem sample application"
7+
8+
config SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME
9+
string "Endpoint hostname"
10+
default "test-endpoint.com"
11+
12+
source "Kconfig.zephyr"

samples/net/cellular_modem/README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ Next, the UART API must be specified using ``CONFIG_UART_INTERRUPT_DRIVEN=y`` or
5555
``CONFIG_UART_ASYNC_API=y``. The driver doesn't support UART polling.
5656

5757
Lastly, the APN must be configured using ``CONFIG_MODEM_CELLULAR_APN=""``.
58+
59+
Server setup
60+
************
61+
62+
.. code-block:: shell
63+
64+
git clone --depth=1 https://github.com/zephyrproject-rtos/zephyr.git
65+
cd zephyr/samples/net/cellular_modem/server
66+
python te.py
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Otherwise we run into DLCI buffer overruns (maybe due to lack of UART hardware flow control?)
2+
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE=1507
3+
CONFIG_NET_IPV6=n
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/ {
2+
aliases {
3+
modem = &modem;
4+
};
5+
};
6+
7+
/* Tested with Simcom A7672SA module connected via UART
8+
* TX: P1.2
9+
* RX: P1.1
10+
* PWRKEY: P0.02
11+
*/
12+
&uart1 {
13+
compatible = "nordic,nrf-uarte";
14+
status = "okay";
15+
current-speed = <115200>;
16+
/* The module I tested with doesn't expose RCS/CTS pins
17+
* hw-flow-control;
18+
*/
19+
20+
pinctrl-0 = <&uart1_default>;
21+
22+
modem: modem {
23+
compatible = "simcom,a76xx";
24+
status = "okay";
25+
mdm-power-gpios = <&gpio0 2 (GPIO_ACTIVE_HIGH)>;
26+
};
27+
};

samples/net/cellular_modem/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <zephyr/drivers/cellular.h>
1717

18-
#define SAMPLE_TEST_ENDPOINT_HOSTNAME ("test-endpoint.com")
18+
#define SAMPLE_TEST_ENDPOINT_HOSTNAME CONFIG_SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME
1919
#define SAMPLE_TEST_ENDPOINT_UDP_ECHO_PORT (7780)
2020
#define SAMPLE_TEST_ENDPOINT_UDP_RECEIVE_PORT (7781)
2121
#define SAMPLE_TEST_PACKET_SIZE (1024)

subsys/modem/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ config MODEM_CMUX_DEFAULT_MTU_127
3535
DT_HAS_SIMCOM_SIM7080_ENABLED || DT_HAS_U_BLOX_SARA_R4_ENABLED || \
3636
DT_HAS_U_BLOX_SARA_R5_ENABLED || DT_HAS_SWIR_HL7800_ENABLED || \
3737
DT_HAS_TELIT_ME910G1_ENABLED || DT_HAS_TELIT_ME310G1_ENABLED || \
38-
DT_HAS_SQN_GM02S_ENABLED)
38+
DT_HAS_SQN_GM02S_ENABLED || DT_HAS_SIMCOM_A76XX_ENABLED)
3939
help
4040
Use the default MTU size of 127 bytes for the CMUX module on certain modems.
4141
This must match the AT+CMUX commands in the modem_cellular driver.

0 commit comments

Comments
 (0)