I enclosed the patch for flashrom.c file, which adds a possibility to
define the FWH device address. I hope it will be useful for someone.
I used 0.9.1-r770 flashrom version.
--
Piotr Piwko
http://www.embedded-engineering.pl/
--- ../../../flashrom.c 2010-02-03 11:09:50.000000000 +0100
+++ flashrom.c 2010-02-03 10:48:05.000000000 +0100
@@ -36,6 +36,13 @@
enum programmer programmer = PROGRAMMER_INTERNAL;
char *programmer_param = NULL;
+/*
+ * PP: The last byte of the FWH device address space.
+ * It points to the FWH device which should be used. By default the boot
+ * FWH device is taken (0xFFFFFFFF).
+ */
+uint32_t fwh_device_addr = 0xFFFFFFFF;
+
const struct programmer_entry programmer_table[] = {
{
.name = "internal",
@@ -279,7 +286,12 @@
size_t size = flash->total_size * 1024;
/* Flash registers live 4 MByte below the flash. */
/* FIXME: This is incorrect for nonstandard flashbase. */
- flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size);
+// flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size);
+
+ /* PP: Map the flash registers pointed by fwh_device_addr */
+ flash->virtual_registers =
+ (chipaddr)programmer_map_flash_region("flash chip registers",
+ (fwh_device_addr - 0x400000 - size + 1), size);
}
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len)
@@ -622,7 +634,14 @@
size = flash->total_size * 1024;
check_max_decode(buses_common, size);
- base = flashbase ? flashbase : (0xffffffff - size + 1);
+// base = flashbase ? flashbase : (0xffffffff - size + 1);
+
+ /*
+ * PP: Set the proper base address of flash device pointed by
+ * fwh_device_addr
+ */
+ base = flashbase ? flashbase : (fwh_device_addr - size + 1);
+
flash->virtual_memory = (chipaddr)programmer_map_flash_region("flash chip", base, size);
if (force)
@@ -776,8 +795,10 @@
int remaining = 0;
enum programmer p;
- printf("usage: %s [-VfLzhR] [-E|-r file|-w file|-v file] [-c chipname]\n"
- " [-m [vendor:]part] [-l file] [-i image] [-p programmer]\n\n", name);
+ /* PP: New usage */
+ printf("usage: %s [-VfLzhR] [-a address] [-E|-r file|-w file|-v file] \n"
+ " [-c chipname] [-m [vendor:]part] [-l file] [-i image] [-p programmer]\n\n",
+ name);
printf("Please note that the command line interface for flashrom will "
"change before\nflashrom 1.0. Do not use flashrom in scripts "
@@ -785,7 +806,19 @@
" version won't interpret options in a different way.\n\n");
printf
- (" -r | --read: read flash and save into file\n"
+ (/* PP: Address for FWH device */
+ " -a | --address <address>: specify the FWH device address (hex)\n"
+ " - it should be a last byte of the FWH\n"
+ " device address space, e.g.:\n"
+ " 0xFFFFFFFF - 1st 1MB boot FWH device\n"
+ " 0xFFEFFFFF - 2nd 1MB FWH device\n"
+ " 0xFFDFFFFF - 3rd 1MB FWH device\n"
+ " ...\n"
+ " - by defulat the boot device (0xFFFFFFFF)\n"
+ " is used\n"
+
+ /* Other options */
+ " -r | --read: read flash and save into file\n"
" -w | --write: write file into flash\n"
" -v | --verify: verify flash against file\n"
" -n | --noverify: don't verify flash against file\n"
@@ -837,6 +870,10 @@
void print_version(void)
{
printf("flashrom v%s\n", flashrom_version);
+
+ /* PP: Information about modification */
+ printf("Added possibility to define the FWH device address (-a option).\n");
+ printf("%s, %s, Piotr Piwko\n\n", __TIME__, __DATE__);
}
int main(int argc, char *argv[])
@@ -860,11 +897,15 @@
int ret = 0, i;
#if PRINT_WIKI_SUPPORT == 1
- const char *optstring = "rRwvnVEfc:m:l:i:p:Lzh";
+ /* PP: Option string */
+ const char *optstring = "a:rRwvnVEfc:m:l:i:p:Lzh";
#else
- const char *optstring = "rRwvnVEfc:m:l:i:p:Lh";
+ /* PP: Option string */
+ const char *optstring = "a:rRwvnVEfc:m:l:i:p:Lh";
#endif
static struct option long_options[] = {
+ /* PP: Address option */
+ {"address", 1, 0, 'a'},
{"read", 0, 0, 'r'},
{"write", 0, 0, 'w'},
{"erase", 0, 0, 'E'},
@@ -920,6 +961,11 @@
while ((opt = getopt_long(argc, argv, optstring,
long_options, &option_index)) != EOF) {
switch (opt) {
+ /* PP: Set the FWH device address */
+ case 'a':
+ fwh_device_addr = strtoul(optarg, NULL, 16);
+ fprintf(stderr, "FWH device address: 0x%x\n", fwh_device_addr);
+ break;
case 'r':
if (++operation_specified > 1) {
fprintf(stderr, "More than one operation "
_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom