-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
stm32: QSPI flash driver concurrent access issue #38548
Comments
@hjuul could you please detail if there is specific target board, shield and appli that your are using to show this error ? |
@FRASTM I'm using a custom board based on stm32f777 with QSPI flash MT25QL256ABA. Some more details on Discord: https://discord.com/channels/720317445772017664/887588796839903242/887588800635748352 |
@hjuul Having a new look to this. So maybe I was missing coffee when I initially answered to you but The reason why you're seeing issue is hence not as obvious as initially thought. Would you mind enabling DBG logs and see what shows up ? |
I spent some time debugging this, but haven't found the root cause yet. Enabling DBG logs wasn't feasible because it increases the number of qspi writes, which in turn increases the number of logs, and so on. A few observations:
Side note: In |
In HAL_QSPI_Command_IT, the BUSY flag is checked until sw timeout, but do you see the (HW) Timeout flag (TOF) set in the status register QUADSPI_SR |
@FRASTM , When the failure has occurred, |
For the moment I do not see this error on my sample application. I am Sharing few ideas based on the AN4760 |
With log, the failure could appear more clearly in
|
@FRASTM , from the log output of my original post you can see that I will try with the additional abort tomorrow. But even if that fixes the symptom, isn't it a problem that I get an error in the first place? |
@FRASTM I tried your patch, and also applied it in
|
In the flash_stm32_qspi.c, two callback functions are not defined
|
@FRASTM, I applied your latest patch but I'm still able to reproduce my issue. From my trace it seems Btw your patch has a side effect. At boot I now get the following error: |
@hjuul would it be possible to have the part of your application or a simple change to apply on the existing samples/drivers/spi_flash that could reproduce the pb you see. |
@FRASTM, I'm afraid I don't have time to work with this at the moment, but I'll continue to look into this later. |
PR #39570 to add qspi callback functions for stm32 driver |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Hi, I'm reopening this issue. In the original post I was seeing this issue when using LittleFS logging backend with the file system on QSPI flash. Since I couldn't make it work I disabled that feature. Now I'm using NVS with a storage partition in QSPI flash, and I'm seeing the exact same issue. I'm not using the QSPI flash for anything else, so I no longer believe this is an issue of concurrent access to the QSPI flash. As before, the failure happens rarely, but when it does occur I can not use the QSPI flash again until I do a system reset. I believe there are several issues here:
Issues 2) and 3) could probably be solved quite easily. I've attached a trace view of the last NVS read before the failure occurs. The relevant functions context are shown in red bars, the QSPI ISR is the yellow bar. This looks as expected (to me at least), and notice that I'd really appreciate any suggestions on this; both on why this failure happens in the first place, and how to recover gracefully from such a failure. I'll gladly provide more data if needed, and I'm working to try to reproduce this on a disco board. |
@FRASTM, could you please reopen this issue? |
I've been looking into this for the past week now. I still don't know what is causing it, but I've got some more information.
With this patch, sometimes I see that a QSPI interrupt is triggered 212us after I am able to work around this by checking the BUSY bit at the start of
If you have any idea what could be causing this extra interrupt after the read procedure is done, or have suggestions on how I can debug this further, please let me know. |
Depending on which interrupts are set, among Did you had a look at the the Errata sheet ? |
I've gone through the erratas but nothing there seems to apply to my case. |
I'm closing this issue. It turned out to be not related to QSPI flash driver. Thanks anyway for looking into this, and sorry for the inconvenience. |
@erwango: For debug purpose, no. This was a particularly difficult issue to resolve, so I had to instrument the driver and the HAL for visual trace anyway. And it is very easy to add those callback functions for abort and FIFO threshold when needed, so I don't think they need to be in there if they don't serve a purpose. I do have some other notes though:
|
@hjuul Thanks for this feedback, we'll keep that in mind for the next time we update this driver. One note: You mention DMA as not supported, but I do think it is. You 'just' need to add proper 'dmas' property. zephyr/boards/arm/disco_l475_iot1/disco_l475_iot1.dts Lines 261 to 268 in 63a109e
Or I am missing something ? |
@erwango Looks like you're right. I didn't use DMA though. |
Another update, because I think someone else will run into a similar problem later: The root cause of this seems to be speculative access on ARM Cortex-M7. The Cortex-M7 may occasionally do speculative reads to any memory that is configured as Normal memory type. By default this includes the address space for the memory mapped QUADSPI. Note! This happens even when the QUADSPI is not configured in memory mapped mode! The solution is to configure the MPU such that the entire map-able address space for the QUADSPI is set to Strongly Ordered memory. Some more information on that here: |
Describe the bug
Reading or writing from/to QSPI flash from different contexts doesn't work.
flash_stm32_qspi.c
seems to not be thread safe by design.Impact
File system API doesn't handle concurrency either, so it is left to the application.
But in my application there are several subsystems that also access the QSPI driver (logging with fs backend, settings API, fcb) so handling concurrency in the application is nontrivial.
Logs and console output
This is what happens when I try to read log files through the file system API while the logging thread is running:
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: