On Fri, 21 Mar 2025 at 12:47, Javier Casas Marin <javierca...@geotab.com.invalid> wrote:
> 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). > The problem is your chip and not the driver :) The at45db driver was written for the AT45DB161D. Opcode 82H = Main Memory Page Program Through Buffer 1 For your chip (at45db641e) Opcode 82H = Main Memory Page Program through Buffer 1 with Built-In Erase Opcode 02H = Main Memory Byte/Page Program through Buffer 1 without Built-In Erase