Hi, We are using the FTL driver over a MTD device (flash memory at45db641e). When we write something to flash, eventually the ftl_flush function is called and it does an erase (MTD_ERASE) and then the write (MTD_BWRITE). But in the at45db driver (at45db.c) the write uses command 0x82 ("Main Memory Page Program through Buffer 1 with Built-In Erase") that also performs a built-in erase before the write. In summary, each time we write to flash, the page is erased twice before it is written, first in the FTL driver and then in the MTD driver.
The at45db device has another command that doesn't include the built-in erase prior to the write: "Main Memory Byte/Page Program through Buffer 1 without Built-In Erase" (0x02) that is not present in the current version of the driver. Several questions here: 1. Is it expected that a write to a flash MTD device can fail without erasing? In this case, the responsibility for erasing the page belongs to upper layers and the MTD driver doesn't have to perform the erase before the write (-> move to use command 0x02 instead of the one currently used, 0x82). 2. If there are use cases where the MTD driver needs to ensure that the page is erased before writing, there should be a KConfig to disable that and allow the user to choose whether the pre-erase is performed or not to prevent these double erasing scenarios. We have to fix this and we would like to do it in a way that can be pushed upstream. Any thoughts are welcome! Thanks Javier Casas MarĂn Geotab Senior Embedded Systems Developer Direct Toll-free Visit +34 900 535 371 www.geotab.com/es Twitter <https://twitter.com/geotab> | Facebook <https://www.facebook.com/Geotab> | YouTube <https://www.youtube.com/user/MyGeotab> | LinkedIn <https://www.linkedin.com/company/geotab/>