mcuboot
mcuboot copied to clipboard
Mbed-OS: Prevent use of BlockDevice with unreliable erase value
The default return value of BlockDevice::get_erase_value is -1. When implicitly cast from an int to a uint8_t, this gets truncated to 0xFF, which is normally a reasonable erase value.
However, the intent of the Mbed-OS BlockDevice API is that an integer value of -1 is to be interpreted as an "unreliable" erase value. ie: the underlying BlockDevice does not have a known erase value.
If a user attempts to use such a BlockDevice (eg: SDBlockDevice at the moment, see ARMmbed/mbed-os#15070), they may encounter hard to debug errors.
Since MCUboot expects some fields to be the "erased value" under certain boot/swap states, a BlockDevice with an unreliable erase value is not compatible with MCUboot. It is recommended that the user wrap the incompatible BlockDevice in a FlashSimBlockDevice to provide a known erase value.
This commit adds an assert that will (hopefully) catch such an error during development.
Signed-off-by: George Beckstein [email protected]
@LDong-Arm @boraozgen
Updated the comments to recommend use of the FlashSimBlockDevice to ensure a known erase value and enable compatibility with MCUboot.
See ARMmbed/mbed-os#15071
The failed mynewt test should pass after re-pushing. The certificate issue has been resolved. Rebasing will bring in a change that ignores the certificate, though.
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.
Is there still interest in getting this merged?
Unfortunately I no longer contribute to Mbed-OS, so someone else will have to push this along.
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.