[Yaffs] yaffs2 compatability mode patch

Nick Bane nick@cecomputing.co.uk
Fri, 18 Feb 2005 23:03:50 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C5160E.1BD738D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

A patch file for yaffs2 fixing some yaffs1 compatability mode problems =
against the current cvs
The patch is in two parts.
The first part is a makefile patch for linux-2.4.25-vrs2-tcl1.
The second part fixes some tags issues and ecc on write where NANDECC is =
false.

Nick Bane


-----------------------
Nick Bane
nick@cecomputing.co.uk
+44 (0)1954 719270=20
--=20
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.8 - Release Date: 14/02/2005

------=_NextPart_000_000B_01C5160E.1BD738D0
Content-Type: application/octet-stream;
	name="yaffs2.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="yaffs2.diff"

diff -wurN ../yaffs-old/Makefile ./Makefile=0A=
--- ../yaffs-old/Makefile	2004-12-17 23:14:51.000000000 +0000=0A=
+++ ./Makefile	2005-02-18 14:41:21.000000000 +0000=0A=
@@ -18,13 +18,13 @@=0A=
 ## Change or override  KERNELDIR to your kernel=0A=
 ## comment out USE_xxxx if you don't want these features.=0A=
 =0A=
-KERNELDIR =3D /usr/src/kernel-headers-2.4.27=0A=
+# NCB KERNELDIR =3D /usr/src/kernel-headers-2.4.27=0A=
 =0A=
 ## Change if you are using a cross-compiler=0A=
-MAKETOOLS =3D =0A=
+# NCB MAKETOOLS =3D =0A=
 =0A=
-CC=3D$(MAKETOOLS)gcc=0A=
-LD=3D$(MAKETOOLS)ld=0A=
+# NCB CC=3D$(MAKETOOLS)gcc=0A=
+# NCB LD=3D$(MAKETOOLS)ld=0A=
 =0A=
 # Configurations...=0A=
 # Comment out the stuff you don't want.=0A=
@@ -34,7 +34,7 @@=0A=
 # This adds the yaffsram file system support. Nice for testing on x86, =
but uses 2MB of RAM.=0A=
 # Don't enable for NAND-based targets.=0A=
 =0A=
-USE_RAM_FOR_TEST =3D -DCONFIG_YAFFS_RAM_ENABLED=0A=
+# NCB USE_RAM_FOR_TEST =3D -DCONFIG_YAFFS_RAM_ENABLED=0A=
 =0A=
 =0A=
 # CONFIG_YAFFS_MTD_ENABLED.=0A=
@@ -46,7 +46,7 @@=0A=
 # This adds the yaffs2ram file system support. Nice for testing on x86, =
but uses 2MB of RAM.=0A=
 # Don't enable for NAND-based targets.=0A=
 =0A=
-USE_RAM_FOR_TEST_2 =3D -DCONFIG_YAFFS2_RAM_ENABLED=0A=
+# NCB USE_RAM_FOR_TEST_2 =3D -DCONFIG_YAFFS2_RAM_ENABLED=0A=
 =0A=
 =0A=
 # CONFIG_YAFFS2_MTD_ENABLED.=0A=
@@ -67,14 +67,14 @@=0A=
 #=0A=
 # NB UseNANDECC does not work at present with yaffsram.=0A=
 =0A=
-USE_NANDECC =3D -DCONFIG_YAFFS_USE_NANDECC=0A=
+# NCB USE_NANDECC =3D -DCONFIG_YAFFS_USE_NANDECC=0A=
 =0A=
 # CONFIG_YAFFS_ECC_WRONG_ORDER=0A=
 # This makes yaffs_ecc.c use the same ecc byte order as=0A=
 # Steven Hill's nand_ecc.c. If not set, then you get the=0A=
 # same ecc byte order as SmartMedia.=0A=
 =0A=
-#USE_WRONGECC =3D -DCONFIG_YAFFS_ECC_WRONG_ORDER=0A=
+USE_WRONGECC =3D -DCONFIG_YAFFS_ECC_WRONG_ORDER=0A=
 =0A=
 # CONFIG_YAFFS_USE_HEADER_FILE_SIZE=0A=
 # When the flash is scanned, two file sizes are constructed:=0A=
@@ -115,19 +115,12 @@=0A=
 =0A=
 YAFFS2_CONFIGS =3D $(YAFFS_CONFIGS) -DCONFIG_YAFFS_YAFFS2=0A=
 =0A=
-CFLAGS =3D -D__KERNEL__ -DMODULE $(YAFFS2_CONFIGS)  =
-I$(KERNELDIR)/include -O2 -g -Wall=0A=
+O_TARGET :=3D yaffs2.o=0A=
 =0A=
+#obj-y   :=3D yaffs_fs.o yaffs_guts.o yaffs_ramem.o yaffs_mtdif.o =
yaffs_ecc.o yaffs_tagscompat.o yaffs_ramem2k.o yaffs_packedtags2.o =
yaffs_mtdif2.o=0A=
+obj-y   :=3D yaffs_fs.o yaffs_guts.o yaffs_mtdif.o yaffs_ecc.o =
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_mtdif2.o=0A=
+obj-m   :=3D $(O_TARGET)=0A=
 =0A=
-OBJS =3D yaffs_fs.o yaffs_guts.o yaffs_ramem.o yaffs_mtdif.o =
yaffs_ecc.o yaffs_tagscompat.o yaffs_ramem2k.o yaffs_packedtags2.o =
yaffs_mtdif2.o=0A=
+EXTRA_CFLAGS +=3D $(YAFFS2_CONFIGS)=0A=
 =0A=
-=0A=
-all: yaffs.o=0A=
-=0A=
-$(OBJS): %.o: %.c Makefile=0A=
-	$(CC) -c $(CFLAGS) $< -o $@=0A=
-=0A=
-yaffs.o: $(OBJS)=0A=
-	$(LD) -r $(OBJS) -o $@=0A=
-=0A=
-clean:=0A=
-	rm -f $(OBJS) core=0A=
+include $(TOPDIR)/Rules.make=0A=
diff -wurN ../yaffs-old/yaffs_ecc.c ./yaffs_ecc.c=0A=
--- ../yaffs-old/yaffs_ecc.c	2004-11-03 08:14:07.000000000 +0000=0A=
+++ ./yaffs_ecc.c	2005-02-17 17:25:38.000000000 +0000=0A=
@@ -265,9 +265,15 @@=0A=
 		// swap the bytes to correct for the wrong order=0A=
 		unsigned char t;=0A=
 		=0A=
+#if 0 // NCB=0A=
 		t =3D d0;=0A=
 		d0 =3D d1;=0A=
 		d1 =3D t;=0A=
+#else=0A=
+		t =3D cDelta;=0A=
+		cDelta =3D lDelta;=0A=
+		lDelta =3D t;=0A=
+#endif=0A=
 #endif=0A=
 		=0A=
 		bit =3D 0;=0A=
diff -wurN ../yaffs-old/yaffs_fs.c ./yaffs_fs.c=0A=
--- ../yaffs-old/yaffs_fs.c	2004-12-17 04:39:04.000000000 +0000=0A=
+++ ./yaffs_fs.c	2005-02-18 18:44:28.000000000 +0000=0A=
@@ -33,6 +33,7 @@=0A=
 extern const char *yaffs_guts_c_version;=0A=
 =0A=
 =0A=
+=0A=
 #include <linux/config.h>=0A=
 #include <linux/kernel.h>=0A=
 #include <linux/module.h>=0A=
@@ -63,7 +64,6 @@=0A=
 =0A=
 #endif=0A=
 =0A=
-=0A=
 #include <asm/uaccess.h>=0A=
 =0A=
 #include "yportenv.h"=0A=
@@ -72,8 +72,8 @@=0A=
 =0A=
 =0A=
 =0A=
-//unsigned yaffs_traceMask =3D YAFFS_TRACE_ALWAYS | =
YAFFS_TRACE_BAD_BLOCKS;=0A=
-unsigned yaffs_traceMask =3D 0xFFFFFFFF;=0A=
+unsigned yaffs_traceMask =3D YAFFS_TRACE_ALWAYS | =
YAFFS_TRACE_BAD_BLOCKS;=0A=
+//unsigned yaffs_traceMask =3D 0xFFFFFFFF;=0A=
 =0A=
 =0A=
 #ifdef CONFIG_YAFFS_RAM_ENABLED=0A=
diff -wurN ../yaffs-old/yaffs_guts.c ./yaffs_guts.c=0A=
--- ../yaffs-old/yaffs_guts.c	2004-12-17 04:39:04.000000000 +0000=0A=
+++ ./yaffs_guts.c	2005-02-18 21:24:21.000000000 +0000=0A=
@@ -489,7 +489,8 @@=0A=
 	__u8 *data =3D yaffs_GetTempBuffer(dev,__LINE__);=0A=
 	yaffs_ExtendedTags tags;=0A=
 =0A=
-  	dev->readChunkWithTagsFromNAND(dev,chunkInNAND,data,&tags);=0A=
+// NCB  	dev->readChunkWithTagsFromNAND(dev,chunkInNAND,data,&tags);=0A=
+  	yaffs_ReadChunkWithTagsFromNAND(dev,chunkInNAND,data,&tags);=0A=
 	=0A=
 	if(!yaffs_CheckFF(data,dev->nBytesPerChunk) || tags.chunkUsed)=0A=
 	{=0A=
diff -wurN ../yaffs-old/yaffs_tagscompat.c ./yaffs_tagscompat.c=0A=
--- ../yaffs-old/yaffs_tagscompat.c	2004-11-03 08:14:07.000000000 +0000=0A=
+++ ./yaffs_tagscompat.c	2005-02-18 17:24:11.000000000 +0000=0A=
@@ -587,6 +587,13 @@=0A=
 		tags.byteCount =3D eTags->byteCount;=0A=
 		tags.serialNumber =3D eTags->serialNumber;=0A=
 		=0A=
+// NCB=0A=
+		if (!dev->useNANDECC && data)=0A=
+		{=0A=
+		    yaffs_CalcECC(data,&spare);=0A=
+		}=0A=
+=0A=
+// /NCB=0A=
 		 yaffs_LoadTagsIntoSpare(&spare,&tags);=0A=
 		=0A=
 	}=0A=
@@ -602,8 +609,21 @@=0A=
 	yaffs_Tags tags;=0A=
 	yaffs_ECCResult eccResult;=0A=
 	=0A=
+// NCB=0A=
+     static yaffs_Spare spareFF;=0A=
+     static int init;=0A=
+     =0A=
+     if(!init)=0A=
+     {=0A=
+	     memset(&spareFF,0xFF,sizeof(spareFF));=0A=
+	     init =3D 1;=0A=
+     }=0A=
+// /NCB=0A=
 	if(yaffs_ReadChunkFromNAND(dev,chunkInNAND,data,&spare,&eccResult,1))=0A=
 	{=0A=
+// added NCB - eTags may be NULL=0A=
+		if (eTags) {=0A=
+=0A=
 		 int deleted =3D (yaffs_CountBits(spare.pageStatus) < 7) ? 1 : 0;=0A=
 			=0A=
 		 yaffs_GetTagsFromSpare(dev,&spare,&tags);=0A=
@@ -616,6 +636,10 @@=0A=
 		 eTags->eccResult =3D eccResult;=0A=
 		 eTags->blockBad =3D 0; // We're reading it therefore it is not a bad =
block=0A=
 		 =0A=
+// NCB added 18/2/2005=0A=
+    		 eTags->chunkUsed =3D (memcmp(&spareFF,&spare,sizeof(spareFF)) =
!=3D 0) ? 1:0;=0A=
+		}=0A=
+		 =0A=
 		 return YAFFS_OK;=0A=
 	}=0A=
 	else=0A=

------=_NextPart_000_000B_01C5160E.1BD738D0--