[U-Boot] [PATCH 1/1] mtd: nand-base: fix bug writing 1 byte less than page size
Hector Palacios
hector.palacios at digi.com
Mon Jul 18 09:39:09 CEST 2016
On 07/18/2016 09:18 AM, Hector Palacios wrote:
> nand_do_write_ops() determines if it is writing a partial page with the
> formula:
> if (column || (writelen < mtd->writesize - 1))
>
> When 'writelen' is exactly 1 byte less than the NAND page size the formula
> equates to zero, so the code doesn't process it as a partial write, although
> it should.
> As a consequence the function remains in the while(1) loop with 'writelen'
> becoming 0xffffffff and iterating until the watchdog timeout triggers.
>
> To reproduce the issue on a NAND with 2K page (0x800):
> => nand erase.part <partition>
> => nand write $loadaddr <partition> 7ff
>
> Signed-off-by: Hector Palacios <hector.palacios at digi.com>
>
> https://jira.digi.com/browse/DUB-619
> ---
> drivers/mtd/nand/nand_base.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index c0e381ad2d15..cb15bb21e2f0 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2524,7 +2524,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
>
> WATCHDOG_RESET();
> /* Partial page write? */
> - if (unlikely(column || writelen < (mtd->writesize - 1))) {
> + if (unlikely(column || writelen < mtd->writesize)) {
> cached = 0;
> bytes = min_t(int, bytes - column, (int) writelen);
> chip->pagebuf = -1;
>
Please disregard. This patch was generated over U-Boot v2015.04.
I sent a corrected v2 patch.
--
Hector Palacios
More information about the U-Boot
mailing list