[riot-notifications] [RIOT-OS/RIOT] mtd: introduce mtd_write_page_hl() (#15843)
notifications at github.com
Sun Jan 24 01:17:57 CET 2021
### Contribution description
The `mtd_write_page()` function will do a 'raw write' to the underlying memory device.
That means for flash based storage, it will only do 1 -> 0 bit writes while 0 -> 1 writes are ignored.
This is the behavior that e.g. SPIFFS expects (used there for 'blind writes').
For some applications a more high level view is required where any bit write pattern should result in the requested data being written to the storage device.
For flash based storage, this means a read - modify - write cycle is necessary where a whole flash sector is copied to RAM, modified, erased and re-written.
This PR introduces the `mtd_write_page_hl()` function that will do just that (or fall back to `mtd_write_page()` if the storage supports direct writes, e.g. in the case of EEPROM).
The work area is allocated dynamically once on start-up. This is done because the sector size may not be known at compile-time (see #15617).
To not waste memory when this functionality is not needed, the new function is hidden behind the `mtd_hl_write` pseudo-module.
To properly test this, this also hooks up the AT24MAC EEPROM found on the `same54-xpro` as a second MTD device and fixes some bugs with the `tests/mtd_raw` test that this brought to surface.
### Testing procedure
`tests/mtd_raw` has been extended with a `write_page_hl` command. The new command has also been integrated into the automated `test` command:
> test 0 # SPI NOR
2021-01-24 01:14:08,361 # test 0
2021-01-24 01:14:08,362 # [START]
2021-01-24 01:14:09,122 # [SUCCESS]
> test 1 # AT24MAC EEPROM
2021-01-24 01:14:10,881 # test 1
2021-01-24 01:14:10,882 # [START]
2021-01-24 01:14:10,929 # [SUCCESS]
### Issues/PRs references
`mtd_write_page_h()l` is a terrible name.
I'd much rather rename `mtd_write_page()` -> `mtd_write_page_raw()`.
But this would be an API change.
Examples: Fixes #1234. See also #5678. Depends on PR #9876.
Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* boards/same54-xpro: expose at24mac as MTD_1
* mtd: add cmd_write_page_hl()
* drivers: add MTD_DRIVER_FLAG_DIRECT_WRITE to mtd drivers
* tests/mtd_raw: include mtd_write_page_hl() in test
* tests/mtd_raw: fix initial size output
* tests/mtd_raw: fix auto-test for memory that erases to 0
-- File Changes --
M boards/same54-xpro/Makefile.dep (1)
M boards/same54-xpro/board.c (13)
M boards/same54-xpro/include/board.h (7)
M drivers/at24cxxx/mtd/mtd.c (3)
M drivers/at25xxx/mtd/mtd.c (1)
M drivers/include/mtd.h (46)
M drivers/mtd/mtd.c (56)
M drivers/mtd_mci/mtd_mci.c (1)
M drivers/mtd_sdcard/mtd_sdcard.c (1)
M makefiles/pseudomodules.inc.mk (1)
M tests/mtd_raw/Makefile (1)
M tests/mtd_raw/main.c (53)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications