Skip to content

general_block_device test: support non-uniform erase sizes #13552

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 2 commits into from
Sep 7, 2020

Conversation

LDong-Arm
Copy link
Contributor

@LDong-Arm LDong-Arm commented Sep 4, 2020

Summary of changes

Fixes: #12575

Several test cases in the general_block_device test assume one erase/sector size exists across the whole flash, which is not always true. BlockDevice::get_erase_size() (no parameter) returns 0 to indicate the lack of a common erase size:

bd_size_t QSPIFBlockDevice::get_erase_size() const
{
// return minimal erase size supported by all regions (0 if none exists)
return _sfdp_info.smptbl.regions_min_common_erase_size;
}

But this doesn't mean the test can't work in such scenarios - in fact it has nearly all the bits and pieces to support non-uniform erase sizes. We just need to refrain from using the vague get_erase_size() but use get_erase_size(addr) instead:

  • test_program_read_small_data_sizes uses one sector only, so we simply get the size of that particular sector.
  • For read/write buffers allocated in preparation for basic_erase_program_read_test(), we only need to make sure it's large enough for the largest sector. Then basic_erase_program_read_test() can already handle variable sector sizes and only use part of our buffer as needed.

Additionally, this PR improves the heap allocation error message for targets with very large sectors (e.g. 256KB) but small RAMs.
Potential improvement for this(?): In my opinion allocating read/write buffers equal to sector size is way too much and doesn't always work as said. Read and write operations are much more fine-grained (one byte to < 1KB), so in principle we can use smaller buffers and break down operations with a loop...

Impact of changes

It should fix flashes that don't have a common erase size across regions, such as CYW9P62S1_43012EVB_01 in #12575 - to be tested.

Migration actions required

None.

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

@miteshdedhia7, @ARMmbed/mbed-os-storage, @ARMmbed/mbed-os-core


…ctor we use

The test case only uses one specific sector, but the erase size
is obtained for the whole block device instead. This doesn't work
if different regions of the flash don't have a common erase size.

Fix the issue by getting the erase size at the address we use.
…ctor

Previously we get the common erase size of the whole flash, which
may or may not exists if there are multiple regions. In this case
the size returned is zero and the test fails.

Fix this by allocating read and write buffers that are large enough
for all sectors. The test itself already supports non-uniform
erase sizes, and the erase size at any address can be smaller
than our buffers.
@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Sep 4, 2020
@ciarmcom
Copy link
Member

ciarmcom commented Sep 4, 2020

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

@ciarmcom ciarmcom requested a review from a team September 4, 2020 16:00
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.

Code change looks good.

It would be useful if @miteshdedhia7 can confirm that this fixes #12575

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

mbed-ci commented Sep 7, 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_greentea-test ✔️

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

Issue with features-storage-tests-blockdevice-general_block_device
6 participants