Skip to content

Commit b6c97ba

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 <[email protected]>
1 parent 2fc54ae commit b6c97ba

File tree

9 files changed

+131
-4
lines changed

9 files changed

+131
-4
lines changed

drivers/modem/Kconfig.cellular

+1-1
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

+69-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ 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) || DT_HAS_COMPAT_STATUS_OKAY(sqn_gm02s) || DT_HAS_COMPAT_STATUS_OKAY(simcom_a76xx)
529529
MODEM_CHAT_MATCH_DEFINE(connect_match, "CONNECT", "", NULL);
530530
#endif
531531

@@ -2064,6 +2064,51 @@ MODEM_CHAT_SCRIPT_DEFINE(simcom_sim7080_periodic_chat_script,
20642064
modem_cellular_chat_callback_handler, 4);
20652065
#endif
20662066

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

2615+
#define MODEM_CELLULAR_DEVICE_SIMCOM_A76XX(inst) \
2616+
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
2617+
\
2618+
static struct modem_cellular_data MODEM_CELLULAR_INST_NAME(data, inst) = { \
2619+
.chat_delimiter = "\r", \
2620+
.chat_filter = "\n", \
2621+
.ppp = &MODEM_CELLULAR_INST_NAME(ppp, inst), \
2622+
}; \
2623+
\
2624+
MODEM_CELLULAR_DEFINE_AND_INIT_USER_PIPES(inst, \
2625+
(user_pipe_0, 3), \
2626+
(user_pipe_1, 4)) \
2627+
\
2628+
MODEM_CELLULAR_DEFINE_INSTANCE(inst, 1500, 100, 20000, 5000, false, \
2629+
NULL, \
2630+
&simcom_a76xx_init_chat_script, \
2631+
&simcom_a76xx_dial_chat_script, \
2632+
&simcom_a76xx_periodic_chat_script, NULL)
2633+
25702634
#define MODEM_CELLULAR_DEVICE_U_BLOX_SARA_R4(inst) \
25712635
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
25722636
\
@@ -2730,6 +2794,10 @@ DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_QUECTEL_EG25_G)
27302794
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_SIMCOM_SIM7080)
27312795
#undef DT_DRV_COMPAT
27322796

2797+
#define DT_DRV_COMPAT simcom_a76xx
2798+
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_SIMCOM_A76XX)
2799+
#undef DT_DRV_COMPAT
2800+
27332801
#define DT_DRV_COMPAT u_blox_sara_r4
27342802
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_U_BLOX_SARA_R4)
27352803
#undef DT_DRV_COMPAT

dts/bindings/modem/simcom,a76xx.yaml

+13
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

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Configuration options for cellular modem sample
2+
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
mainmenu "Cellular modem sample application"
6+
7+
config SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME
8+
string "Endpoint hostname"
9+
default "test-endpoint.com"
10+
11+
source "Kconfig.zephyr"

samples/net/cellular_modem/README.rst

+8
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ 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+
git clone --depth=1 https://github.com/zephyrproject-rtos/zephyr.git
64+
cd zephyr/samples/net/cellular_modem/server
65+
python te.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
&uart1 {
12+
compatible = "nordic,nrf-uarte";
13+
status = "okay";
14+
current-speed = <115200>;
15+
// The module I tested with doesn't expose RCS/CTS pins
16+
// hw-flow-control;
17+
18+
pinctrl-0 = <&uart1_default>;
19+
20+
modem: modem {
21+
compatible = "simcom,a76xx";
22+
status = "okay";
23+
mdm-power-gpios = <&gpio0 2 (GPIO_ACTIVE_HIGH)>;
24+
};
25+
};

samples/net/cellular_modem/src/main.c

+1-1
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

+1-1
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)