-
Notifications
You must be signed in to change notification settings - Fork 7.6k
modem_cellular: Add support for the simcom a76xx modem #90081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello @olalonde, and thank you very much for your first pull request to the Zephyr project! |
43d0b7c
to
41fa7b7
Compare
@@ -0,0 +1,27 @@ | |||
/ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look right. Now anyone having this DK will get this simcom modem added automatically even if he/she does not have one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the nrf52840dk board for testing the modem as none of the supported Zephyr boards uses it. There's no reason to run the cellular modem sample with it since it doesn't have a modem, so the chance of confusing someone is low. Is there a better way to do this? Or should i just remove it from the sample? I don't mind either way it was mostly just to facilitate my testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that someone might be using the nRF52840 DK as the host MCU just as you are doing, but with another modem.
Maybe a solution would be to move and rename this overlay so that it's just for this particular modem and you can include it manually in your build.
Don't know what the others think of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomi-font Personally, I feel boards that don't have a modem on them shouldn't be included here at all. Perhaps instead we could include documentation on how to write a DTS for this sample instead.
config SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME | ||
string "Endpoint hostname" | ||
default "test-endpoint.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! @bjarki-andreasen something really should be done with regards to test-endpoint.com
... cc @kartben
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side note, in my own project, I recently added this to my CMakeLists.txt
to avoid committing secrets to git:
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/local.conf)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/local.conf
"# This file is not version controlled, you can use it for local only configuration")
endif()
set(EXTRA_CONF_FILE
${CMAKE_CURRENT_SOURCE_DIR}/local.conf
)
And I also added local.conf
to .gitignore
.
It would be useful here to allow developers to set a private CONFIG_SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME
without having to edit a version controlled file. And for other configurations (e.g. logging) that are useful for testing but that you don't necessarily want to commit to git.
@@ -0,0 +1,27 @@ | |||
/ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that someone might be using the nRF52840 DK as the host MCU just as you are doing, but with another modem.
Maybe a solution would be to move and rename this overlay so that it's just for this particular modem and you can include it manually in your build.
Don't know what the others think of this.
@@ -0,0 +1,3 @@ | |||
# Otherwise we run into DLCI buffer overruns (maybe due to lack of UART hardware flow control?) | |||
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE=1507 | |||
CONFIG_NET_IPV6=n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation for this? (as a comment)
samples/net/cellular_modem/prj.conf
Outdated
@@ -1,5 +1,6 @@ | |||
# Copyright (c) 2023 Bjarki Arge Andreasen | |||
# SPDX-License-Identifier: Apache-2.0 | |||
CONFIG_SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME="" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olalonde I guess you include the hostname by passing an environment variable (in CMake or when building with west
), but there is no reason not to have a default here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a default that works? I just thought it would make it more obvious that this option needs to be set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then in that case maybe you would change the default of the Kconfig option where it's defined, I think it would make more sense.
But it's true that given test-endpoint.com
is no longer functional it might be better to completely remove it.
|
||
MODEM_CHAT_SCRIPT_CMDS_DEFINE(simcom_a76xx_shutdown_chat_script_cmds, | ||
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CPOF", ok_match)); | ||
|
||
MODEM_CHAT_SCRIPT_DEFINE(simcom_a76xx_shutdown_chat_script, | ||
simcom_a76xx_shutdown_chat_script_cmds, abort_matches, | ||
modem_cellular_chat_callback_handler, 15); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that important but this commit could be squashed into the first one.
drivers/modem/modem_cellular.c
Outdated
#ifdef CONFIG_MODEM_CELLULAR_POWER_ON_GNSS | ||
/* Power on the GNSS module. | ||
* We need to do this early, otherwise it does not work when | ||
* doing it later (e.g. from a user pipe). | ||
*/ | ||
MODEM_CHAT_SCRIPT_CMD_RESP_MULT("AT+CGNSSPWR=1", allow_match), | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef CONFIG_MODEM_CELLULAR_POWER_ON_GNSS | |
/* Power on the GNSS module. | |
* We need to do this early, otherwise it does not work when | |
* doing it later (e.g. from a user pipe). | |
*/ | |
MODEM_CHAT_SCRIPT_CMD_RESP_MULT("AT+CGNSSPWR=1", allow_match), | |
#endif | |
#ifdef CONFIG_MODEM_CELLULAR_POWER_ON_GNSS | |
/* Power on the GNSS module. | |
* We need to do this early, otherwise it does not work when | |
* doing it later (e.g. from a user pipe). | |
*/ | |
MODEM_CHAT_SCRIPT_CMD_RESP_MULT("AT+CGNSSPWR=1", allow_match), | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The board overlay for the cellular sample must be removed. In zephyr, we have the option of boards and shields for common portable build targets. overlays specific to a local setup is not allowed upstream (outside of common vendor specific fixtures)
drivers/modem/Kconfig.cellular
Outdated
config MODEM_CELLULAR_POWER_ON_GNSS | ||
bool "Power on the modem's GNSS module" | ||
depends on DT_HAS_SIMCOM_A76XX_ENABLED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this config, the modem_cellular.c driver is an MVP for cellular networking, its not meant for power optimization of GNSS. Just enable it unconditionally. For finer control, introduce a device driver specific driver.
MODEM_CHAT_SCRIPT_CMDS_DEFINE(simcom_a76xx_periodic_chat_script_cmds, | ||
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CREG?", ok_match), | ||
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG?", ok_match), | ||
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGREG?", ok_match)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AT+CREG?
command is used to query circuit-switched network (2G/3G) registration status. The AT+CGREG?
command is used to query GPRS (2G) registration status, and the AT+CEREG?
is used to query EPS registration status (LTE, essentially). Not all A76XX series modems support all of these technologies, so it is not unexpected to receive a +CGREG: 0,0
or +CREG: 0,0
while you are connected to an LTE network.
The way the current state machine works is it will start some mechanism to recover from a loss of registration. I suspect running these commands in an LTE-only module is going to potentially introduce issues. In general, this area needs to be improved because for multi-RAT modems the logic is finicky at best.
drivers/modem/modem_cellular.c
Outdated
@@ -616,6 +618,8 @@ static int modem_cellular_on_idle_state_enter(struct modem_cellular_data *data) | |||
} | |||
|
|||
modem_cellular_notify_user_pipes_disconnected(data); | |||
net_if_carrier_off(modem_ppp_get_iface(data->ppp)); | |||
net_if_dormant_off(modem_ppp_get_iface(data->ppp)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The net_if_dormant_off()
should do nothing, because we never call net_if_dormant_on(...)
. While net_if_carrier_off(...)
should be called when leaving CARRIER_ON_STATE
in modem_cellular_carrier_on_state_leave(...)
. Basically, in the same state it was previously turned on.
Could you maybe turn on CONFIG_MODEM_LOG_LEVEL_DBG=y
as it will allow us to track these state changes.
Seems that notify_iface_up(...)
in net_if.c
is never called. Could you please enable CONFIG_NET_IF_LOG_LEVEL_DBG=y
so we understand the cause why? Because we should be calling carrier_on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We covered this here #90084
@@ -0,0 +1,27 @@ | |||
/ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomi-font Personally, I feel boards that don't have a modem on them shouldn't be included here at all. Perhaps instead we could include documentation on how to write a DTS for this sample instead.
samples/net/cellular_modem/prj.conf
Outdated
@@ -1,5 +1,6 @@ | |||
# Copyright (c) 2023 Bjarki Arge Andreasen | |||
# SPDX-License-Identifier: Apache-2.0 | |||
CONFIG_SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME="" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olalonde I guess you include the hostname by passing an environment variable (in CMake or when building with west
), but there is no reason not to have a default here.
6f7d1e4
to
442d575
Compare
@bjarki-andreasen I think I addressed all the issues. |
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]>
|
|
||
config SAMPLE_CELLULAR_MODEM_ENDPOINT_HOSTNAME | ||
string "Endpoint hostname" | ||
default "test-endpoint.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it makes sense to stop pretending test-endpoint.com
should be functional:
default "test-endpoint.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's really not ideal.
The sample/instructions should be updated to not depend it anymore, or the doc should be updated to indicate how one may host their own server (with the caveat that users might struggle to make their endpoint publicly accessible)
IMO the sample should be a really minimal showcase of printing modem-info, showing that we can ping 8.8.8.8 or whatever, and that's it. Things like testing throughput etc. are really something that's left for a test IMO, and probably don't belong to the sample.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree as well :) With the state of the modem subsystem and drivers, we should be looking to networking samples to test networking, the cellular part really should not make a difference :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I think it would be better to split this into at least two commits. One for driver changes, and the other for the sample changes.
Hi @olalonde! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
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.
Tested with:
and