Skip to contentSkip to conversation

FAT Bare Partition Support

PATCH New Antonio R. Costa 4 participants 7 messages Jun 11, 2008 – Aug 2, 2008 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 FAT Bare Partition Support

Logic unit:

Purpose:    Add support for bare partitions (no partition table)
Author:     Antnoio R. Costa <antonio.costa <at> atmel.com>
Date  :     11 Jun 2008

Status:
~~~~~~
Some SD cards are not formatted with a partition table but with just a bare partition at the beginnig of the memory.

I modified get_partition_info_extended to call test_block_type as done by print_partition_extended. In this way bare FAT partitions are recognised. Now we need a test for Ext2.

disk/part_dos.c +38 -2
index 4d778ec..e5cc8aa 100644
@@ -1,4 +1,7 @@
 /*
+ * (C) Copyright 2008 Atmel Corp.
+ * Antonio R. Costa <antonio.costa <at> atmel.com>
+ *                  <costa.antonior <at> gmail.com>
  * (C) Copyright 2001
  * Raymond Lo, lo at routefree.com
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -53,6 +56,11 @@ static inline int le32_to_int(unsigned char *le32)
 	   );
 }
 
+static inline int le16_to_int(unsigned char *le16)
+{
+    return ((le16[1] << 8) + le16[0]);
+}
+
 static inline int is_extended(int part_type)
 {
     return (part_type == 0x5 ||
@@ -166,12 +174,20 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 	unsigned char buffer[DEFAULT_SECTOR_SIZE];
 	dos_partition_t *pt;
 	int i;
-
+	
 	if (dev_desc->block_read (dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
 		printf ("** Can't read partition table on %d:%d **\n",
 			dev_desc->dev, ext_part_sector);
 		return -1;
 	}
+
+/* 
+ * ARC:	This check is bad: 
+ * unfortunately both MBR and FAT bootsector
+ * have a sign 0x55aa @ 0x1FF
+ * I replaced it by test_block_type as in
+ * print_partition_extended
+ 
 	if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
 		buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
 		printf ("bad MBR sector signature 0x%02x%02x\n",
@@ -179,7 +195,19 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 			buffer[DOS_PART_MAGIC_OFFSET + 1]);
 		return -1;
 	}
-
+*/
+	i=test_block_type(buffer);
+	
+	if(i==-1) {
+		printf ("bad MBR sector signature 0x%02x%02x\n",
+			buffer[DOS_PART_MAGIC_OFFSET],
+			buffer[DOS_PART_MAGIC_OFFSET + 1]);
+		return -1;
+	}
+	
+	if(i==DOS_PBR)
+		return -1;
+	
 	/* Print all primary/logical partitions */
 	pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
 	for (i = 0; i < 4; i++, pt++) {
@@ -193,6 +221,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 			info->blksz = 512;
 			info->start = ext_part_sector + le32_to_int (pt->start4);
 			info->size  = le32_to_int (pt->size4);
+
 			switch(dev_desc->if_type) {
 				case IF_TYPE_IDE:
 				case IF_TYPE_SATA:
@@ -208,6 +237,13 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 				case IF_TYPE_DOC:
 					sprintf ((char *)info->name, "docd%c%d\n", 'a' + dev_desc->dev, part_num);
 					break;
+				case IF_TYPE_MMC:
+					sprintf ((char *)info->name, "mmc%c%d\n", 'a' + dev_desc->dev, part_num);
+					break;
+				case IF_TYPE_SD:
+				case IF_TYPE_SDHC:
+					sprintf ((char *)info->name, "sd%c%d\n", 'a' + dev_desc->dev, part_num);
+					break;
 				default:
 					sprintf ((char *)info->name, "xx%c%d\n", 'a' + dev_desc->dev, part_num);
 					break;
Signature · 1 line
1.5.4.3
#1 lore raw

PATCH 1/1 FAT Bare Partition Support

Hi Antonio

I am not responsible for this part of U-BOOT but your patch contain coding style violation.

Regards,
Michal Simek

Quoted 21 lines

Logic unit:

Purpose:    Add support for bare partitions (no partition table)
Author:     Antnoio R. Costa <antonio.costa <at> atmel.com>
Date  :     11 Jun 2008

Status:
~~~~~~
Some SD cards are not formatted with a partition table but with just a bare partition at the beginnig of the memory.

I modified get_partition_info_extended to call test_block_type as done by print_partition_extended. In this way bare FAT partitions are recognised. Now we need a test for Ext2.

disk/part_dos.c +0 -0
index 4d778ec..e5cc8aa 100644

disk/part_dos.c line 4

Quoted 4 lines
disk/part_dos.c +3 -0
@@ -1,4 +1,7 @@
 /*
+ * (C) Copyright 2008 Atmel Corp.
+ * Antonio R. Costa <antonio.costa <at> atmel.com>
+ *                  <costa.antonior <at> gmail.com>

choose only one email

disk/part_dos.c static inline int le32_to_int(unsigned char *le32) · line 63

Quoted 12 lines
disk/part_dos.c +5 -0
  * (C) Copyright 2001
  * Raymond Lo, lo at routefree.com
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -53,6 +56,11 @@ static inline int le32_to_int(unsigned char *le32)
 	   );
 }
 
+static inline int le16_to_int(unsigned char *le16)
+{
+    return ((le16[1] << 8) + le16[0]);
+}
+

this should be in header file

disk/part_dos.c static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part · line 177

Quoted 9 lines
disk/part_dos.c +1 -1
 static inline int is_extended(int part_type)
 {
     return (part_type == 0x5 ||
@@ -166,12 +174,20 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 	unsigned char buffer[DEFAULT_SECTOR_SIZE];
 	dos_partition_t *pt;
 	int i;
-
+	

Coding style issue.

Quoted 51 lines
disk/part_dos.c +22 -1
 	if (dev_desc->block_read (dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
 		printf ("** Can't read partition table on %d:%d **\n",
 			dev_desc->dev, ext_part_sector);
 		return -1;
 	}
+
+/* 
+ * ARC:	This check is bad: 
+ * unfortunately both MBR and FAT bootsector
+ * have a sign 0x55aa @ 0x1FF
+ * I replaced it by test_block_type as in
+ * print_partition_extended
+ 
 	if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
 		buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
 		printf ("bad MBR sector signature 0x%02x%02x\n",
@@ -179,7 +195,19 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 			buffer[DOS_PART_MAGIC_OFFSET + 1]);
 		return -1;
 	}
-
+*/
+	i=test_block_type(buffer);
+	
+	if(i==-1) {
+		printf ("bad MBR sector signature 0x%02x%02x\n",
+			buffer[DOS_PART_MAGIC_OFFSET],
+			buffer[DOS_PART_MAGIC_OFFSET + 1]);
+		return -1;
+	}
+	
+	if(i==DOS_PBR)
+		return -1;
+	
 	/* Print all primary/logical partitions */
 	pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
 	for (i = 0; i < 4; i++, pt++) {
@@ -193,6 +221,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 			info->blksz = 512;
 			info->start = ext_part_sector + le32_to_int (pt->start4);
 			info->size  = le32_to_int (pt->size4);
+
 			switch(dev_desc->if_type) {
 				case IF_TYPE_IDE:
 				case IF_TYPE_SATA:
@@ -208,6 +237,13 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 				case IF_TYPE_DOC:
 					sprintf ((char *)info->name, "docd%c%d\n", 'a' + dev_desc->dev, part_num);
 					break;

disk/part_dos.c static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part · line 249

Quoted 10 lines
disk/part_dos.c +7 -0
+				case IF_TYPE_MMC:
+					sprintf ((char *)info->name, "mmc%c%d\n", 'a' + dev_desc->dev, part_num);
+					break;
+				case IF_TYPE_SD:
+				case IF_TYPE_SDHC:
+					sprintf ((char *)info->name, "sd%c%d\n", 'a' + dev_desc->dev, part_num);
+					break;
 				default:
 					sprintf ((char *)info->name, "xx%c%d\n", 'a' + dev_desc->dev, part_num);
 					break;

Regards,
Michal Simek

#2 lore raw

PATCH 1/1 FAT Bare Partition Support

Quoted 28 lines · Michal Simek

Hi Antonio

I am not responsible for this part of U-BOOT but your patch contain coding style violation.

Regards,
Michal Simek

Quoted 20 lines

Logic unit:

Purpose:    Add support for bare partitions (no partition table)
Author:     Antnoio R. Costa <antonio.costa <at> atmel.com>
Date  :     11 Jun 2008

Status:
~~~~~~
Some SD cards are not formatted with a partition table but with just a bare partition at the beginnig of the memory.

I modified get_partition_info_extended to call test_block_type as done by print_partition_extended. In this way bare FAT partitions are recognised. Now we need a test for Ext2.

disk/part_dos.c +0 -0
index 4d778ec..e5cc8aa 100644

[snip]

Quoted 7 lines

disk/part_dos.c static inline int le32_to_int(unsigned char *le32) · line 63

Quoted 5 lines
disk/part_dos.c +5 -0
+static inline int le16_to_int(unsigned char *le16)
+{
+    return ((le16[1] << 8) + le16[0]);
+}
+

this should be in header file

Please use <asm/byteorder.h> rather than making Yet Another Define. Note that the subdirectory asm gets symlinked to the appropriate arch-specific subdirectory and then the right endian munching is selected and it Just Works[tm].

PowerPC example:
<http://git.denx.de/?p=u-boot.git;a=blob;f=include/asm-ppc/byteorder.h;h=3f5bcf63a1f980eb0c5e95e458119f55f5855274;hb=HEAD>

[snip]

Quoted 2 lines

Regards,
Michal Simek

Thanks,
gvb

#3 lore raw

PATCH 1/1 FAT Bare Partition Support

2008/6/16 Jerry Van Baren <[email protected]>:

Quoted 45 lines
Quoted 23 lines · Michal Simek

Hi Antonio

I am not responsible for this part of U-BOOT but your patch contain coding style
violation.

Regards,
Michal Simek

Logic unit:

Quoted 13 lines
Purpose:    Add support for bare partitions (no partition table)
Author:     Antnoio R. Costa <antonio.costa <at> atmel.com>
Date  :     11 Jun 2008

Status:
~~~~~~
Some SD cards are not formatted with a partition table but with just a bare partition at the beginnig of the memory.

I modified get_partition_info_extended to call test_block_type as done by print_partition_extended. In this way bare FAT partitions are recognised. Now we need a test for Ext2.

Quoted 8 lines

disk/part_dos.c

Quoted 7 lines
disk/part_dos.c +0 -0
index 4d778ec..e5cc8aa 100644

[snip]

+static inline int le16_to_int(unsigned char *le16)

Quoted 8 lines

disk/part_dos.c static inline int le32_to_int(unsigned char *le32) · line 63

Quoted 5 lines
disk/part_dos.c +4 -0
+{
+    return ((le16[1] << 8) + le16[0]);
+}
+

this should be in header file

Quoted 10 lines

Please use <asm/byteorder.h> rather than making Yet Another Define. Note that the subdirectory asm gets symlinked to the appropriate arch-specific subdirectory and then the right endian munching is selected and it Just Works[tm].

PowerPC example:
<
http://git.denx.de/?p=u-boot.git;a=blob;f=include/asm-ppc/byteorder.h;h=3f5bcf63a1f980eb0c5e95e458119f55f5855274;hb=HEAD

Quoted 1 line

Telling the truth it seems that I've used this function during debug in fact at a deeper look it seems it disappeared from the code a part the definition.
Ok I'm going to fix the problem and re-submit.

In these cases is there a special manner to format the subject to make an explicit reference to a patched patch :) ?

Regards,
Antonio

Quoted 10 lines

[snip]

Regards,

Quoted 2 lines

Michal Simek

Thanks,
gvb

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20080617/dd5bfd84/attachment.htm

#4 lore raw

PATCH 1/1 FAT Bare Partition Support

Quoted 6 lines

Telling the truth it seems that I've used this function during debug in fact at a deeper look it seems it disappeared from the code a part the definition.
Ok I'm going to fix the problem and re-submit.

Any update about the re-submit patch?

Best Regards,
J.

#5 lore raw

PATCH 1/1 FAT Bare Partition Support

Hi JC,
I have been busy on writing a Linux driver for the DSP on our
AT572D940HF-EB board.
Furthermore in the next 3 weeks I'm on vacation, please gimme more time cause
I would like rework this patch but also support for our board and SDHC support for all
Atmel devices together with Haarvard.

Regards,
Antonio R.

2008/8/2 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>

Quoted 12 lines
Quoted 2 lines

Telling the truth it seems that I've used this function during debug

in

Quoted 4 lines

fact at a deeper look it seems it disappeared from the code a part the definition.
Ok I'm going to fix the problem and re-submit.

Any update about the re-submit patch?

Best Regards,
J.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20080802/bfa2d338/attachment.htm

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 1/1 FAT Bare Partition Support

If you can't find who is it - because I think there is no any special custodian for disks, Wolfgang Denk is that person.

And please send your emails about U-BOOT directly to mailing list not personally to me. If you want use to me for a support, we can sign a contract.

Michal

Quoted 201 lines

Sorry Michael but I'm pretty new... how can I know who is it? I looked into MAINTAINERS and CREDITS but no disk/ directory found.

Regards,
Antonio

2008/6/16 Michal Simek <monstr at seznam.cz <mailto:[email protected]>>:

Quoted 1 line

2008/6/16 Michal Simek <monstr at seznam.cz <mailto:[email protected]>

    <mailto:monstr at seznam.cz <mailto:[email protected]>>>:
    >
    >     Hi Antonio
    >
    >     I am not responsible for this part of U-BOOT but your patch
    contain
    >     coding style
    >     violation.
    >
    >     Regards,
    >     Michal Simek
    >
    >     > Logic unit:
    >     > Purpose:    Add support for bare partitions (no partition table)
    >     > Author:     Antnoio R. Costa <antonio.costa <at> atmel.com
    <http://atmel.com>
    >     <http://atmel.com>>
    >     > Date  :     11 Jun 2008
    >     >
    >     > Status:
    >     > ~~~~~~
    >     > Some SD cards are not formatted with a partition table but with
    >     > just a bare partition at the beginnig of the memory.
    >     >
    >     > I modified get_partition_info_extended to call test_block_type
    >     > as done by print_partition_extended. In this way bare FAT
    partitions
    >     > are recognised. Now we need a test for Ext2.
    >     >
    >     > Signed-off-by: Antonio R. Costa <[email protected]
    <mailto:[email protected]>
    >     <mailto:antonio.costa at atmel.com <mailto:[email protected]>>>
    >     >
    >     > diff --git a/disk/part_dos.c b/disk/part_dos.c
    >     > index 4d778ec..e5cc8aa 100644
    >     > --- a/disk/part_dos.c
    >     > +++ b/disk/part_dos.c
    >     > @@ -1,4 +1,7 @@
    >     >  /*
    >     > + * (C) Copyright 2008 Atmel Corp.
    >     > + * Antonio R. Costa <antonio.costa <at> atmel.com
    <http://atmel.com> <http://atmel.com>>
    >     > + *                  <costa.antonior <at> gmail.com
    <http://gmail.com>
    >     <http://gmail.com>>
    >
    >     choose only one email
    >
    >
    > Ok
    >
    >
    >
    >
    >     >   * (C) Copyright 2001
    >     >   * Raymond Lo, lo at routefree.com <mailto:[email protected]>
    <mailto:lo at routefree.com <mailto:[email protected]>>
    >     >   * Wolfgang Denk, DENX Software Engineering, wd at denx.de
    <mailto:[email protected]>
    >     <mailto:wd at denx.de <mailto:[email protected]>>.
    >     > @@ -53,6 +56,11 @@ static inline int le32_to_int(unsigned
    char *le32)
    >     >          );
    >     >  }
    >     >
    >     > +static inline int le16_to_int(unsigned char *le16)
    >     > +{
    >     > +    return ((le16[1] << 8) + le16[0]);
    >     > +}
    >     > +
    >
    >     this should be in header file
    >
    >
    > why? le32_to_int is defined in this file just above my function ???
    >
    OK, keep it.

    >
    >     >  static inline int is_extended(int part_type)
    >     >  {
    >     >      return (part_type == 0x5 ||
    >     > @@ -166,12 +174,20 @@ static int get_partition_info_extended
    >     (block_dev_desc_t *dev_desc, int ext_part
    >     >       unsigned char buffer[DEFAULT_SECTOR_SIZE];
    >     >       dos_partition_t *pt;
    >     >       int i;
    >     > -
    >     > +
    >
    >     Coding style issue.
    >
    >     What is this ? Some kind of white spaces instead tabs or what?

    In our initial patch, you had on this line tab - look at it.

    And send this patch with cc to person who is responsible for this
    part of u-boot.

    Michal

    >     >       if (dev_desc->block_read (dev_desc->dev,
    ext_part_sector, 1,
    >     (ulong *) buffer) != 1) {
    >     >               printf ("** Can't read partition table on
    %d:%d **\n",
    >     >                       dev_desc->dev, ext_part_sector);
    >     >               return -1;
    >     >       }
    >     > +
    >     > +/*
    >     > + * ARC:      This check is bad:
    >     > + * unfortunately both MBR and FAT bootsector
    >     > + * have a sign 0x55aa @ 0x1FF
    >     > + * I replaced it by test_block_type as in
    >     > + * print_partition_extended
    >     > +
    >     >       if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
    >     >               buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
    >     >               printf ("bad MBR sector signature 0x%02x%02x\n",
    >     > @@ -179,7 +195,19 @@ static int get_partition_info_extended
    >     (block_dev_desc_t *dev_desc, int ext_part
    >     >                       buffer[DOS_PART_MAGIC_OFFSET + 1]);
    >     >               return -1;
    >     >       }
    >     > -
    >     > +*/
    >     > +     i=test_block_type(buffer);
    >     > +
    >     > +     if(i==-1) {
    >     > +             printf ("bad MBR sector signature 0x%02x%02x\n",
    >     > +                     buffer[DOS_PART_MAGIC_OFFSET],
    >     > +                     buffer[DOS_PART_MAGIC_OFFSET + 1]);
    >     > +             return -1;
    >     > +     }
    >     > +
    >     > +     if(i==DOS_PBR)
    >     > +             return -1;
    >     > +
    >     >       /* Print all primary/logical partitions */
    >     >       pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
    >     >       for (i = 0; i < 4; i++, pt++) {
    >     > @@ -193,6 +221,7 @@ static int get_partition_info_extended
    >     (block_dev_desc_t *dev_desc, int ext_part
    >     >                       info->blksz = 512;
    >     >                       info->start = ext_part_sector +
    le32_to_int
    >     (pt->start4);
    >     >                       info->size  = le32_to_int (pt->size4);
    >     > +
    >     >                       switch(dev_desc->if_type) {
    >     >                               case IF_TYPE_IDE:
    >     >                               case IF_TYPE_SATA:
    >     > @@ -208,6 +237,13 @@ static int get_partition_info_extended
    >     (block_dev_desc_t *dev_desc, int ext_part
    >     >                               case IF_TYPE_DOC:
    >     >                                       sprintf ((char
    *)info->name,
    >     "docd%c%d\n", 'a' + dev_desc->dev, part_num);
    >     >                                       break;
    >     > +                             case IF_TYPE_MMC:
    >     > +                                     sprintf ((char
    *)info->name,
    >     "mmc%c%d\n", 'a' + dev_desc->dev, part_num);
    >     > +                                     break;
    >     > +                             case IF_TYPE_SD:
    >     > +                             case IF_TYPE_SDHC:
    >     > +                                     sprintf ((char
    *)info->name,
    >     "sd%c%d\n", 'a' + dev_desc->dev, part_num);
    >     > +                                     break;
    >     >                               default:
    >     >                                       sprintf ((char
    *)info->name,
    >     "xx%c%d\n", 'a' + dev_desc->dev, part_num);
    >     >                                       break;
    >     >
    >     >
    >
    >     Regards,
    >     Michal Simek

------------------------------------------------------------------------

No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 270.3.0/1504 - Release Date: 15.6.2008 05:52