Skip to content

Fix sfdp_find_addr_region algorithm #13699

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
Nov 12, 2020

Conversation

boraozgen
Copy link
Contributor

@boraozgen boraozgen commented Oct 2, 2020

Summary of changes

sfdp_find_addr_region() was causing issues with SPI flashes with sector table parsed from SFDP (in particular SST26VF016B).

In particular, it was returning -1 when address 0 is passed (probably also if the address in the first region). I do not know why the search algorithm is written to search from the higher to lower regions, but it was obvious that it would fail for the first region. Also it was harder to read due to the index manipulation.

I tested the new algorithm with SST26VF016B and it returns the correct region for the addresses I provided. Unfortunately I do not have a test setup where I can test multiple flash chips. I guess there are no automated tests for SPIF and SFDP components, maybe it is a good idea to build a CI setup for this.

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

[X] No Tests required for this change (E.g docs only update)
[] 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 Oct 2, 2020
@ciarmcom ciarmcom requested review from a team October 2, 2020 14:00
@ciarmcom
Copy link
Member

ciarmcom commented Oct 2, 2020

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

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Please add details to the commit message (from pull request description)

@boraozgen boraozgen force-pushed the bugfix/sfdp-find-addr-region branch from 0778617 to 40ad5b2 Compare October 16, 2020 08:00
@mergify mergify bot dismissed 0xc0170’s stale review October 16, 2020 08:01

Pull request has been modified.

@boraozgen boraozgen force-pushed the bugfix/sfdp-find-addr-region branch from 40ad5b2 to 730ffe6 Compare October 16, 2020 08:02
0xc0170
0xc0170 previously approved these changes Oct 17, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 17, 2020

CI started

@mergify mergify bot added needs: CI and removed needs: review labels Oct 17, 2020
@mbed-ci
Copy link

mbed-ci commented Oct 17, 2020

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_build-ARM ✔️
jenkins-ci/mbed-os-ci_build-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_dynamic-memory-usage ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️
jenkins-ci/mbed-os-ci_cloud-client-pytest ✔️

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 19, 2020

@ARMmbed/mbed-os-core Please review

evedon
evedon previously requested changes Oct 19, 2020
Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

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

Thank you for the fix.
The issue of the original code was that the last return should have been return 0 instead of return -1. But I agree that it is easier to follow the logic when searching from the lower to the higher regions so let's keep your version.

I think that there are still two issues with the function though:
1- offset type should be bd_addr_t instead of bd_size_t. They both map to uint64_t.
2- The first check should return -1 if offset >= sfdp_info.bptbl.device_size_bytes

@boraozgen
Copy link
Contributor Author

@evedon Thank you for the review. I will add the requested changes asap. It might take a couple of days as I am currently working on something else.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 3, 2020

@evedon Thank you for the review. I will add the requested changes asap. It might take a couple of days as I am currently working on something else.

Any update?

@boraozgen
Copy link
Contributor Author

Sorry for the delay. I added the requested changes.

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.

Thanks @boraozgen, looks good to me

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 3, 2020

@boraozgen Can you rebase (to squash all 3 commits into one) ?

sfdp_find_addr_region() was causing issues with SPI
flashes with sector table parsed from SFDP (in
particular SST26VF016B).

In particular, it was returning -1 when address 0 is
passed (probably also if the address in the first
region). I do not know why the search algorithm is
written to search from the higher to lower regions,
but it was obvious that it would fail for the first
region. Also it was harder to read due to the index
manipulation.
@boraozgen boraozgen force-pushed the bugfix/sfdp-find-addr-region branch from 2a60984 to 7f0716a Compare November 3, 2020 13:23
@boraozgen
Copy link
Contributor Author

@boraozgen Can you rebase (to squash all 3 commits into one) ?

Done.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 3, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Nov 3, 2020

Jenkins CI Test : ❌ FAILED

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

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_dynamic-memory-usage ✔️
jenkins-ci/mbed-os-ci_cloud-client-pytest ✔️
jenkins-ci/mbed-os-ci_greentea-test

@mergify mergify bot added needs: work and removed needs: CI labels Nov 3, 2020
@LDong-Arm
Copy link
Contributor

@0xc0170 Looks like a CI issue:

[1604425454.35][GLRM][ERR] can't allocate resource: 'DISCO_L475VG_IOT01A', reason: Allocation failed: Suitable resources were not available during timeout (1800s), statusCode: 408

@LDong-Arm
Copy link
Contributor

@0xc0170 Would you please rerun CI?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 6, 2020

Yes, will rerun. We are trying to unblock today CMake to master PR (CI was updated and having some hiccups along with some other dependencies related, so until they are green, other PR could be affected).

I'll set this to needs: CI to rerun CI

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 10, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Nov 10, 2020

Jenkins CI Test : ❌ FAILED

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

CLICK for Detailed Summary

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

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 11, 2020

I'll check in a hour, the logs do not have any failures, will check jenkins log and possibly restart needed here (cmake should not fail here).

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 11, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Nov 11, 2020

Jenkins CI Test : ✔️ SUCCESS

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

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_dynamic-memory-usage ✔️
jenkins-ci/mbed-os-ci_cloud-client-pytest ✔️
jenkins-ci/mbed-os-ci_cmake-example-test ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit f333c3e into ARMmbed:master Nov 12, 2020
@mergify mergify bot removed the ready for merge label Nov 12, 2020
@mbedmain mbedmain added release-version: 6.5.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Nov 18, 2020
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.

7 participants