-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: modem: hl78xx: Add automatic baud rate detection and switching #100612
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
Open
zafersn
wants to merge
10
commits into
zephyrproject-rtos:main
Choose a base branch
from
zafersn:feature/hl78xx-auto-baudrate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
drivers: modem: hl78xx: Add automatic baud rate detection and switching #100612
zafersn
wants to merge
10
commits into
zephyrproject-rtos:main
from
zafersn:feature/hl78xx-auto-baudrate
+1,474
−99
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extend socket-related chat match tables to handle generic "ERROR" responses for both CONNECT and +KUDP_IND URCs, improving detection of failed socket creation and connection attempts. While updating match handling, unify all modem commands to use the standard OK match set by adding hl78xx_get_ok_match_size(). All remaining users of the former sockets-specific OK match are switched to the unified helpers. Additionally, all dynamic command send paths now provide an explicit match count and use MDM_CMD_TIMEOUT instead of the previous hard-coded `1` for script timeout, improving consistency and reliability across: * RAT configuration * band configuration * APN setup * GSM PDP activation * AirVantage DM session control * socket send and TLS configuration paths This brings all command execution onto the same match/timeout model and ensures ERROR responses are handled correctly during socket operations. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Extend modem_dynamic_cmd_send() with a response_timeout parameter to allow callers to specify the overall script timeout per command. The previously hardcoded 1000 ms timeout is removed (set to 0 in params) and the script timeout is now driven by the passed-in value. Update all internal call sites to provide MDM_CMD_TIMEOUT (in seconds) and increase the default command timeout from 10 s to 40 s. Several chat scripts and configuration paths are updated accordingly. This improves reliability for long-running HL78xx operations and ensures consistent timeout handling across sockets, RAT/band configuration, APN setup, PDP activation, AirVantage DM session control, and TLS/TCP/UDP socket management. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Add MODEM_HL78XX_EVENT_AT_CMD_TIMEOUT event to distinguish chat scripts timeouts from other script failures. The chat callback now maps MODEM_CHAT_SCRIPT_RESULT_TIMEOUT to this new event. Update state handlers so AT command timeouts trigger the init fail diagnostic script during startup, and fall back to the power-on pulse in the init-fail state, similar to existing timeout handling. This improves error classification and enables more accurate recovery logic for long-running or stalled AT command exchanges. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
0311f12 to
340ee1c
Compare
…ching This adds an optional auto-baudrate mechanism that improves robustness when the modem boots with an unknown or changed UART speed. Key additions: * New Kconfig option MODEM_HL78XX_AUTO_BAUDRATE and related settings: - selectable target baud rate - detection baudrate list - detection timeout and retry count - option to persist AT+IPR updates - option to start diagnostics or boot directly with auto-baud logic * UART status tracking added to hl78xx_data, including current and target baud rates * New HL78XX_MODEM_INFO_CURRENT_BAUD_RATE info field * New MODEM_HL78XX_STATE_SET_BAUDRATE state with detection and switching logic * Chat, init, and diagnostic handlers updated to route failures into the auto-baudrate logic when enabled * New helpers: hl78xx_get_uart_config(), hl78xx_try_baudrate(), hl78xx_detect_current_baudrate(), hl78xx_switch_baudrate() * Startup delay increased when auto-baudrate-at-boot is enabled These changes allow the driver to recover from unexpected modem UART rate changes and keep the UART configuration synchronized with the modem. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Reorganize the sample configuration files for clarity and easier maintenance. This introduces grouped sections with descriptive comments and improves consistency between prj.conf and the verbose-logging overlay. Main updates: * Add structured headers for system, UART, networking, modem, RAT, AirVantage, shell, and logging settings * Expand verbose overlay with clearer purpose, build notes, and grouped modem logging options * Improve readability by aligning comments and collecting related options * No functional behavior is changed; this is a documentation and structure improvement These changes make the sample configuration easier to understand and simplify future maintenance. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
The sample no longer requires the POSIX API layer, so the CONFIG_POSIX_API option is removed from prj.conf. The code is updated to use the native zsock_* APIs instead of the POSIX getaddrinfo(), inet_ntop(), and freeaddrinfo() variants. This aligns the sample with Zephyr’s preferred socket API and avoids pulling in unnecessary POSIX compatibility layers. No functional behavior is changed. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Add support for handling AirVantage WDSI indications in the sample application. FOTA update progress, download requests, and completion events are processed and coordinated using a new semaphore. The sample can restart its connection workflow after a successful firmware update. Additional updates include: - add serial number retrieval and logging - add fota_complete_rerun semaphore and status tracking - simplify debug logging in event listener and OK handler - reorganize main loop to support FOTA-triggered reruns This aligns the sample with the modem driver's expanded AirVantage and WDSI support. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
The sample previously always queried RSRP, which is not valid when the HL78xx operates in GSM mode. Use RSSI when GSM RAT is active and RSRP for other RATs. Update the log output and rename the variable for clarity. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Enable HL78XX modem auto-baudrate detection and switching in the sample application. Set 921600 bps as the target baudrate with fallback options (9600, 115200, 57600, 38400, 19200). Also read and log the current baudrate from the modem during startup. This helps verify and debug communication speed mismatches between the modem and the device UART. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Add detailed documentation for the HL78xx auto-baudrate feature, including: - AUTO_BAUDRATE_README.md: full description, use cases, configuration options, and troubleshooting - QUICK_REFERENCE.md: concise reference for presets, Kconfig options, and supported baud rates Covers: - Feature overview and implementation details - Supported baud rates and Kconfig options - State machine integration - Troubleshooting guidance - Performance and optimization tips - Integration examples This improves usability and provides a quick reference for developers working with the HL78xx modem in Zephyr projects. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
340ee1c to
8559e9a
Compare
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Summary
This PR adds automatic baud rate detection and switching capability to the Sierra Wireless HL78xx modem driver (HL7812/HL7800). The feature enables the driver to automatically detect the modem's current UART baud rate and switch to a configured target rate, improving reliability and flexibility in production environments.
In production deployments, modems may be configured with different baud rates from previous sessions, factory defaults, or manual AT commands. Currently, if the modem's baud rate doesn't match the device tree configuration, communication fails and the driver cannot initialize. This feature eliminates manual baud rate synchronization and enables automatic recovery from baud rate mismatches.
Key Features