ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.68k stars 2.98k forks source link

`SDBlockDevice::erase` is a no-op, this should be configurable #15070

Closed AGlass0fMilk closed 3 years ago

AGlass0fMilk commented 3 years ago

Description of defect

Currently (and very confusingly), the SDBlockDevice implementation defaults to a "no-op" when calling erase on it. In some cases, the code is expecting a particular value once the device is erased.

I know, I know, the documentation specifically mentions this. I swear it has not always been like this (it's too late and I'm too lazy to go check the git blame). I have been using Mbed-OS and the SDBlockDevice for years... I've never encountered this issue.

Anyways, I think it would be appropriate to provide a configuration option that allows the user to decide if erase is a no-op or not. If not, they must provide an erase value that is then programmed to the SDBlockDevice.

In my case, I'm making a bootloader for the K64F that is built with MCUboot. MCUboot expects certain areas of flash to be their "erased" values, otherwise bad things :TM: happen.

Target(s) affected by this defect ?

All

Toolchain(s) (name and version) displaying this defect ?

arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599] Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

What version of Mbed-os are you using (tag or sha) ?

mbed-os-99.99.99

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Package             Version     Location
------------------- ----------- -----------------------------------------------------------
aenum               3.0.0
appdirs             1.4.3
asn1ate             0.6.0
attrs               19.3.0
Automat             20.2.0
av                  8.0.3
beautifulsoup4      4.6.3
ble-serial          2.0.0
bleak               0.12.1
bluepy              1.3.0
capstone            4.0.2
cbor                1.0.0
certifi             2019.11.28
cffi                1.14.1
chardet             3.0.4
click               7.1
cmsis-pack-manager  0.2.10
cobs                1.1.4
cogapp              3.0.0
colorama            0.3.9
coloredlogs         15.0
constantly          15.1.0
crc16               0.1.1
crccheck            0.6
cryptography        2.9.2
cycler              0.10.0
dataclasses         0.8
dbus-next           0.2.2
distlib             0.3.1
docopt              0.6.2
docutils            0.17.1
ecdsa               0.15
elftools            0.1.0.dev0
ep                  0.0.1       /home/gdbeckstein/Documents/embeddedplanet/ep-app-generator
fasteners           0.15
filelock            3.0.12
Flask               1.1.2
future              0.16.0
futures             3.1.1
fuzzywuzzy          0.18.0
gitdb               4.0.5
GitPython           3.1.13
grip                4.5.2
hidapi              0.9.0.post2
humanfriendly       9.1
hyperlink           20.0.1
icetea              1.2.4
idna                2.7
imgtool             1.7.0rc1
importlib-metadata  1.6.0
importlib-resources 5.1.2
incremental         17.5.0
inflection          0.5.1
iniconfig           1.1.1
intelhex            2.2.1
intervaltree        3.1.0
itsdangerous        1.1.0
Jinja2              2.10.3
jsonmerge           1.7.0
jsonschema          2.6.0
junit-xml           1.8
keyrings.alt        4.0.2
kiwisolver          1.2.0
lockfile            0.12.2
Logbook             1.5.3
Mako                1.1.4
manifest-tool       1.5.2
Markdown            3.3.2
MarkupSafe          1.1.1
matplotlib          3.3.0
mbed-cli            1.10.5
mbed-cloud-sdk      2.0.8
mbed-flasher        0.10.1
mbed-greentea       1.7.4
mbed-host-tests     1.5.10
mbed-ls             1.7.12
mbed-os-tools       0.0.15
mbed-tools          7.1.2
milksnake           0.1.5
monotonic           1.5
naturalsort         1.5.1
numpy               1.19.1
packaging           20.4
path-and-address    2.0.1
pc-ble-driver-py    0.14.2
pdoc3               0.9.2
Pillow              7.2.0
pip                 20.2
pkg-resources       0.0.0
pluggy              0.13.1
prettytable         2.2.0
protobuf            3.5.2.post1
psutil              5.6.6
py                  1.9.0
pyasn1              0.2.3
pycparser           2.20
pycryptodome        3.9.8
pyelftools          0.25
Pygments            2.7.1
PyHamcrest          2.0.2
pylink-square       0.10.1
pyocd               0.31.0
pyocd-pemicro       1.0.6
pyparsing           2.4.7
pypemicro           0.1.7
pyrsistent          0.16.0
pyserial            3.4
pytest              6.1.1
python-can          3.3.4
python-dateutil     2.8.1
python-dotenv       0.14.0
pyudev              0.22.0
pyusb               1.2.1
PyYAML              5.4.1
requests            2.20.1
semver              2.10.2
setuptools          46.1.3
six                 1.16.0
smmap               3.0.5
sortedcontainers    2.4.0
soupsieve           2.0
tabulate            0.8.9
toml                0.10.1
tqdm                4.57.0
trollius            2.1.post2
Twisted             20.3.0
txdbus              1.1.2
typing-extensions   3.7.4.3
urllib3             1.24.2
virtualenv          20.4.3
wcwidth             0.2.5
Werkzeug            1.0.1
wheel               0.34.2
wrapt               1.12.1
yattag              1.13.2
zipp                3.1.0
zope.interface      5.2.0

How is this defect reproduced ?

Use code that relies on a particular erase value with an underlying SDBlockDevice.

AGlass0fMilk commented 3 years ago

Closed because of realizations in #15071 comment thread.