[U-Boot] [PATCH] fw_env: add NAND support
Markus Klotzbücher
mk at denx.de
Wed Sep 3 13:51:50 CEST 2008
Dear Guennadi,
On Tue, Sep 02, 2008 at 07:05:29PM +0200, Guennadi Liakhovetski wrote:
> +static int flash_flag_obsolete (int dev, int fd, off_t offset)
> +{
> + struct mtd_info_user mtdinfo;
> + int rc;
> +
> + rc = ioctl (fd, MEMGETINFO, &mtdinfo);
> + if (rc < 0) {
> + perror ("Cannot get MTD information");
> + return -1;
> + }
> +
> + if (mtdinfo.type == MTD_NANDFLASH) {
> + /*
> + * No luck on NAND - we could save the erase, but have to write
> + * a whole erase block anyway
> + */
> + rc = __flash_write_buf (dev, fd, &obsolete_flag,
> + sizeof (obsolete_flag), offset,
> + &mtdinfo);
Hmmm, what exactly are you doing here? IIRC environment in NAND was
implemented slightly differently than NOR in that it reused the
obsolete flag as a serial number. This number is incremented for every
write so the env with the higher number is always the current one
(besides the corner case where the number overflows, see
env_nand.c). This way the obsoleting can be completly avoided.
I can't see this in your patch?
Best regards
Markus
P.S.: As mentioned before this mechanism of course could save the
"obsoleting" operation in NOR too...
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de")
More information about the U-Boot
mailing list