[U-Boot] [PATCH 07/13] fastboot: Implement NAND backend

Boris Brezillon
2015-09-10T07:41:51Z

Hi Maxime,

On Mon, 31 Aug 2015 16:46:07 +0200
Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> So far the fastboot code was only supporting MMC-backed devices for its
> flashing operations (flash and erase).
>
> Add a storage backend for NAND-backed devices.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---

[...]

> +
> +static int _fb_nand_write(nand_info_t *nand, struct part_info *part,
> + void *buffer, unsigned int offset,
> + unsigned int length)
> +{
> + int flags = WITH_WR_VERIFY;
> + int ret;
> +
> +#ifdef CONFIG_FASTBOOT_FLASH_NAND_TRIMFFS
> + flags |= WITH_DROP_FFS;
> +#endif
> + ret = nand_write_skip_bad(nand, offset, &length, NULL,
> + part->size - (offset - part->offset),
> + buffer, flags);

Hm, you seem to ignore skipped blocks here (the 'actual' parameter is
NULL), which means you won't adapt the offset accordingly and will
likely override some data if you appear to have bad blocks in the
section you're writing with the sparse method.

> +
> + if (ret)
> + return ret;
> +
> + return ret;
> +}
> +
> +static unsigned int fb_nand_sparse_write(struct sparse_storage *storage,
> + void *priv,
> + unsigned int offset,

Maybe you should pass a pointer here, so that you can properly update it
with the number of skipped blocks (the same goes for the _fb_nand_write
function).

Best Regards,

Boris

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering