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

Qspi patch #1

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open

Qspi patch #1

wants to merge 35 commits into from

Conversation

ldenefle
Copy link
Collaborator

No description provided.

Bjarki Arge Andreasen and others added 29 commits November 6, 2023 09:16
The backend currently returns the pipe closed event immediately
after calling uart_rx_disable() which is not the correct behavior.
the pipe closed event should be called when the UART_RX_DISABLED
event is raised by the UART driver.

With this fix, back-to-back open/close/open... will work as
expected, where before the second open would often fail since
the UART was not actually disabled yet.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit improves the usage of the bus pipe (connected
to UART) to only open it when the modem is actually
powered and ready, not when leaving the idle state. This
ensures the pipe is flushed before sending the init script,
and re-enables the UART driver if it is disabled due to
errors.

While building a test platform based on the nRF9160 and a
Quectel BG95, it was discovered that the nRF9160 correctly
throws UART errors if the RX is enabled while the UART RX
line is low (which was due to the modem being powered
down).

The improvements should also help help remove the
"<wrn> modem_chat: receive buffer overrun" warning which
would occur during startup as the pipe was opened, but
nothing was receiving the data, causing the buffer to
overflow.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit delegates the modem_pipe_notify_closed() call
resulting from the UART async API UART_RX_DISABLED event
to the workqueue. This is neccesary as the async UART
callback may be called from ISR context.

modem_pipe_notify_closed() must be called from outside of
the ISR context as it takes a mutex.

The commit also adds a missing break to the async UART
callback, and adds a missing dependency to the Kconfig
for the UART backends, RING_BUFFER=y

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Modem backed configs should be used instead of uart.

Signed-off-by: Wojciech Slenska <[email protected]>
This commit adds support for partial matches for the modem_chat
module. A match is a combination of an expected response to a
request along with delimiters to use and a handler for the
parsed response.

The usual behavior of the modem_chat script is to continue to
the next step when any expected response is received. The partial
flag indicates that the script should not proceed to the next
step if the response matches the match. This is useful for
commands which respond with an unspecified number of lines,
followed by an "OK". This flag allows the script to essentially
run in a "while" loop until OK is received.

Along with this addition, a more scalable macro for initializing
the modem_chat match struct, MODEM_CHAT_MATCH_INITIALIZER().
Without this macro, we will need 4 different macros to initialize
the 4 variants of a chat_match, and 8 when the next feature is
added...

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This PR makes the modem_pipe instances track if they have
data ready to receive, and invoke the RECEIVE_READY event
every time they are attached if the backend implementing
the pipe has notified that receive is ready.

This mechanism ensures that modules attaching to a pipe
get the async RECEIVE_READY event immediately after
attaching to a pipe if there is data ready, instead of
having to poll the pipe, or worse, wait until newer data
becomes available.

The addition revealed a timing issue in the cmux test
suite. Specifically the CMUX instance now immediately
receives the response to a command which the CMUX
instance has not sent yet, causing it to drop the
response.

The CMUX test suite now uses the transaction
mechanism of the mock_pipe to wait for the command
before sending the response.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Added ppp net stats to modem subsys.

Signed-off-by: Wojciech Slenska <[email protected]>
This commit adds one new feature, modem_chat_run_script(),
which synchronously runs a script.

The existing function modem_chat_script_run() is async,
and doesn't follow the naming convention created for the
other modem modules, specifically, all functions are sync,
unless appended with _async.

To preserve backwards compatibility, the existing function
modem_chat_script_run() will remain until deprecated. It
simply calls modem_chat_run_script_async().

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit updates the modem_cellular driver to use the
new naming scheme for the modem_chat functions.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit optimizes the performance of the script chats by
storing the size of requests with the chat script chat, negating
the need to use strlen() within the modem_chat module every time
a chat script chat request is sent.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This PR adds a mechanism to avoid calling open() or close()
on pipes which are already opened or closed respectively.

This optimization can help simplify backends implementing
the modem_pipe API by avoiding duplicated boilerplate code.

The TTY backend test suite has been updated to match the
new behavior.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit adds a timeout of 300ms to the generic (gsm_ppp) init
chat script. This delay is required for some modems (discovered on
a Telit ME910G1-WW) to allow it to enter CMUX mode. Without this
delay, the modem simply refuses to respond to any CMUX commands.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit sets the C/R (command/response) bit when UIH
CMUX frames are sent from the modem_cmux module. This bit
is ignored by some modems like the Quectel BG95, as there
is no defined response to this specific CMUX frame type.
However, other modems, like the TELIT ME910, require the
bit to be set (command). If the bit is not set, the modem
will simply ignore the frame completely.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit increases the buffer used for commands
in the control channel within an instance of the
modem_cmux module. The buffer was not large enough to
store an MSC command if the optional break signals
where included. This commit fixes the issue and
updates the test suite to use the max size MSC message.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit adjust the chat scripts for the simcom
sim7080 and gsm_ppp compatibles to fix an issue found
when trying to use a sim7080 modem. The CMUX command
includes optional parameters which are not identical
for all modems, so the AT+CMUX command has been adjusted
to only contain the mandatory parameters.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
There is no fallthrough statement or comment so I assume break is
missing.

Fixes build time warning from some tools.

Signed-off-by: Andrei Emeltchenko <[email protected]>
This commit adds a check to the async connect and disconnect
functions to validate the CMUX is not already connected
or disconnected respectively. This was already part of the
sync connect and disconnect functions, so the sync functions
now simply wrap the async functions to avoid duplicate code.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit resets the CMUX events to match the
initial value of disconnected.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit replaces the k_event_wait calls using K_NO_WAIT
with k_event_test.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit resets the receive ring buffer for each DLCI
pipe when they are opened. They may have old data stored
from last time they where opened.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit adds logging for CMUX frames and commands and
their data, for both transmit and receive. It also removes
the superseded LOG_DBG() lines like "Received frame".

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit resets the state of the CMUX receive state
machine when the CMUX instance is attached to a pipe.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit reuses the string "Unknown %s frame type" for two
log messages, as suggested by ycsin.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Fix fault on modem_cellular disconnection/reconnection
Issue #64291

Signed-off-by: romain pelletant <[email protected]>
Refactor device macro to be custom for each modem
to allow custom configurations.

Signed-off-by: Jeff Welder <[email protected]>
Added chat script and initial config to support Telit ME910G1.
Needed to edit power_pulse pin timing in accordance to datasheet.

Signed-off-by: Jeff Welder <[email protected]>
The modem subsystem is novel and should therefore be marked
experimental.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
The init scripts need a missing wait for OK after sending
AT+CGMM and the AT+CMUX command specifies more parameters
than nessesary, and in some cases incorrectly.

This commit adds the missing wait for OK and fixes the AT+CMUX
commands in the init scripts.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
This commit introduces support for the modem EG25-G from Quectel.

Signed-off-by: Lucas Denefle <[email protected]>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello @ldenefle, and thank you very much for your first pull request to the Zephyr project!

A project maintainer just triggered our CI pipeline to run it against your PR and ensure it's compliant and doesn't cause any issues. You might want to take this opportunity to review the project's Contributor Expectations and make any updates to your pull request if necessary. 😊

anangl and others added 6 commits November 23, 2023 15:46
The way that the QSPI peripheral is activated has been changed in
nrfx 3.2.0. Now the peripheral is not activated during the driver
initialization. Instead, the driver activates the peripheral when
the first operation is requested or when `nrfx_qspi_activate()` is
called. In case of XIP, the latter needs to be used, as there may
be no standard operation request.

Signed-off-by: Andrzej Głąbek <[email protected]>
After entering the Deep Power-down mode, some flash chips ignore all
commands except from the one that releases the chip from the DP mode
and it is not possible to successfully read their Status Register then.
Since the QSPI peripheral tries to read this register when it is being
activated, it consequently fails to send the actual command that would
release the flash chip from the DP mode if that is to be done right
after QSPI initialization.
Prevent this problem by performing the QSPI activation with all pins
disconnected. This causes that the Status Register value is read as
all zeros and allows the activation to always finish successfully,
and the RDPD command to be properly sent.

Signed-off-by: Andrzej Głąbek <[email protected]>
Consistently use `res` for results of calls to nrfx functions
and `rc` for Zephyr return codes, to avoid mixing up those two
and for example calling `qspi_get_zephyr_ret_code()` for a value
that is already a Zephyr return code. Correct also such call in
`qspi_nor_write()`.

Signed-off-by: Andrzej Głąbek <[email protected]>
After integration of nrfx 3.2.0, it is no longer needed to deinitialize
the nrfx_qspi driver to avoid increased power consumption when the QSPI
peripheral is idle. Now it is enough to call `nrfx_qspi_dectivate()`
when a given operation is done. The driver will automatically activate
the QSPI peripheral again when a next operation is requested.

This commit applies the following changes:
- `qspi_device_init` and `qspi_device_uninit` functions are replaced
  by `qspi_acquire` and `qspi_release`, respectively; those handle
  exclusive access to the QSPI peripheral and deactivation of it or
  runtime device power management
- locking is removed from `qspi_send_cmd` as it is the resposibility
  of the caller of that function
- `trans_lock` and `trans_unlock` functions are removed together with
  the related semaphore as they are no longer needed
- checking of input parameters is moved from `qspi_erase` to its
  caller, `qspi_nor_erase`
- `qspi_nor_pm_action` is refactored to properly handle locking of
  the QSPI peripheral; checking of the `xip_enabled` flag is removed
  from that function as now the call to `pm_device_is_busy()` covers
  that (when XIP is enabled, the device is kept indicated as busy)

Signed-off-by: Andrzej Głąbek <[email protected]>
So far the driver first changed the configuration of the flash chip
and after that checked the signature of that chip. This could lead
to improper change of the chip configuration if the actually found
one was different than that specified in devicetree.
This commit reverses the order of these two initialization steps and
also restructures a bit the initialization code.

Signed-off-by: Andrzej Głąbek <[email protected]>
@ldenefle ldenefle force-pushed the main branch 2 times, most recently from 6c5b388 to 8fb601a Compare August 1, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants