[coreboot] [PATCH] flashrom: sector-based flashing

FENG Yu Ning fengyuning1984 at gmail.com
Mon Dec 1 05:05:49 CET 2008


On Sat, Nov 29, 2008 at 8:23 PM, FENG Yu Ning <fengyuning1984 at gmail.com> wrote:
> On Sat, Nov 29, 2008 at 9:15 AM, Carl-Daniel Hailfinger
> <c-d.hailfinger.devel.2006 at gmx.net> wrote:
>> Index: flashrom-eraseblocks/flashrom.c
>> ===================================================================
>> --- flashrom-eraseblocks/flashrom.c     (Revision 3776)
>> +++ flashrom-eraseblocks/flashrom.c     (Arbeitskopie)
>> @@ -534,11 +534,33 @@
>>
>>        if (erase_it) {
>>                printf("Erasing flash chip.\n");
>> -               if (!flash->erase) {
>> -                       fprintf(stderr, "Error: flashrom has no erase function for this flash chip.\n");
>> +               if (!flash->block_erase && flash->eraseblocks[0].count) {
>> +                       fprintf(stderr, "Hint: flashrom knows the eraseblock "
>> +                               "layout, but there is no blockwise erase "
>> +                               "function for this flash chip. "
>> +                               "Using whole-chip erase.\n");
>> +               }
>> +               if (flash->block_erase && !flash->eraseblocks[0].count) {
>> +                       fprintf(stderr, "Hint: flashrom has a blockwise erase "
>> +                               "function for this flash chip, but the "
>> +                               "eraseblock layout is unknown. "
>> +                               "Using whole-chip erase.\n");
>> +               }
>> +               if (flash->block_erase && flash->eraseblocks[0].count) {
>> +                       unsigned long done = 0;
>> +                       int i, j;
>> +                       for (i = 0; done < flash->total_size * 1024; i++) {
>> +                               for (j = 0; j < flash->eraseblocks[i].count; j++) {
>> +                                       flash->block_erase(flash, done + flash->eraseblocks[i].size * j);
>> +                               }
>> +                               done += flash->eraseblocks[i].count * flash->eraseblocks[i].size;
>> +                       }
>> +               } else if (flash->erase) {
>> +                       flash->erase(flash);
>> +               } else {
>> +                       fprintf(stderr, "Error: flashrom has no chip erase function for this flash chip.\n");
>>                        return 1;
>>                }
>> -               flash->erase(flash);
>>                exit(0);
>>        } else if (read_it) {
>>                if ((image = fopen(filename, "w")) == NULL) {
>
> No comment to the logic. But the new code has a different degree of
> detail compared to other 'if (do_it)' blocks(i.e., the for loop).

I do have a comment to the logic now. If we want to erase a whole
chip, we shall try 'flash->erase' first.

yu ning




More information about the coreboot mailing list