[PATCH v2 2/6] mtd: spi-nor: add erase die (chip) capability

Tudor Ambarus tudor.ambarus at linaro.org
Fri Nov 3 04:47:40 PDT 2023



On 11/2/23 21:42, Fabio Estevam wrote:
> On 02/11/2023 15:56, Tudor Ambarus wrote:
> 
>> Let's try something else:
>> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
>> index 5584bf9cbfd1..a0af7a7eb727 100644
>> --- a/drivers/mtd/spi-nor/core.c
>> +++ b/drivers/mtd/spi-nor/core.c
>> @@ -1074,7 +1074,7 @@ static int spi_nor_erase_die(struct spi_nor *nor,
>> loff_t addr, size_t die_size)
>>
>>         if (nor->spimem) {
>>                 struct spi_mem_op op =
>> -                      
>> SPI_NOR_DIE_ERASE_OP(nor->params->die_erase_opcode,
>> +                       SPI_NOR_DIE_ERASE_OP(nor->erase_opcode,
>>                                              nor->addr_nbytes, addr,
>> multi_die);
>>
>>                 spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
>>
>> I expect that with this the first sector from each die will be erased.
> 
> You are right. This is exactly what happens with this change:
> 
> First die:
> 
> ~# hexdump  /dev/mtd0
> 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
> *
> 0010000 9231 efb8 d664 d77b 231c 3522 d7e8 4f6e
> 
> Second die:
> 
> ~# hexdump -s 0x4000000 /dev/mtd0
> 4000000 ffff ffff ffff ffff ffff ffff ffff ffff
> *
> 4010000 0418 0518 60a0 9214 2411 2004 c144 9e2b


I think I know what happens with your flash. Please try the debug patch
from https://github.com/ambarus/linux-0day.git
spi-nor/next-die-erase-v2-debug.

I assume your flash works in 3-byte mode. The die erase cmd needs an
extended register in 3-byte mode otherwise is ignored. Please try the
patch and let me know if it works.

Reading the datasheet I found out that
"The device supports 3-byte addressing (default), with A[23:0] input
during address cycle. After any READ command is executed, the device
will output data from the selected address. After the boundary is
reached, the device will start reading again from the beginning."

So I expect up to now we tested just the first die, all tests in 3-byte
mode. Thus when we wanted to do a cross-die test, reading from the last
2 MB of first die to the first 2MB of the second die, what we actually
did was to read the last and the first 2MB of the first die.

Cheers,
ta



More information about the linux-mtd mailing list