Skip to content

SPIF: fixed _address_size to always initialize as 3_BYTES in ::init() #14909

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

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

ndrs-pst
Copy link
Contributor

@ndrs-pst ndrs-pst commented Jul 10, 2021

Summary of changes

Fixed _address_size attribute in blockdevice::COMPONENT_SPIF when using with device that has size bigger than 16 MiB. (e.g. 32 MiB)

In this scenario, during SPIFBlockDevice::init() _address_size will be set to SPIF_ADDR_SIZE_4_BYTES after enumerated by SFDP command. Then calling to deinit() will not restore _address_size back to initial value SPIF_ADDR_SIZE_3_BYTES again.

Result that the following calling sequence will be failed on the 2nd init()
static SPIFBlockDevice spif_bd;
rc = spif_bd.init(); // rc : SPIF_BD_ERROR_OK
rc = spif_bd.deinit(); // rc : SPIF_BD_ERROR_OK
rc = spif_bd.init(); // rc : SPIF_BD_ERROR_PARSING_FAILED

Impact of changes

Migration actions required

Documentation

None


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Jul 10, 2021
@ciarmcom ciarmcom requested a review from a team July 10, 2021 16:00
@ciarmcom
Copy link
Member

@ndrs-pst, thank you for your changes.
@ARMmbed/mbed-os-maintainers please review.

@0xc0170 0xc0170 requested a review from a team July 12, 2021 15:17
@ciarmcom ciarmcom added the stale Stale Pull Request label Jul 14, 2021
@ciarmcom
Copy link
Member

This pull request has automatically been marked as stale because it has had no recent activity. @ARMmbed/mbed-os-maintainers, @ARMmbed/mbed-os-core, please complete review of the changes to move the PR forward. Thank you for your contributions.

Copy link
Contributor

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

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

@ndrs-pst Thanks for the fix. It looks like we always need to start with 3-byte until 4-byte addressing is enabled in _sfdp_detect_and_enable_4byte_addressing(). This change looks good to me.

Given that 3-byte addressing is the "initial state", what about moving _address_size = QSPI_CFG_ADDR_SIZE_24 from constructors into ::init() to start this way every time, rather than using deinit() to change it back?

@ndrs-pst
Copy link
Contributor Author

ndrs-pst commented Jul 16, 2021

@LDong-Arm That's also OK too.
By the way I just realized that the implementation on detect and enable 4 bytes between SPIF vs (QSPIF/OSPIF) are different as follows
SPIF : relying on _address_size value so affect by this fixed.
QSPIF/OSPIF : hard code to use QSPI_CFG_ADDR_SIZE_24 during read SFDP so not affect by this fixed.

@ciarmcom ciarmcom removed the stale Stale Pull Request label Jul 16, 2021
@LDong-Arm
Copy link
Contributor

LDong-Arm commented Jul 16, 2021

@LDong-Arm That's also OK too.
By the way I just realized that the implementation on detect and enable 4 bytes between SPIF vs (QSPIF/OSPIF) are different as follows
SPIF : relying on _address_size value so affect by this fixed.
QSPIF/OSPIF : hard code to use QSPI_CFG_ADDR_SIZE_24 during read SFDP so not affect by this fixed.

If we can use the constant QSPI_CFG_ADDR_SIZE_24 for operations that only support 3-byte and _address_size elsewhere, that would be better. But this requires some testing. Always starting with 3-byte is a relatively safe approach.

What target and what type of storage are you using?

@ndrs-pst
Copy link
Contributor Author

@LDong-Arm Your approach would be safer then.
About your question :
We are using W25R256JWEIQ (1.8V), W25R256JVEIQ (3.3V) 256 Mb NOR Flash from Winbond via SPIF in our custom target (STM32F411CE).
So it would be limit to test QSPIF (4-bytes addressing) for now.

@LDong-Arm
Copy link
Contributor

LDong-Arm commented Jul 19, 2021

@LDong-Arm Your approach would be safer then.
About your question :
We are using W25R256JWEIQ (1.8V), W25R256JVEIQ (3.3V) 256 Mb NOR Flash from Winbond via SPIF in our custom target (STM32F411CE).
So it would be limit to test QSPIF (4-bytes addressing) for now.

Thanks for the info. Could you please either make the suggested change (set _address_size in init()), or use the constant QSPI_CFG_ADDR_SIZE_24 in SPIF (which you can test) in a similar way to QSPIF/OSPIF if it works and update the PR? Thanks in advance.

Copy link
Contributor

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

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

(Requesting change)

@mergify mergify bot dismissed LDong-Arm’s stale review July 19, 2021 09:48

Pull request has been modified.

@ndrs-pst
Copy link
Contributor Author

@LDong-Arm Just push more commit, please review. 😃
🚀 🗼

@LDong-Arm
Copy link
Contributor

@LDong-Arm Just push more commit, please review. 😃
🚀 🗼

Thanks @ndrs-pst, it looks good now. Could you squash the two commits, and make sure QSPIF/OSPIF are not touched (currently just an empty line is removed from each) so only SPIF is changed? Also the PR description can be updated to include SPIF only.

@ndrs-pst ndrs-pst changed the title xSPIF: fixed _address_size restore back to 3_BYTES/SIZE_24 in deinit() SPIF: fixed _address_size to always initialize as 3_BYTES in ::init() Jul 19, 2021
@ndrs-pst
Copy link
Contributor Author

@LDong-Arm Just squash the commit and change PR comment

Copy link
Contributor

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot added needs: CI and removed needs: work labels Jul 19, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Jul 19, 2021

CI started

@mbed-ci
Copy link

mbed-ci commented Jul 19, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit 11439bf into ARMmbed:master Jul 20, 2021
@mergify mergify bot removed the ready for merge label Jul 20, 2021
@mbedmain mbedmain added release-version: 6.14.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants