Dear Guennadi Liakhovetski,

In message <[EMAIL PROTECTED]> you wrote:
> This will become more important with NAND support, in which case the minimum
> erase region is a block, which consists of several pages and can be 256KiB
> large.

Please explain.

What does "anywhere" mean? At offset 0, 1, 5, 17 or 42? Or what?  And
what exactly is the "erase area" ?

And where's the difference between NAND and NOR flash? For  NOR,  the
minimum "erase region" is a "block", either, which also can be 256KiB
large.

> +     /*
> +      * Support environment anywhere within erase sectors: read out the
> +      * complete area to be erased, replace the environment image, write
> +      * the whole block back again.
> +      */
> +     if (DEVESIZE (dev_target) > CFG_ENV_SIZE) {
> +             data = malloc (DEVESIZE (dev_target));
> +             if (!data) {
> +                     fprintf (stderr,
> +                              "Cannot malloc %lu bytes: %s\n",
> +                              DEVESIZE (dev_target),
> +                              strerror (errno));
> +                     return -1;
> +             }
> +
> +             rc = ioctl (fd_target, MEMGETINFO, &mtdinfo_target);
> +             if (rc < 0) {
> +                     perror ("Cannot get MTD information");
> +                     return -1;
> +             }
> +
> +             /* Erase sector size is always a power of 2 */
> +             erase_offset = DEVOFFSET (dev_target) &
> +                     ~(mtdinfo_target.erasesize - 1);
> +
> +             rc = flash_read_buf (dev_target, fd_target, data,
> +                                  DEVESIZE (dev_target), erase_offset);
> +             if (rc < 0)
> +                     return rc;
> +
> +             /* Overwrite the old environment */
> +             memcpy(DEVOFFSET (dev_target) - erase_offset + data,
> +                    environment.image, CFG_ENV_SIZE);
> +     } else {
> +             data = (char *)environment.image;
> +             erase_offset = DEVOFFSET (dev_target);
> +     }

You are talking about "several pages" above. Where is this refelected
in the code?


Frankly, I don't understand what you are trying to do. Please explain
your implementation.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [EMAIL PROTECTED]
      Bugs are by far the largest and  most successful class of
      entity, with nearly a million known species. In this res-
      pect they outnumber all the other  known  creatures about
      four to one.  -- Professor Snope's Encyclopedia of Animal
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to