-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix sfdp_find_addr_region algorithm #13699
Conversation
@boraozgen, thank you for your changes. |
There was a problem hiding this 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)
0778617
to
40ad5b2
Compare
40ad5b2
to
730ffe6
Compare
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@ARMmbed/mbed-os-core Please review |
There was a problem hiding this 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
@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? |
Sorry for the delay. I added the requested changes. |
There was a problem hiding this 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
@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.
2a60984
to
7f0716a
Compare
Done. |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@0xc0170 Looks like a CI issue:
|
@0xc0170 Would you please rerun CI? |
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 |
CI restarted |
Jenkins CI Test : ❌ FAILEDBuild Number: 3 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
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). |
CI restarted |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
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
Test results
Reviewers