# # $Id: fconfig-ts7260.patch 7 2008-03-19 15:13:40Z wim $ # # $LastChangedDate: 2008-03-19 16:13:40 +0100 (Wed, 19 Mar 2008) $ # $Rev: 7 $ # $Author: wim $ # $URL: file:///home/wim/svn/ts7260/fconfig-ts7260.patch $ # # Patch for fconfig to work with ts7260 # fconfig can be found on http://andrzejekiert.ovh.org/software.html.en # offset based on this: # # RedBoot> fis list # Name FLASH addr Mem addr Length Entry point # (reserved) 0x60000000 0x60000000 0x01D04000 0x00000000 # RedBoot 0x61D04000 0x61D04000 0x00040000 0x00000000 # vmlinux 0x61D44000 0x00218000 0x000C0000 0x00218000 # FIS directory 0x61FFC000 0x61FFC000 0x00003000 0x00000000 # RedBoot config 0x61FFF000 0x61FFF000 0x00001000 0x00000000 # # kernel message: # Creating 3 MTD partitions on "NAND 32MiB 3,3V 8-bit": # 0x00000000-0x00004000 : "TS-BOOTROM" # 0x00004000-0x01d04000 : "Linux" # 0x01d04000-0x02000000 : "RedBoot" # # 0x002FB000 = $(RedBoot config) - $(RedBoot) # # This way I could use fconfig running: # fconfig -d /dev/mtdblock/2 -o 0x2fb000 -w -n boot_script_timeout -x 10 # # diff -Naur fconfig/crunchfc.c fconfig.new/crunchfc.c --- fconfig/crunchfc.c 2007-10-21 20:55:52.000000000 +0200 +++ fconfig.new/crunchfc.c 2008-03-19 14:38:21.000000000 +0100 @@ -407,7 +407,7 @@ TYPE_SIZE(key.type), offset); /* do an actual write to the device or file */ - if (lseek(data->fd, offset, SEEK_SET) == -1) { + if (lseek(data->fd, data->offset+offset, SEEK_SET) == -1) { MESSAGE(VERB_LOW, "lseek() failed\n"); return -1; } @@ -451,7 +451,7 @@ MESSAGE(VERB_HIGH, "Writing CRC at offset %d\n", len-4); /* do an actual write to the device or file */ - if (lseek(data->fd, len-4, SEEK_SET) == -1) { + if (lseek(data->fd, data->offset+len-4, SEEK_SET) == -1) { MESSAGE(VERB_LOW, "CRC: lseek() failed\n"); return; } diff -Naur fconfig/crunchfc.h fconfig.new/crunchfc.h --- fconfig/crunchfc.h 2007-10-21 20:55:52.000000000 +0200 +++ fconfig.new/crunchfc.h 2008-03-19 14:32:49.000000000 +0100 @@ -22,6 +22,7 @@ struct config_data { int fd; + int offset; uint32_t maxlen; uint32_t reallen; uint8_t swab; diff -Naur fconfig/fconfig.c fconfig.new/fconfig.c --- fconfig/fconfig.c 2007-10-21 20:55:52.000000000 +0200 +++ fconfig.new/fconfig.c 2008-03-19 14:37:09.000000000 +0100 @@ -76,8 +76,9 @@ } fputs("Read, write or list Redboot configuration\n", stdout); - fputs("usage: fconfig [-r|-w|-l] -d dev -n nickname -x value\n", stdout); + fputs("usage: fconfig [-r|-w|-l] -d dev -o offset -n nickname -x value\n", stdout); fputs("'dev' may be a char device, block device or a file\n", stdout); + fputs("'offset' may be the offset in bytes on the device\n", stdout); fputs("Supported types: \n", stdout); for (i = 0; i < NUM_TYPES; i++) { printf(" - %s\n", TYPE_NAME(i)); @@ -107,6 +108,7 @@ return NULL; } + if ( data->offset > 0 ) lseek(data->fd, data->offset, SEEK_SET); count = read(data->fd, buffer, MAX_CONFIG_DATA); if (count <= 0) { MESSAGE(VERB_LOW, "Nothing read!\n"); @@ -233,7 +235,9 @@ uint8_t *value = NULL; uint8_t *device = NULL; - while ((c = getopt(argc, argv, "hrwlvsd:n:x:")) != -1) { + data.offset = 0; + + while ((c = getopt(argc, argv, "hrwlvsd:n:o:x:")) != -1) { switch (c) { case 'r': mode = MODE_READ; @@ -247,6 +251,9 @@ case 'n': nickname = optarg; break; + case 'o': + sscanf( optarg, "%i", &(data.offset)); + break; case 'x': value = optarg; break;