general_block_device test: support non-uniform erase sizes #13552
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:mbed-os/storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp
Lines 493 to 497 in 54f0f56
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 useget_erase_size(addr)
instead:test_program_read_small_data_sizes
uses one sector only, so we simply get the size of that particular sector.basic_erase_program_read_test()
, we only need to make sure it's large enough for the largest sector. Thenbasic_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
Test results
Reviewers
@miteshdedhia7, @ARMmbed/mbed-os-storage, @ARMmbed/mbed-os-core