This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FATFS Problems to read the partition table on compact flash >128MB


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)
 //





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]