* Patch for RedBoot Partition Table Parsing
@ 2004-03-24 4:00 LOH Chee Tim
2004-03-24 9:15 ` David Woodhouse
0 siblings, 1 reply; 3+ messages in thread
From: LOH Chee Tim @ 2004-03-24 4:00 UTC (permalink / raw)
To: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 725 bytes --]
The attached patch, against mtd-snapshot-20040323, fixes RedBoot Partition
Table Parsing for unallocated flash space before the first image.
Also included are minor updates to:
1. include nullname only if it is used
2. add an option for selecting whether unallocated flash space is to be
included
3. follow eCos 2.0 by reading partition table from the whole of last erase
block instead of just the start
4. force read-only for RedBoot, RedBoot Config and FIS directory images
Please feel free to comment on the patch and its suitability for inclusion
into cvs.
Regards,
Chee Tim
Senior Engineer, Product Development
InnoMedia Pte Ltd
DID: +65 65869142
Tel: +65 68720828 ext 142
Fax: +65 68724006
http://www.innomedia.com
[-- Attachment #2: mtd-snapshot-20040323.diff --]
[-- Type: application/octet-stream, Size: 4353 bytes --]
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/Config.in mtd-snapshot-20040323/drivers/mtd/Config.in
--- mtd-snapshot-20040323-orig/drivers/mtd/Config.in Sat May 24 06:00:06 2003
+++ mtd-snapshot-20040323/drivers/mtd/Config.in Fri Mar 19 10:23:29 2004
@@ -14,6 +14,9 @@
dep_tristate ' MTD partitioning support' CONFIG_MTD_PARTITIONS $CONFIG_MTD
dep_tristate ' MTD concatenating support' CONFIG_MTD_CONCAT $CONFIG_MTD
dep_tristate ' RedBoot partition table parsing' CONFIG_MTD_REDBOOT_PARTS $CONFIG_MTD_PARTITIONS
+ if [ "$CONFIG_MTD_REDBOOT_PARTS" = "y" ]; then
+ dep_bool ' Include unallocated flash space' CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED $CONFIG_MTD_REDBOOT_PARTS
+ fi
dep_tristate ' Command line partition table parsing' CONFIG_MTD_CMDLINE_PARTS $CONFIG_MTD_PARTITIONS
if [ "$CONFIG_ARM" = "y" ]; then
dep_tristate ' ARM Firmware Suite partition parsing' CONFIG_MTD_AFS_PARTS $CONFIG_MTD_PARTITIONS
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/redboot.c mtd-snapshot-20040323/drivers/mtd/redboot.c
--- mtd-snapshot-20040323-orig/drivers/mtd/redboot.c Thu Jun 26 06:00:07 2003
+++ mtd-snapshot-20040323/drivers/mtd/redboot.c Thu Mar 18 16:29:00 2004
@@ -48,21 +48,24 @@
char *names;
char *nullname;
int namelen = 0;
+ int nulllen = 0;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
static char nullstring[] = "unallocated";
+#endif
- buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ buf = kmalloc(master->erasesize, GFP_KERNEL);
if (!buf)
return -ENOMEM;
/* Read the start of the last erase block */
ret = master->read(master, master->size - master->erasesize,
- PAGE_SIZE, &retlen, (void *)buf);
+ master->erasesize, &retlen, (void *)buf);
if (ret)
goto out;
- if (retlen != PAGE_SIZE) {
+ if (retlen != master->erasesize) {
ret = -EIO;
goto out;
}
@@ -80,7 +83,7 @@
goto out;
}
- for (i = 0; i < PAGE_SIZE / sizeof(struct fis_image_desc); i++) {
+ for (i = 0; i < master->erasesize / sizeof(struct fis_image_desc); i++) {
struct fis_list *new_fl, **prev;
if (buf[i].name[0] == 0xff)
@@ -112,48 +115,67 @@
nrparts++;
}
- if (fl->img->flash_base)
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ if (fl->img->flash_base) {
nrparts++;
+ nulllen = sizeof(nullstring);
+ }
for (tmp_fl = fl; tmp_fl->next; tmp_fl = tmp_fl->next) {
- if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize < tmp_fl->next->img->flash_base)
+ if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize <= tmp_fl->next->img->flash_base) {
nrparts++;
+ nulllen = sizeof(nullstring);
+ }
}
- parts = kmalloc(sizeof(*parts)*nrparts + sizeof(nullstring) + namelen, GFP_KERNEL);
+#endif
+ parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
if (!parts) {
ret = -ENOMEM;
goto out;
}
- memset(parts, 0, sizeof(*parts)*nrparts + namelen);
+ memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen);
- /* FIXME: Include nullname only if it's used */
nullname = (char *)&parts[nrparts];
- sprintf(nullname, nullstring);
- names = nullname + sizeof(nullstring);
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ if (nulllen > 0) {
+ strcpy(nullname, nullstring);
+ }
+#endif
+ names = nullname + nulllen;
i=0;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if (fl->img->flash_base) {
parts[0].name = nullname;
parts[0].size = fl->img->flash_base;
parts[0].offset = 0;
+ i++;
}
+#endif
for ( ; i<nrparts; i++) {
parts[i].size = fl->img->size;
parts[i].offset = fl->img->flash_base;
parts[i].name = names;
strcpy(names, fl->img->name);
+ if (!memcmp(names, "RedBoot", 8) ||
+ !memcmp(names, "RedBoot config", 15) ||
+ !memcmp(names, "FIS directory", 14)) {
+ parts[i].mask_flags = MTD_WRITEABLE;
+ }
names += strlen(names)+1;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) {
i++;
parts[i].offset = parts[i-1].size + parts[i-1].offset;
parts[i].size = fl->next->img->flash_base - parts[i].offset;
parts[i].name = nullname;
}
+#endif
tmp_fl = fl;
fl = fl->next;
kfree(tmp_fl);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Patch for RedBoot Partition Table Parsing
2004-03-24 4:00 Patch for RedBoot Partition Table Parsing LOH Chee Tim
@ 2004-03-24 9:15 ` David Woodhouse
2004-03-26 2:01 ` LOH Chee Tim
0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2004-03-24 9:15 UTC (permalink / raw)
To: cheetim_loh; +Cc: linux-mtd
On Wed, 2004-03-24 at 12:00 +0800, LOH Chee Tim wrote:
> The attached patch, against mtd-snapshot-20040323, fixes RedBoot Partition
> Table Parsing for unallocated flash space before the first image.
Thanks.
> Also included are minor updates to:
> 1. include nullname only if it is used
> 2. add an option for selecting whether unallocated flash space is to be
> included
OK. I'd be a lot happier if we had already fixed up the partitioning and
could get at a 'whole-device' MTD device reliably, but it does make
sense.
> 3. follow eCos 2.0 by reading partition table from the whole of last erase
> block instead of just the start
OK.
> 4. force read-only for RedBoot, RedBoot Config and FIS directory images
I don't like this very much. I habitually update RedBoot from Linux. I
have occasionally been known to change the config and FIS directory too.
Perhaps we could make it optional too?
Please update the Kconfig file to match what you've changed in
Config.in.
--
dwmw2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch for RedBoot Partition Table Parsing
2004-03-24 9:15 ` David Woodhouse
@ 2004-03-26 2:01 ` LOH Chee Tim
0 siblings, 0 replies; 3+ messages in thread
From: LOH Chee Tim @ 2004-03-26 2:01 UTC (permalink / raw)
To: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]
On Wed, 2004-03-24 at 5:15PM, David Woodhouse wrote:
> > Also included are minor updates to:
> > 1. include nullname only if it is used
> > 2. add an option for selecting whether unallocated flash space is to be
> > included
>
> OK. I'd be a lot happier if we had already fixed up the partitioning and
> could get at a 'whole-device' MTD device reliably, but it does make
> sense.
Can you please elaborate more on the issue so that I can try to help?
> > 4. force read-only for RedBoot, RedBoot Config and FIS directory images
>
> I don't like this very much. I habitually update RedBoot from Linux. I
> have occasionally been known to change the config and FIS directory too.
>
> Perhaps we could make it optional too?
>
> Please update the Kconfig file to match what you've changed in
> Config.in.
Please find attached the new patch against mtd-snapshot-20040323 that makes
forcing read-only of RedBoot system images optional and the updated Kconfig
file to match the changes to Config.in.
Regards,
Chee Tim
Senior Engineer, Product Development
InnoMedia Pte Ltd
DID: +65 65869142
Tel: +65 68720828 ext 142
Fax: +65 68724006
http://www.innomedia.com
[-- Attachment #2: mtd-snapshot-20040323.diff --]
[-- Type: application/octet-stream, Size: 5461 bytes --]
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/Config.in mtd-snapshot-20040323/drivers/mtd/Config.in
--- mtd-snapshot-20040323-orig/drivers/mtd/Config.in Sat May 24 06:00:06 2003
+++ mtd-snapshot-20040323/drivers/mtd/Config.in Thu Mar 25 00:56:44 2004
@@ -14,6 +14,10 @@
dep_tristate ' MTD partitioning support' CONFIG_MTD_PARTITIONS $CONFIG_MTD
dep_tristate ' MTD concatenating support' CONFIG_MTD_CONCAT $CONFIG_MTD
dep_tristate ' RedBoot partition table parsing' CONFIG_MTD_REDBOOT_PARTS $CONFIG_MTD_PARTITIONS
+ if [ "$CONFIG_MTD_REDBOOT_PARTS" = "y" -o "$CONFIG_MTD_REDBOOT_PARTS" = "m" ]; then
+ bool ' Include unallocated flash space' CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ bool ' Force read-only for RedBoot system images' CONFIG_MTD_REDBOOT_PARTS_READONLY
+ fi
dep_tristate ' Command line partition table parsing' CONFIG_MTD_CMDLINE_PARTS $CONFIG_MTD_PARTITIONS
if [ "$CONFIG_ARM" = "y" ]; then
dep_tristate ' ARM Firmware Suite partition parsing' CONFIG_MTD_AFS_PARTS $CONFIG_MTD_PARTITIONS
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/Kconfig mtd-snapshot-20040323/drivers/mtd/Kconfig
--- mtd-snapshot-20040323-orig/drivers/mtd/Kconfig Thu May 29 06:00:06 2003
+++ mtd-snapshot-20040323/drivers/mtd/Kconfig Thu Mar 25 01:20:55 2004
@@ -68,6 +68,20 @@
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
example.
+config MTD_REDBOOT_PARTS_UNALLOCATED
+ bool " Include unallocated flash regions"
+ depends on MTD_REDBOOT_PARTS
+ help
+ If you need to register each unallocated flash region as a MTD
+ 'partition', enable this option.
+
+config MTD_REDBOOT_PARTS_READONLY
+ bool " Force read-only for RedBoot system images"
+ depends on MTD_REDBOOT_PARTS
+ help
+ If you need to force read-only for 'RedBoot', 'RedBoot Config' and
+ 'FIS directory' images, enable this option.
+
config MTD_CMDLINE_PARTS
tristate "Command line partition table parsing"
depends on MTD_PARTITIONS
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/redboot.c mtd-snapshot-20040323/drivers/mtd/redboot.c
--- mtd-snapshot-20040323-orig/drivers/mtd/redboot.c Thu Jun 26 06:00:07 2003
+++ mtd-snapshot-20040323/drivers/mtd/redboot.c Thu Mar 25 00:41:32 2004
@@ -48,21 +48,24 @@
char *names;
char *nullname;
int namelen = 0;
+ int nulllen = 0;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
static char nullstring[] = "unallocated";
+#endif
- buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ buf = kmalloc(master->erasesize, GFP_KERNEL);
if (!buf)
return -ENOMEM;
/* Read the start of the last erase block */
ret = master->read(master, master->size - master->erasesize,
- PAGE_SIZE, &retlen, (void *)buf);
+ master->erasesize, &retlen, (void *)buf);
if (ret)
goto out;
- if (retlen != PAGE_SIZE) {
+ if (retlen != master->erasesize) {
ret = -EIO;
goto out;
}
@@ -80,7 +83,7 @@
goto out;
}
- for (i = 0; i < PAGE_SIZE / sizeof(struct fis_image_desc); i++) {
+ for (i = 0; i < master->erasesize / sizeof(struct fis_image_desc); i++) {
struct fis_list *new_fl, **prev;
if (buf[i].name[0] == 0xff)
@@ -112,48 +115,69 @@
nrparts++;
}
- if (fl->img->flash_base)
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ if (fl->img->flash_base) {
nrparts++;
+ nulllen = sizeof(nullstring);
+ }
for (tmp_fl = fl; tmp_fl->next; tmp_fl = tmp_fl->next) {
- if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize < tmp_fl->next->img->flash_base)
+ if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize <= tmp_fl->next->img->flash_base) {
nrparts++;
+ nulllen = sizeof(nullstring);
+ }
}
- parts = kmalloc(sizeof(*parts)*nrparts + sizeof(nullstring) + namelen, GFP_KERNEL);
+#endif
+ parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
if (!parts) {
ret = -ENOMEM;
goto out;
}
- memset(parts, 0, sizeof(*parts)*nrparts + namelen);
+ memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen);
- /* FIXME: Include nullname only if it's used */
nullname = (char *)&parts[nrparts];
- sprintf(nullname, nullstring);
- names = nullname + sizeof(nullstring);
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ if (nulllen > 0) {
+ strcpy(nullname, nullstring);
+ }
+#endif
+ names = nullname + nulllen;
i=0;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if (fl->img->flash_base) {
parts[0].name = nullname;
parts[0].size = fl->img->flash_base;
parts[0].offset = 0;
+ i++;
}
+#endif
for ( ; i<nrparts; i++) {
parts[i].size = fl->img->size;
parts[i].offset = fl->img->flash_base;
parts[i].name = names;
strcpy(names, fl->img->name);
+#ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY
+ if (!memcmp(names, "RedBoot", 8) ||
+ !memcmp(names, "RedBoot config", 15) ||
+ !memcmp(names, "FIS directory", 14)) {
+ parts[i].mask_flags = MTD_WRITEABLE;
+ }
+#endif
names += strlen(names)+1;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) {
i++;
parts[i].offset = parts[i-1].size + parts[i-1].offset;
parts[i].size = fl->next->img->flash_base - parts[i].offset;
parts[i].name = nullname;
}
+#endif
tmp_fl = fl;
fl = fl->next;
kfree(tmp_fl);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-26 1:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-24 4:00 Patch for RedBoot Partition Table Parsing LOH Chee Tim
2004-03-24 9:15 ` David Woodhouse
2004-03-26 2:01 ` LOH Chee Tim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox