<div dir="ltr"><div><div><div><div>Hello<br><br></div>That is very interesting. Do you have a way to automate that?<br><br></div>I am testing ram stuff with coreboot, I don't need to flash a full 8MB image. I could just pass a -i of the cbfs content to only change the ramstage, and do a manual md5 of the various parts contained to only target the difference, but it seems a bit tedious.<br><br></div>It would be nice to do have a way to do kind of diff between the currenttly flashed image and the desired image, and only flash the required changes.<br><br></div>Charlotte<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 8, 2016 at 2:22 PM, David Hendricks via flashrom <span dir="ltr"><<a href="mailto:flashrom@flashrom.org" target="_blank">flashrom@flashrom.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Peter,<br>
Thanks for the patch! However, I suspect this will not be accepted<br>
since the size check is an important safety measure for the general<br>
use case.<br>
<br>
In general layout files should be used for this sort of thing. The way<br>
we've gone about this in the <a href="http://chromium.org" rel="noreferrer" target="_blank">chromium.org</a> branch is to augment the -i<br>
syntax to allow the user to specify a region and corresponding file,<br>
and we also added a "--fast-verify" mode to only verify regions which<br>
were targeted. So for example you could do "flashrom -p <programmer><br>
-l <layout_file> -i region:filename.bin --fast-verify --ignore-fmap<br>
-w" which will write filename.bin to the targeted region and verify<br>
only that region.<br>
<br>
Details here: <a href="https://www.chromium.org/chromium-os/packages/cros-flashrom#TOC-Partial-Reads-and-Writes" rel="noreferrer" target="_blank">https://www.chromium.org/<wbr>chromium-os/packages/cros-<wbr>flashrom#TOC-Partial-Reads-<wbr>and-Writes</a><br>
. LMK if this is any help.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Mon, Nov 7, 2016 at 1:00 PM, Peter Mamonov <<a href="mailto:pmamonov@gmail.com">pmamonov@gmail.com</a>> wrote:<br>
> Flashrom restricts an image size to be equal to a ROM capacity. This is<br>
> inconvenient in case of large and slow ROM chips, when only part of the ROM<br>
> should be updated. This patch removes this restriction in a quick-and-dirty<br>
> manner.<br>
><br>
> Signed-off-by: Peter Mamonov <<a href="mailto:pmamonov@gmail.com">pmamonov@gmail.com</a>><br>
> ---<br>
>  flashrom.c | 26 +++++++++++++++-----------<br>
>  1 file changed, 15 insertions(+), 11 deletions(-)<br>
><br>
> diff --git a/flashrom.c b/flashrom.c<br>
> index d51a44c..f805e00 100644<br>
> --- a/flashrom.c<br>
> +++ b/flashrom.c<br>
> @@ -1255,30 +1255,30 @@ int read_buf_from_file(unsigned char *buf, unsigned long size,<br>
><br>
>         if ((image = fopen(filename, "rb")) == NULL) {<br>
>                 msg_gerr("Error: opening file \"%s\" failed: %s\n", filename, strerror(errno));<br>
> -               return 1;<br>
> +               return -1;<br>
>         }<br>
>         if (fstat(fileno(image), &image_stat) != 0) {<br>
>                 msg_gerr("Error: getting metadata of file \"%s\" failed: %s\n", filename, strerror(errno));<br>
>                 fclose(image);<br>
> -               return 1;<br>
> +               return -1;<br>
>         }<br>
> -       if (image_stat.st_size != size) {<br>
> +       if (image_stat.st_size > size) {<br>
>                 msg_gerr("Error: Image size (%jd B) doesn't match the flash chip's size (%lu B)!\n",<br>
>                          (intmax_t)image_stat.st_size, size);<br>
> -               fclose(image);<br>
> -               return 1;<br>
> +               return -1;<br>
>         }<br>
> +       size = image_stat.st_size;<br>
>         numbytes = fread(buf, 1, size, image);<br>
>         if (fclose(image)) {<br>
>                 msg_gerr("Error: closing file \"%s\" failed: %s\n", filename, strerror(errno));<br>
> -               return 1;<br>
> +               return -1;<br>
>         }<br>
>         if (numbytes != size) {<br>
>                 msg_gerr("Error: Failed to read complete file. Got %ld bytes, "<br>
>                          "wanted %ld!\n", numbytes, size);<br>
> -               return 1;<br>
> +               return -1;<br>
>         }<br>
> -       return 0;<br>
> +       return size;<br>
>  #endif<br>
>  }<br>
><br>
> @@ -1481,7 +1481,10 @@ static int walk_eraseregions(struct flashctx *flash, int erasefunction,<br>
>                  * members so the loop below won't be executed for them.<br>
>                  */<br>
>                 len = eraser.eraseblocks[i].size;<br>
> -               for (j = 0; j < eraser.eraseblocks[i].count; j++) {<br>
> +               for (j = 0;<br>
> +                    j < eraser.eraseblocks[i].count &&<br>
> +                    start + len <= flash->chip->total_size * 1024;<br>
> +                    j++) {<br>
>                         /* Print this for every block except the first one. */<br>
>                         if (i || j)<br>
>                                 msg_cdbg(", ");<br>
> @@ -1988,11 +1991,12 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,<br>
>         }<br>
><br>
>         if (write_it || verify_it) {<br>
> -               if (read_buf_from_file(<wbr>newcontents, size, filename)) {<br>
> +               size = read_buf_from_file(<wbr>newcontents, size, filename);<br>
> +               if (size < 0) {<br>
>                         ret = 1;<br>
>                         goto out;<br>
>                 }<br>
> -<br>
> +               flash->chip->total_size = size / 1024; /* FIXME */<br>
>  #if CONFIG_INTERNAL == 1<br>
>                 if (programmer == PROGRAMMER_INTERNAL && cb_check_image(newcontents, size) < 0) {<br>
>                         if (force_boardmismatch) {<br>
> --<br>
> 2.1.4<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> flashrom mailing list<br>
> <a href="mailto:flashrom@flashrom.org">flashrom@flashrom.org</a><br>
> <a href="https://www.flashrom.org/mailman/listinfo/flashrom" rel="noreferrer" target="_blank">https://www.flashrom.org/<wbr>mailman/listinfo/flashrom</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
David Hendricks (dhendrix)<br>
Systems Software Engineer, Google Inc.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
flashrom mailing list<br>
<a href="mailto:flashrom@flashrom.org">flashrom@flashrom.org</a><br>
<a href="https://www.flashrom.org/mailman/listinfo/flashrom" rel="noreferrer" target="_blank">https://www.flashrom.org/<wbr>mailman/listinfo/flashrom</a><br>
</div></div></blockquote></div><br></div>