-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add overloaded get_erase_size API with address parameter to BlockDevice #6408
Add overloaded get_erase_size API with address parameter to BlockDevice #6408
Conversation
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.
LGTM!
@AnotherButler, if you would like to take a quick look. Small doc updates. |
@geky if you could take a look at the API addition. Imo, looks straightforward. |
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.
I'm for it, though unfortunately the slicing/chaining block devices need some changes.
features/filesystem/bd/BlockDevice.h
Outdated
* | ||
* @return Size of a eraseable block in bytes | ||
* @return Size of an eraseable block in bytes |
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.
Ah, that's what I get for using search/replace on english...
{ | ||
return _erase_size; | ||
} | ||
|
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.
Oh, unfortunately this implementation is going to be much more complicated. We need to lookup the erase size for the block inside the list of block devices.
@@ -102,6 +102,11 @@ bd_size_t SlicingBlockDevice::get_erase_size() const | |||
return _bd->get_erase_size(); | |||
} | |||
|
|||
bd_size_t SlicingBlockDevice::get_erase_size(bd_addr_t addr) const | |||
{ | |||
return _bd->get_erase_size(addr); |
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.
This needs to have the _start
offset added to addr before passing addr down
@@ -276,6 +276,11 @@ bd_size_t MBRBlockDevice::get_erase_size() const | |||
return _bd->get_erase_size(); | |||
} | |||
|
|||
bd_size_t MBRBlockDevice::get_erase_size(bd_addr_t addr) const | |||
{ | |||
return _bd->get_erase_size(addr); |
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.
This also needs to add _offset
to addr.
257740a
to
487dc28
Compare
@geky Thanks for the comments. Pushed a fix. Please observe the changes (mainly the one in ChainingBlockDevice.cpp). |
Pinging @geky for a re-review. Also, possibly @deepikabhavnani. Primarily wondering if ChainingBlockDevice is the only block device that needed non-trivial changes/updates. |
@cmonr I believe it is. As: |
MBED_ASSERT(0); | ||
return 0; // satisfy compiler | ||
} | ||
|
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.
Yeah, this looks good 👍
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.
Nothing to block this PR: Just queries for my understanding
- I see
_bd_count(sizeof(bds) / sizeof(bds[0])
set during constructor, does this mean we erase all chain blocks in erase operation?
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.
An erase can cross multiple block devices in the chain.
Here's where it's implemented:
https://github.com/davidsaada/mbed-os/blob/a6048005d7c7ee06b7956918589d381a9f41f159/features/filesystem/bd/ChainingBlockDevice.cpp#L174-L194
Please explain this comment, how erase size will vary based on the address |
features/filesystem/bd/BlockDevice.h
Outdated
* @return Size of an erasable block in bytes | ||
* @note Must be a multiple of the program size | ||
*/ | ||
virtual bd_size_t get_erase_size(bd_addr_t addr) const |
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 param in doxygen - addr
@davidsaada Could you squash Amanda's copy edits, and add another commit for Deepika's comments? After that, we should be good to start CI. |
@deepikabhavnani This is relevant in case the block device implements a flash components having different sector sizes (erase size = sector size). In this case, the API cannot return a constant erase size, as it depends on the address. |
58951f5
to
a604800
Compare
Single block device supporting different sector sizes? I don;t think we support that.. @geky Please clarify. |
@deepikabhavnani Indeed, we currently don't have any block device that has variant erase sizes. However, unless we add this API, we'll never be able to implement block devices supporting flash components with variant sector sizes. |
/morph build |
Build : SUCCESSBuild number : 1545 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 1184 |
ಠ_ಠ /morph export-build |
Test : SUCCESSBuild number : 1324 |
Exporter Build : SUCCESSBuild number : 1190 |
@AnotherButler Can you review the latest update? |
@davidsaada Handbook update reference? |
Description
Add an overloaded get_erase_size API with address parameter to BlockDevice and all derived classes.
This is due to the fact that in some flash components, erase size varies depending on address.
Pull request type