This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
FATFS Problems to read the partition table on compact flash >128MB
- From: "Per Hedblom" <per dot hedblom at abem dot se>
- To: <ecos-patches at sources dot redhat dot com>
- Date: Wed, 19 Jan 2005 12:05:31 +0100
- Subject: FATFS Problems to read the partition table on compact flash >128MB
- Organization: ABEM Instrument AB
Hi,
My fatfs could not create windows compatible fat files on my 256Mb compact
flash card. The disk works fine within eCos but the files newer shows up on
my windows machine. A 128 mb card works fine. I traced down the problem to
how the partition table is read. The current implementation uses the two
C/H/S fields to find the start and end of each disk partition (offset 1 and
5).
My 256Mb compact flash works if I change the code to read the absolute start
position and size fields (offset 8 and 12). Se patch below.
I don't know how read the partition table in a correct way so it would be
nice If someone could suggest a more generally applicable code change.
/Per Hedblom
Index: src/disk.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/disk/current/src/disk.c,v
retrieving revision 1.2
diff -U5 -p -b -r1.2 disk.c
--- src/disk.c 1 Jul 2004 13:03:20 -0000 1.2
+++ src/disk.c 19 Jan 2005 10:19:18 -0000
@@ -163,17 +163,16 @@ read_partition(cyg_uint8 *dat
cyg_uint16 c, h, s;
part->type = data[4];
part->state = data[0];
- READ_CHS(&data[1], c, h, s);
- CHS_TO_LBA(&info->ident, c, h, s, part->start);
+ READ_DWORD(&data[12], part->size);
- READ_CHS(&data[5], c, h, s);
- CHS_TO_LBA(&info->ident, c, h, s, part->end);
+ READ_DWORD(&data[8], part->start);
+
+ part->end=part->start+ part->size;
- READ_DWORD(&data[12], part->size);
}
//
// Read Master Boot Record (partitions)
//