mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
Kill obsolete exclude range feature
It is ignored by almost every chip and does not work for external flashers. Plus, it gives the user a false sense of security in some corner cases. Corresponding to flashrom svn r608. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
This commit is contained in:
parent
20a293fc68
commit
49eb4dd704
@ -3,7 +3,7 @@
|
|||||||
flashrom \- detect, read, write, verify and erase flash chips
|
flashrom \- detect, read, write, verify and erase flash chips
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B flashrom \fR[\fB\-VfLzhR\fR] [\fB\-E\fR|\fB\-r\fR file|\fB\-w\fR file|\fB\-v\fR file]
|
.B flashrom \fR[\fB\-VfLzhR\fR] [\fB\-E\fR|\fB\-r\fR file|\fB\-w\fR file|\fB\-v\fR file]
|
||||||
[\fB\-c\fR chipname] [\fB\-s\fR addr] [\fB\-e\fR addr] [\fB\-m\fR [vendor:]part]
|
[\fB\-c\fR chipname] [\fB\-m\fR [vendor:]part]
|
||||||
[\fB\-l\fR file] [\fB\-i\fR image] [\fB\-p\fR programmer] [file]
|
[\fB\-l\fR file] [\fB\-i\fR image] [\fB\-p\fR programmer] [file]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B flashrom
|
.B flashrom
|
||||||
@ -50,9 +50,6 @@ More verbose output.
|
|||||||
.TP
|
.TP
|
||||||
.B "\-c, \-\-chip" <chipname>
|
.B "\-c, \-\-chip" <chipname>
|
||||||
Probe only for specified flash ROM chip.
|
Probe only for specified flash ROM chip.
|
||||||
.TP
|
|
||||||
.B "\-s, \-\-estart" <addr>
|
|
||||||
Exclude start position (obsolete).
|
|
||||||
.sp
|
.sp
|
||||||
flashrom supports ROM layouts. This allows you to flash certain parts of
|
flashrom supports ROM layouts. This allows you to flash certain parts of
|
||||||
the flash chip only. A ROM layout file looks like follows:
|
the flash chip only. A ROM layout file looks like follows:
|
||||||
@ -81,9 +78,6 @@ ROM layouts should replace the \-s and \-e option since they are more
|
|||||||
flexible and they should lead to a ROM update file format with the
|
flexible and they should lead to a ROM update file format with the
|
||||||
ROM layout and the ROM image in one file (cpio, zip or something?).
|
ROM layout and the ROM image in one file (cpio, zip or something?).
|
||||||
.TP
|
.TP
|
||||||
.B "\-e, \-\-eend" <addr>
|
|
||||||
Exclude end postion (obsolete).
|
|
||||||
.TP
|
|
||||||
.B "\-m, \-\-mainboard" <[vendor:]part>
|
.B "\-m, \-\-mainboard" <[vendor:]part>
|
||||||
Override mainboard settings.
|
Override mainboard settings.
|
||||||
.sp
|
.sp
|
||||||
|
51
flashrom.c
51
flashrom.c
@ -31,7 +31,6 @@
|
|||||||
#include "flashchips.h"
|
#include "flashchips.h"
|
||||||
|
|
||||||
char *chip_to_probe = NULL;
|
char *chip_to_probe = NULL;
|
||||||
int exclude_start_page, exclude_end_page;
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int programmer = PROGRAMMER_INTERNAL;
|
int programmer = PROGRAMMER_INTERNAL;
|
||||||
|
|
||||||
@ -410,7 +409,7 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_flash(struct flashchip *flash, char *filename, unsigned int exclude_start_position, unsigned int exclude_end_position)
|
int read_flash(struct flashchip *flash, char *filename)
|
||||||
{
|
{
|
||||||
unsigned long numbytes;
|
unsigned long numbytes;
|
||||||
FILE *image;
|
FILE *image;
|
||||||
@ -433,10 +432,6 @@ int read_flash(struct flashchip *flash, char *filename, unsigned int exclude_sta
|
|||||||
} else
|
} else
|
||||||
flash->read(flash, buf, 0, size);
|
flash->read(flash, buf, 0, size);
|
||||||
|
|
||||||
if (exclude_end_position - exclude_start_position > 0)
|
|
||||||
memset(buf + exclude_start_position, 0,
|
|
||||||
exclude_end_position - exclude_start_position);
|
|
||||||
|
|
||||||
numbytes = fwrite(buf, 1, size, image);
|
numbytes = fwrite(buf, 1, size, image);
|
||||||
fclose(image);
|
fclose(image);
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -482,8 +477,8 @@ int erase_flash(struct flashchip *flash)
|
|||||||
|
|
||||||
void usage(const char *name)
|
void usage(const char *name)
|
||||||
{
|
{
|
||||||
printf("usage: %s [-VfLzhR] [-E|-r file|-w file|-v file] [-c chipname] [-s addr]\n"
|
printf("usage: %s [-VfLzhR] [-E|-r file|-w file|-v file] [-c chipname]\n"
|
||||||
" [-e addr] [-m [vendor:]part] [-l file] [-i image] [-p programmer] [file]\n\n", name);
|
" [-m [vendor:]part] [-l file] [-i image] [-p programmer] [file]\n\n", name);
|
||||||
|
|
||||||
printf("Please note that the command line interface for flashrom will "
|
printf("Please note that the command line interface for flashrom will "
|
||||||
"change before\nflashrom 1.0. Do not use flashrom in scripts "
|
"change before\nflashrom 1.0. Do not use flashrom in scripts "
|
||||||
@ -497,8 +492,6 @@ void usage(const char *name)
|
|||||||
" -E | --erase: erase flash device\n"
|
" -E | --erase: erase flash device\n"
|
||||||
" -V | --verbose: more verbose output\n"
|
" -V | --verbose: more verbose output\n"
|
||||||
" -c | --chip <chipname>: probe only for specified flash chip\n"
|
" -c | --chip <chipname>: probe only for specified flash chip\n"
|
||||||
" -s | --estart <addr>: exclude start position\n"
|
|
||||||
" -e | --eend <addr>: exclude end postion\n"
|
|
||||||
" -m | --mainboard <[vendor:]part>: override mainboard settings\n"
|
" -m | --mainboard <[vendor:]part>: override mainboard settings\n"
|
||||||
" -f | --force: force write without checking image\n"
|
" -f | --force: force write without checking image\n"
|
||||||
" -l | --layout <file.layout>: read ROM layout from file\n"
|
" -l | --layout <file.layout>: read ROM layout from file\n"
|
||||||
@ -542,8 +535,6 @@ int main(int argc, char *argv[])
|
|||||||
{"erase", 0, 0, 'E'},
|
{"erase", 0, 0, 'E'},
|
||||||
{"verify", 0, 0, 'v'},
|
{"verify", 0, 0, 'v'},
|
||||||
{"chip", 1, 0, 'c'},
|
{"chip", 1, 0, 'c'},
|
||||||
{"estart", 1, 0, 's'},
|
|
||||||
{"eend", 1, 0, 'e'},
|
|
||||||
{"mainboard", 1, 0, 'm'},
|
{"mainboard", 1, 0, 'm'},
|
||||||
{"verbose", 0, 0, 'V'},
|
{"verbose", 0, 0, 'V'},
|
||||||
{"force", 0, 0, 'f'},
|
{"force", 0, 0, 'f'},
|
||||||
@ -559,7 +550,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
unsigned int exclude_start_position = 0, exclude_end_position = 0; // [x,y)
|
|
||||||
char *tempstr = NULL, *tempstr2 = NULL;
|
char *tempstr = NULL, *tempstr2 = NULL;
|
||||||
|
|
||||||
print_version();
|
print_version();
|
||||||
@ -573,7 +563,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
setbuf(stdout, NULL);
|
setbuf(stdout, NULL);
|
||||||
while ((opt = getopt_long(argc, argv, "rRwvVEfc:s:e:m:l:i:p:Lzh",
|
while ((opt = getopt_long(argc, argv, "rRwvVEfc:m:l:i:p:Lzh",
|
||||||
long_options, &option_index)) != EOF) {
|
long_options, &option_index)) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'r':
|
case 'r':
|
||||||
@ -614,14 +604,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
erase_it = 1;
|
erase_it = 1;
|
||||||
break;
|
break;
|
||||||
case 's':
|
|
||||||
tempstr = strdup(optarg);
|
|
||||||
sscanf(tempstr, "%x", &exclude_start_position);
|
|
||||||
break;
|
|
||||||
case 'e':
|
|
||||||
tempstr = strdup(optarg);
|
|
||||||
sscanf(tempstr, "%x", &exclude_end_position);
|
|
||||||
break;
|
|
||||||
case 'm':
|
case 'm':
|
||||||
tempstr = strdup(optarg);
|
tempstr = strdup(optarg);
|
||||||
strtok(tempstr, ":");
|
strtok(tempstr, ":");
|
||||||
@ -753,7 +735,7 @@ int main(int argc, char *argv[])
|
|||||||
printf("Run flashrom -L to view the hardware supported in this flashrom version.\n");
|
printf("Run flashrom -L to view the hardware supported in this flashrom version.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return read_flash(flashes[0], filename, exclude_start_position, exclude_end_position);
|
return read_flash(flashes[0], filename);
|
||||||
}
|
}
|
||||||
// FIXME: flash writes stay enabled!
|
// FIXME: flash writes stay enabled!
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -817,7 +799,7 @@ int main(int argc, char *argv[])
|
|||||||
if (erase_flash(flash))
|
if (erase_flash(flash))
|
||||||
return 1;
|
return 1;
|
||||||
} else if (read_it) {
|
} else if (read_it) {
|
||||||
if (read_flash(flash, filename, exclude_start_position, exclude_end_position))
|
if (read_flash(flash, filename))
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
struct stat image_stat;
|
struct stat image_stat;
|
||||||
@ -844,27 +826,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exclude range stuff. Nice idea, but at the moment it is only
|
|
||||||
* supported in hardware by the pm49fl004 chips.
|
|
||||||
* Instead of implementing this for all chips I suggest advancing
|
|
||||||
* it to the rom layout feature below and drop exclude range
|
|
||||||
* completely once all flash chips can do rom layouts. stepan
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* FIXME: This code is totally broken. It treats exclude ranges as include ranges. */
|
|
||||||
// ////////////////////////////////////////////////////////////
|
|
||||||
if (exclude_end_position - exclude_start_position > 0)
|
|
||||||
chip_readn(buf + exclude_start_position,
|
|
||||||
flash->virtual_memory + exclude_start_position,
|
|
||||||
exclude_end_position - exclude_start_position);
|
|
||||||
|
|
||||||
exclude_start_page = exclude_start_position / flash->page_size;
|
|
||||||
if ((exclude_start_position % flash->page_size) != 0) {
|
|
||||||
exclude_start_page++;
|
|
||||||
}
|
|
||||||
exclude_end_page = exclude_end_position / flash->page_size;
|
|
||||||
// ////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// This should be moved into each flash part's code to do it
|
// This should be moved into each flash part's code to do it
|
||||||
// cleanly. This does the job.
|
// cleanly. This does the job.
|
||||||
/* FIXME: Adapt to the external flasher infrastructure. */
|
/* FIXME: Adapt to the external flasher infrastructure. */
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
extern int exclude_start_page, exclude_end_page;
|
|
||||||
|
|
||||||
void write_lockbits_49fl00x(chipaddr bios, int size,
|
void write_lockbits_49fl00x(chipaddr bios, int size,
|
||||||
unsigned char bits, int block_size)
|
unsigned char bits, int block_size)
|
||||||
{
|
{
|
||||||
@ -64,9 +62,6 @@ int erase_49fl00x(struct flashchip *flash)
|
|||||||
*/
|
*/
|
||||||
printf("Erasing page: ");
|
printf("Erasing page: ");
|
||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
if ((i >= exclude_start_page) && (i < exclude_end_page))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* erase the page */
|
/* erase the page */
|
||||||
if (erase_block_jedec(flash, i * page_size, page_size)) {
|
if (erase_block_jedec(flash, i * page_size, page_size)) {
|
||||||
fprintf(stderr, "ERASE FAILED!\n");
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
@ -98,9 +93,6 @@ int write_49fl00x(struct flashchip *flash, uint8_t *buf)
|
|||||||
|
|
||||||
printf("Programming page: ");
|
printf("Programming page: ");
|
||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
if ((i >= exclude_start_page) && (i < exclude_end_page))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* erase the page before programming */
|
/* erase the page before programming */
|
||||||
if (erase_block_jedec(flash, i * page_size, page_size)) {
|
if (erase_block_jedec(flash, i * page_size, page_size)) {
|
||||||
fprintf(stderr, "ERASE FAILED!\n");
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user