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

drivers: flash: andes_qspi: Fix bug when RX length exceeds 512 bytes and optimize the check for being used as a flash fetch device. #83676

Merged

Conversation

kevinwang821020
Copy link
Collaborator

This PR addresses two main issues.
The first one is fixing a bug that occurs when the flash receives more than 512 bytes of data. The root cause is that ATCSPI hardware only supports a maximum of 512 bytes per transfer. Therefore, if the received data exceeds this limit, the transfer needs to be split into multiple transactions.
The second issue is related to determining whether the SPI is used as a flash fetch device in XIP mode. Being in XIP mode does not necessarily mean that the program is executed from flash. The SPI node is only used as a flash fetch device when the program is actually running from flash. In other cases, the SPI node can still exist.

Kevin Wang added 2 commits January 8, 2025 11:14
ATCSPI hardware limits single transfer to 512 bytes, so when reading
data over 512 bytes, it needs to be split into multiple transfers

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
XIP may indicate that the program is executed either in local memory
or flash. However, the SPI node is only used as a flash fetch device
when the program is executed in flash.
Therefore, optimize the related checks to ensure that when XIP is
enabled but the program is executed in local memory, the qspi flash
node can still be used.

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
@de-nordic
Copy link
Collaborator

@kevinwang821020 Can you log Zephyr bug for what you fix here and link the issue to this fix?

@de-nordic de-nordic added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels Jan 8, 2025
@kevinwang821020
Copy link
Collaborator Author

Hi @de-nordic ,
This bug does not appear in the tests or samples in the Zephyr upstream package (because single read operations do not exceed 512 bytes).
We discovered this issue based on the atcspi200 hardware specifications and verified its existence by local testing.
Therefore, no issue has been filed.

@de-nordic
Copy link
Collaborator

Hi @de-nordic , This bug does not appear in the tests or samples in the Zephyr upstream package (because single read operations do not exceed 512 bytes). We discovered this issue based on the atcspi200 hardware specifications and verified its existence by local testing. Therefore, no issue has been filed.

I am not sure whether I am allowed to insist on reporting the bug, as it is in your platform.

Nevertheless, I think that a role of a bug report, aside from reporting a problem for somebody to fix, is a way to inform users on a problem so that people with similar problems could find information that the issue may not be specific for their setup, and also provide information that the issue is tracked and being addressed.

@kartben What do you think?

Also, In case you would like to backport the issue fix, into previous release, then bug report is needed.

@kevinwang821020
Copy link
Collaborator Author

I think this is a great suggestion. If others feel the same way, I will follow this suggestion and raise an issue (bug).
By the way, I think this issue may not be necessary to backport to previous release. After all, it seems more like an improvement to this flash driver's tolerance for read length limits (even though the limit was rarely encountered).

Copy link
Collaborator

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

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

Looks OK to me.
I will re-assign the bug to representative of Andes to make sure vendor agrees on the change.

@de-nordic de-nordic assigned wtlee1995 and unassigned de-nordic Feb 4, 2025
@wtlee1995
Copy link
Collaborator

Looks good to me.

@de-nordic de-nordic added this to the v4.1.0 milestone Feb 6, 2025
@kartben kartben merged commit c6488fc into zephyrproject-rtos:main Feb 6, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Flash bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants