
18 Nov
2005
18 Nov
'05
5:26 p.m.
Hi,
I have had following problem with ARM9 CPUs NS9360, NS9750, S3C2410 and S3C2440:
Using fatload command with 2GB USB memory stick lead to data abort and reset of CPU.
The reason herefor is, that the access to the variable fatbuf produces an alignment error, if FAT32 is used.
Attached patch moves the variable fatbuf to top of the structure, where it is defined, so that accesses to this variable are always aligned.
CHANGELOG: Fix access via fatload command on FAT32 formatted partitions Patch by Joachim Jaeger, 18 Nov 2005
Signed-off-by: Joachim Jaeger joachim_jaeger@digi.com
Best regards Joachim Jaeger
--
FS FORTH-SYSTEME GmbH
A Digi International Company
Kueferstr. 8, D-79206 Breisach
Phone: +49 (7667) 908-0, FAX +49 (7667) 908-200
--- /targets/ewp/LxNETES-3/u-boot_head/u-boot/include/fat.h 2004-04-23 22:32:07.000000000 +0200
+++ ./include/fat.h 2005-11-17 09:56:34.000000000 +0100
@@ -3,6 +3,7 @@
*
* 2002-07-28 - rjones@nexus-tech.net - ported to ppcboot v1.1.6
* 2003-03-10 - kharris@nexus-tech.net - ported to u-boot
+ * 2005-11-15 - joachim_jaeger@digi.com - alignment bug fixed
*
* See file CREDITS for list of people who contributed to this
* project.
@@ -99,7 +100,8 @@
#define FAT2CPU16(x) (x)
#define FAT2CPU32(x) (x)
#else
-#define FAT2CPU16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8))
+#define FAT2CPU16(x) ((((x) & 0x00ff) << 8) | \
+ (((x) & 0xff00) >> 8))
#define FAT2CPU32(x) ((((x) & 0x000000ff) << 24) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x00ff0000) >> 8) | \
@@ -177,13 +179,13 @@
/* Private filesystem parameters */
typedef struct {
+ __u8 fatbuf[FATBUFSIZE]; /* Current FAT buffer, has to be 32bit aligned see FAT32 accesses */
int fatsize; /* Size of FAT in bits */
__u16 fatlength; /* Length of FAT in sectors */
__u16 fat_sect; /* Starting sector of the FAT */
__u16 rootdir_sect; /* Start sector of root directory */
__u16 clust_size; /* Size of clusters in sectors */
short data_begin; /* The sector of the first cluster, can be negative */
- __u8 fatbuf[FATBUFSIZE]; /* Current FAT buffer */
int fatbufnum; /* Used by get_fatent, init to -1 */
} fsdata;