-
I've tested spi on the NXP RW612 in both sync and async mode, which did not give the expected results. When I use spi_transceive_cb I see that the the given callback is executed prior to the return of the function The board uses this driver: spi_mcux_flexcomm.c I've used Percepio TraceAlyzer to trace this: Asynchronous: callback executed prior to the return point of spi_transceive_cb In the screenshots I've also tried to measure the absolute timings, however due to the overhead of tracing itself this can be misleading. The actual data being sent out is the string This has been tested on 4.0.0 as well as the current main, i.e. commit 4bb5ffd, both with zephyr sdk 0.17.0 on Linux/Ubuntu. This is my test code:
With the following
Is this indeed a bug, or do I have the wrong expectation of |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 6 replies
-
Hi @badevos! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
Beta Was this translation helpful? Give feedback.
-
I've analyzed some code myself and found this part in the driver:
I tested my code without this check, and this has no effect. |
Beta Was this translation helpful? Give feedback.
-
Hi @dleach02, I see you gave this a low priority. Can you confirm that my reasoning is correct, and |
Beta Was this translation helpful? Give feedback.
-
Sorry, this is a Zephyr Project rating and not an internal NXP rating. Zephyr Project tends to put issues that only affect one platform as low priority. We have pulled the details of your ticket into our internal tracking system and reviewing it. |
Beta Was this translation helpful? Give feedback.
-
Hi @badevos , To test this, I ran the spi_loopback test on the FRDM-RW612 board using Zephyr v4.1. For this test to pass, the MOSI and MISO signals must be shorted externally, by shorting header J1 pins 2 and 4. This test also tests Async mode, and I enabled DMA to match your use-case. The spi_loopback test calls I modified the spi_loopback test with the attached patch spi_loopback-spi_transceive_cb.txt to use Below is a screenshot from the callstack when the callback Since this does not appear to be a bug or an issue with the driver, I am converting this to a Discussion. If you have further questions, we can discuss further in that Discussion. Best regards |
Beta Was this translation helpful? Give feedback.
-
Whether Anyhow we need a solution as our application requires quite some functionality in ISR context as well, including the launch of an SPI transfer. Would it be possible to reconsider this given the fact that our application uses 'single' transfers only. I mean:
The argument I understand that it would be a short-cut, but it will drastically improve the performance (given single transfers) of the system, which will be appreciated by everyone. Can this be implemented please? |
Beta Was this translation helpful? Give feedback.
-
Alternatively we can consider using RTIO |
Beta Was this translation helpful? Give feedback.
This isn't at all guaranteed to be asynchronous, and the updated docs reflect this reality. The way it was implemented unfortunately still requires serializing access to the spi bus through a semaphore. The call may block while ongoing transfers from other threads are taking place. It may very likely return after the callback takes place as well... making it difficult to chain SPI requests together in a callback driven state …