Skip to content
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

Fixing HL7800 Timeout Issue in modem_cellular Example #86962

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

zafersn
Copy link
Contributor

@zafersn zafersn commented Mar 12, 2025

Problem Description
The modem_cellular example did not work with the HL7800 modem until the wake-up pin (MDM_WAKE) / (mdm_wake_gpios) was properly configured. Before this fix, the modem failed to respond correctly and resulted in timeout errors during initialization.

Root Cause
By default, the HL7800 modem might enter sleep mode or PSM (Power Saving Mode), preventing it from properly initializing or responding to AT commands. The modem_cellular driver did not explicitly configure the wake-up pin, which is essential to bring the modem to an active state before communication begins.

Fix Implemented

  1. Check if the wake-up pin is enabled in the device tree
  2. Configure the wake-up pin as an output and set it high to ensure the modem is active
  3. Additional improvement: I made changes to modem_cellular to wait for the KSUP URC message before sending any commands and disable sleep modes (PSM/eDRX) at startup. This ensures the modem remains responsive during initialization and operation.

Note: We discussed this issue on the [Discord modem channel], and the conclusion was not to implement the wake-up pin configuration but to rely on the modem’s previous ksleep configuration, as there may not be enough time to disable sleep by sending an AT command. According to the AT command guide (attached below), if the delay is set to 0, the modem can enter sleep mode immediately after rebooting, meaning we won't have time to run an AT command to disable modem sleep. This is why I had to implement the wake-up pin configuration.

image

Proposed PR Changes

  • Modify modem_cellular to automatically configure the wake-up pin on startup.
  • Disable sleep modes (PSM/eDRX) at initialization to avoid unexpected modem behavior.
  • Further improvement: I updated the modem_cellular to wait for the KSUP URC message, which indicates that the modem is ready to receive AT commands, before sending any commands. This ensures we don't rely on sending a random number of AT commands.

Copy link

Hello @zafersn, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Member

@rerickson1 rerickson1 left a comment

Choose a reason for hiding this comment

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

commit summary should be structured something like:

drivers: modem_cellular: fix HL7800 communication timeout

Comment on lines 2130 to 2144
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT", 100),
/* wait for the modem is ready to receive at cmds */
MODEM_CHAT_SCRIPT_CMD_RESP("", at_ready_match),
Copy link
Member

Choose a reason for hiding this comment

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

Its not guaranteed that the +KSUP notification is enabled. The first AT commands should be left and you should enabled the +KSUP URC for future start ups.

Copy link
Contributor Author

@zafersn zafersn Mar 12, 2025

Choose a reason for hiding this comment

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

This is correct as well. So, it seems like rolling back and running a series of AT commands is the best approach, or would you prefer me to follow the steps you described here:

The first AT commands should be left as is, and you should enable the +KSUP URC for future startups.

Copy link
Member

Choose a reason for hiding this comment

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

Or add a command to enable +KSUP and allow for waiting for +KSUP or continue after a timeout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or add a command to enable +KSUP and allow for waiting for +KSUP or continue after a timeout.

@rerickson1

Well, I tried this approach, but when I use MODEM_CHAT_SCRIPT_CMD_RESP("AT+KSREP=1", ok_match) as the first command, if the modem isn't awake at that moment, the code never times out properly. Instead, it waits for the general timeout and then restarts swir_hl7800_init_chat_script_cmds from the beginning, leading to a continuous failure loop.

See the log below. For now, reverting to the previous approach of running four AT commands might be the best option.

Waiting for L4 connected
[00:00:07.002,000] <dbg> net_mgmt: mgmt_event_wait_call: (main): Synchronous event 0xf9140001 wait 0x20018770
[00:00:07.002,000] <dbg> net_mgmt: net_mgmt_add_event_callback: (main): Adding event callback 0x20018770
[00:00:07.102,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:00:07.102,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 3
[00:00:07.102,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 5
[00:00:07.102,000] <dbg> modem_cellular: modem_cellular_await_power_on_event_handler: 783 modem_cellular_await_power_on_event_handler
[00:00:07.102,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from await power on to run init script
[00:00:07.102,000] <dbg> modem_cellular: modem_cellular_log_event: event bus opened
[00:00:07.102,000] <dbg> modem_chat: modem_chat_script_start: running script: swir_hl7800_init_chat_script
[00:00:07.102,000] <dbg> modem_chat: modem_chat_script_next: swir_hl7800_init_chat_script: step: 0
[00:00:07.102,000] <dbg> modem_chat: modem_chat_script_next: sending: AT+KSREP=1
[00:00:08.103,000] <wrn> modem_backend_uart_async: Transmit aborted (9 sent)
[00:00:09.104,000] <wrn> modem_backend_uart_async: Transmit aborted (0 sent)
[00:00:13.935,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:00:13.935,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:00:13.936,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:13.936,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:13.985,000] <dbg> modem_chat: modem_chat_on_unknown_command_received: +KSUP: 0
[00:00:18.985,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  0
[00:00:18.985,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  0
[00:00:18.985,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:18.985,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:18.985,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:00:18.985,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:00:18.985,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:18.985,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:21.336,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:00:21.336,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:00:21.406,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  5
[00:00:21.406,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  5
[00:00:21.406,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:00:21.406,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:01:07.102,000] <wrn> modem_chat: swir_hl7800_init_chat_script: timed out
[00:01:07.102,000] <dbg> modem_cellular: modem_cellular_log_event: event script failed
[00:01:07.102,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 5
[00:01:07.102,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 1
[00:01:07.102,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from run init script to reset pulse
[00:01:07.202,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:01:07.202,000] <dbg> modem_cellular: modem_cellular_reset_pulse_event_handler: 699 modem_cellular_reset_pulse_event_handler
[00:01:07.202,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 1
[00:01:07.202,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 3
[00:01:07.202,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1289 modem_cellular_on_state_enter
[00:01:07.202,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from reset pulse to await power on
[00:01:07.302,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:01:07.302,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 3
[00:01:07.302,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 5
[00:01:07.302,000] <dbg> modem_cellular: modem_cellular_await_power_on_event_handler: 783 modem_cellular_await_power_on_event_handler
[00:01:07.302,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from await power on to run init script
[00:01:07.302,000] <dbg> modem_cellular: modem_cellular_log_event: event bus opened
[00:01:07.302,000] <dbg> modem_chat: modem_chat_script_start: running script: swir_hl7800_init_chat_script
[00:01:07.302,000] <dbg> modem_chat: modem_chat_script_next: swir_hl7800_init_chat_script: step: 0
[00:01:07.302,000] <dbg> modem_chat: modem_chat_script_next: sending: AT+KSREP=1
[00:01:08.303,000] <wrn> modem_backend_uart_async: Transmit aborted (9 sent)
[00:01:09.305,000] <wrn> modem_backend_uart_async: Transmit aborted (0 sent)
[00:01:13.894,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:01:13.894,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:01:13.895,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:01:13.895,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:01:13.938,000] <dbg> modem_chat: modem_chat_on_unknown_command_received: +KSUP: 0
[00:01:15.467,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  0
[00:01:15.467,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  0
[00:01:15.467,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:01:15.467,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:01:15.467,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:01:15.467,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:01:15.467,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:01:15.467,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:01:17.528,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:01:17.528,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:01:17.595,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  5
[00:01:17.595,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  5
[00:01:17.596,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:01:17.596,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:02:07.002,000] <dbg> net_mgmt: net_mgmt_del_event_callback: (main): Deleting event callback 0x20018770
L4 was not connected in time
[00:02:07.302,000] <wrn> modem_chat: swir_hl7800_init_chat_script: timed out
[00:02:07.302,000] <dbg> modem_cellular: modem_cellular_log_event: event script failed
[00:02:07.302,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 5
[00:02:07.302,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 1
[00:02:07.302,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from run init script to reset pulse
[00:02:07.402,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:02:07.402,000] <dbg> modem_cellular: modem_cellular_reset_pulse_event_handler: 699 modem_cellular_reset_pulse_event_handler
[00:02:07.402,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 1
[00:02:07.402,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 3
[00:02:07.402,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1289 modem_cellular_on_state_enter
[00:02:07.402,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from reset pulse to await power on
[00:02:07.503,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:02:07.503,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 3
[00:02:07.503,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 5
[00:02:07.503,000] <dbg> modem_cellular: modem_cellular_await_power_on_event_handler: 783 modem_cellular_await_power_on_event_handler
[00:02:07.503,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from await power on to run init script
[00:02:07.503,000] <dbg> modem_cellular: modem_cellular_log_event: event bus opened
[00:02:07.503,000] <dbg> modem_chat: modem_chat_script_start: running script: swir_hl7800_init_chat_script
[00:02:07.503,000] <dbg> modem_chat: modem_chat_script_next: swir_hl7800_init_chat_script: step: 0
[00:02:07.503,000] <dbg> modem_chat: modem_chat_script_next: sending: AT+KSREP=1
[00:02:08.504,000] <wrn> modem_backend_uart_async: Transmit aborted (9 sent)
[00:02:09.505,000] <wrn> modem_backend_uart_async: Transmit aborted (0 sent)
[00:02:13.828,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:02:13.828,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:02:13.828,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:02:13.828,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:02:13.928,000] <dbg> modem_chat: modem_chat_on_unknown_command_received: +KSUP: 0
[00:02:16.672,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  0
[00:02:16.672,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  0
[00:02:16.673,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:02:16.673,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:02:16.673,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:02:16.673,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:02:16.673,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:02:16.673,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:02:19.412,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:02:19.412,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:02:19.474,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  5
[00:02:19.474,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  5
[00:02:19.474,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:02:19.474,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:03:07.503,000] <wrn> modem_chat: swir_hl7800_init_chat_script: timed out
[00:03:07.503,000] <dbg> modem_cellular: modem_cellular_log_event: event script failed
[00:03:07.503,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 5
[00:03:07.503,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 1
[00:03:07.503,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from run init script to reset pulse
[00:03:07.603,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:03:07.603,000] <dbg> modem_cellular: modem_cellular_reset_pulse_event_handler: 699 modem_cellular_reset_pulse_event_handler
[00:03:07.603,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 1
[00:03:07.603,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 3
[00:03:07.603,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1289 modem_cellular_on_state_enter
[00:03:07.603,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from reset pulse to await power on
[00:03:07.703,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:03:07.703,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 3
[00:03:07.703,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 5
[00:03:07.703,000] <dbg> modem_cellular: modem_cellular_await_power_on_event_handler: 783 modem_cellular_await_power_on_event_handler
[00:03:07.703,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from await power on to run init script
[00:03:07.703,000] <dbg> modem_cellular: modem_cellular_log_event: event bus opened
[00:03:07.703,000] <dbg> modem_chat: modem_chat_script_start: running script: swir_hl7800_init_chat_script
[00:03:07.703,000] <dbg> modem_chat: modem_chat_script_next: swir_hl7800_init_chat_script: step: 0
[00:03:07.703,000] <dbg> modem_chat: modem_chat_script_next: sending: AT+KSREP=1
[00:03:08.704,000] <wrn> modem_backend_uart_async: Transmit aborted (9 sent)
[00:03:09.705,000] <wrn> modem_backend_uart_async: Transmit aborted (0 sent)
[00:03:14.046,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:03:14.046,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:03:14.047,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:03:14.047,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:03:15.928,000] <dbg> modem_chat: modem_chat_on_unknown_command_received: +KSUP: 0
[00:03:18.084,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  0
[00:03:18.084,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  0
[00:03:18.084,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:03:18.084,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:03:18.084,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:03:18.084,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:03:18.084,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:03:18.084,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:03:20.696,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:03:20.696,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:03:20.763,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  5
[00:03:20.763,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  5
[00:03:20.764,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:03:20.764,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:04:07.703,000] <wrn> modem_chat: swir_hl7800_init_chat_script: timed out
[00:04:07.703,000] <dbg> modem_cellular: modem_cellular_log_event: event script failed
[00:04:07.703,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 5
[00:04:07.703,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 1
[00:04:07.703,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from run init script to reset pulse
[00:04:07.803,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:04:07.803,000] <dbg> modem_cellular: modem_cellular_reset_pulse_event_handler: 699 modem_cellular_reset_pulse_event_handler
[00:04:07.803,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 1
[00:04:07.803,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 3
[00:04:07.803,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1289 modem_cellular_on_state_enter
[00:04:07.803,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from reset pulse to await power on
[00:04:07.903,000] <dbg> modem_cellular: modem_cellular_log_event: event timeout
[00:04:07.903,000] <dbg> modem_cellular: modem_cellular_on_state_leave: 1352 modem_cellular_on_state_leave 3
[00:04:07.903,000] <dbg> modem_cellular: modem_cellular_on_state_enter: 1274 modem_cellular_on_state_enter 5
[00:04:07.903,000] <dbg> modem_cellular: modem_cellular_await_power_on_event_handler: 783 modem_cellular_await_power_on_event_handler
[00:04:07.903,000] <dbg> modem_cellular: modem_cellular_log_state_changed: switch from await power on to run init script
[00:04:07.903,000] <dbg> modem_cellular: modem_cellular_log_event: event bus opened
[00:04:07.903,000] <dbg> modem_chat: modem_chat_script_start: running script: swir_hl7800_init_chat_script
[00:04:07.903,000] <dbg> modem_chat: modem_chat_script_next: swir_hl7800_init_chat_script: step: 0
[00:04:07.903,000] <dbg> modem_chat: modem_chat_script_next: sending: AT+KSREP=1
[00:04:08.905,000] <wrn> modem_backend_uart_async: Transmit aborted (9 sent)
[00:04:09.906,000] <wrn> modem_backend_uart_async: Transmit aborted (0 sent)
[00:04:16.130,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:04:16.130,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:04:16.130,000] <dbg> modem_chat: modem_chat_on_unknown_command_received: +KSUP: 0
[00:04:16.130,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:04:16.130,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:04:19.482,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  0
[00:04:19.482,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  0
[00:04:19.482,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:04:19.482,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:04:19.482,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:04:19.482,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  2
[00:04:19.482,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:04:19.482,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:04:22.260,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  2
[00:04:22.260,000] <dbg> modem_cellular: modem_cellular_log_event: event deregistered
[00:04:22.322,000] <dbg> modem_chat: modem_chat_log_received_command: +CEREG:  5
[00:04:22.322,000] <dbg> modem_chat: modem_chat_log_received_command: +CREG:  5
[00:04:22.322,000] <dbg> modem_cellular: modem_cellular_log_event: event registered
[00:04:22.322,000] <dbg> modem_cellular: modem_cellular_log_event: event registered

Copy link
Member

Choose a reason for hiding this comment

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

The 4 AT commands should come first to wait for ready, or if the KSREP command is first, the time to wait for the command needs to be longer, or try it multiple times. Also, on boot, the HL7800 CTS line will go high, and then low once it can receive AT commands. That logic could be used too. As you can see, it quickly gets complicated :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 4 AT commands should come first to wait for ready, or if the KSREP command is first, the time to wait for the command needs to be longer, or try it multiple times. Also, on boot, the HL7800 CTS line will go high, and then low once it can receive AT commands. That logic could be used too. As you can see, it quickly gets complicated :).

I just saw this comment now. Yeah, exactly! It quickly gets complicated. :) That’s why I don’t want to spend too much time on this and prefer to move on to the actual modem driver work as soon as I finish this. We could implement a really solid solution, but since modem_cellular also supports other modems, we need to consider compatibility. Changes that work for us might not work for them. :)

@zafersn zafersn force-pushed the main branch 2 times, most recently from 6561a57 to 299fa3a Compare March 12, 2025 18:30
@@ -1723,6 +1741,10 @@ static int modem_cellular_init(const struct device *dev)
gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_ACTIVE);
}

if (modem_cellular_gpio_is_enabled(&config->wake_gpio)) {
gpio_pin_configure_dt(&config->wake_gpio, GPIO_OUTPUT_ACTIVE);
Copy link
Member

Choose a reason for hiding this comment

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

Should not be active here. Reset is active before this.

@rerickson1
Copy link
Member

HL7800 may enter sleep, blocking init without proper config.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

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

Looks harmless enough :)

@kartben kartben merged commit 7efbc7c into zephyrproject-rtos:main Mar 19, 2025
21 checks passed
Copy link

Hi @zafersn!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

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! 🪁

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.

5 participants