Patchwork erase block < 8KiB

login
register
mail settings
Submitter Guillaume LECERF
Date Dec. 16, 2011, 12:59 p.m.
Message ID <CAJpamw6N7BcK09L8KxVC_yW3JWaxwsDXeg9xs_Hovn=oCZyZNw@mail.gmail.com>
Download mbox | patch
Permalink /patch/131822/
State New
Headers show

Comments

Guillaume LECERF - Dec. 16, 2011, 12:59 p.m.
2011/10/14 angelo <angelo70@gmail.com>:
> Hi Artem,
> i already managed my issue, this flash and jffs2 works perfect with a 64KB
> sector. There should be in the archive my patch posted.
>
> CFI driver actually do an operation called "fixup". It detect this flash,
> and know that this flash has 2 sector sizes, 4KB and 64KB.
> The fixup chose the 4KB as erasesize, so excluding the jffs2 usage.
>
> The patch to mkfs.jffs2 tool to allow the usage of 4KB erasesize works, but
> is not safe.
> If 4KB was not allowed, there was a reason.
>
> So i also tried to use some other FS, like logfs or UBIFS. But i couldn't
> easily port all the tools needed since i am in a "Coldfire" architecture and
> using uClinux for coldfire.
> So i decided to patch the erasesize to 64KB.

Hi Angelo.

Could you please test the attached patch, which uses block erase size/command ?

Patch

Use block instead of sector erase for some SST chips

From: Guillaume LECERF <glecerf@gmail.com>

Use block erase size and block erase command for SST chips, making JFFS happy
with a 64KiB sector size instead of 4/8 KiB

Signed-off-by: Guillaume LECERF <glecerf@gmail.com>
---
 drivers/mtd/chips/cfi_cmdset_0002.c |   38 ++++++++++++++---------------------
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 8d70895..9a65aa7 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -261,10 +261,14 @@  static void fixup_old_sst_eraseregion(struct mtd_info *mtd)
 
 	/*
 	 * These flashes report two separate eraseblock regions based on the
-	 * sector_erase-size and block_erase-size, although they both operate on the
-	 * same memory. This is not allowed according to CFI, so we just pick the
-	 * sector_erase-size.
+	 * sector_erase-size and block_erase-size, although they both operate on
+	 * the same memory.
+	 * This is not allowed according to CFI, so we should pick the
+	 * sector_erase-size (4KiB). But the sector_erase-size is not adapted to
+	 * JFFS2 for whom 4 KiB is too small.
+	 * So just pick the block_erase-size (64KiB).
 	 */
+	cfi->cfiq->EraseRegionInfo[0] = cfi->cfiq->EraseRegionInfo[1];
 	cfi->cfiq->NumEraseRegions = 1;
 }
 
@@ -277,6 +281,9 @@  static void fixup_sst39vf(struct mtd_info *mtd)
 
 	cfi->addr_unlock1 = 0x5555;
 	cfi->addr_unlock2 = 0x2AAA;
+
+	/* use block_erase_cmd (0x50) */
+	cfi->sector_erase_cmd = CMD(0x50);
 }
 
 static void fixup_sst39vf_rev_b(struct mtd_info *mtd)
@@ -289,22 +296,7 @@  static void fixup_sst39vf_rev_b(struct mtd_info *mtd)
 	cfi->addr_unlock1 = 0x555;
 	cfi->addr_unlock2 = 0x2AA;
 
-	cfi->sector_erase_cmd = CMD(0x50);
-}
-
-static void fixup_sst38vf640x_sectorsize(struct mtd_info *mtd)
-{
-	struct map_info *map = mtd->priv;
-	struct cfi_private *cfi = map->fldrv_priv;
-
-	fixup_sst39vf_rev_b(mtd);
-
-	/*
-	 * CFI reports 1024 sectors (0x03ff+1) of 64KBytes (0x0100*256) where
-	 * it should report a size of 8KBytes (0x0020*256).
-	 */
-	cfi->cfiq->EraseRegionInfo[0] = 0x002003ff;
-	pr_warning("%s: Bad 38VF640x CFI data; adjusting sector size from 64 to 8KiB\n", mtd->name);
+	/* sector_erase_cmd is already equals to block_erase_cmd (0x30) */
 }
 
 static void fixup_s29gl064n_sectors(struct mtd_info *mtd)
@@ -359,10 +351,10 @@  static struct cfi_fixup cfi_fixup_table[] = {
 	{ CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors },
 	{ CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors },
 	{ CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors },
-	{ CFI_MFR_SST, 0x536a, fixup_sst38vf640x_sectorsize }, /* SST38VF6402 */
-	{ CFI_MFR_SST, 0x536b, fixup_sst38vf640x_sectorsize }, /* SST38VF6401 */
-	{ CFI_MFR_SST, 0x536c, fixup_sst38vf640x_sectorsize }, /* SST38VF6404 */
-	{ CFI_MFR_SST, 0x536d, fixup_sst38vf640x_sectorsize }, /* SST38VF6403 */
+	{ CFI_MFR_SST, 0x536a, fixup_sst39vf_rev_b }, /* SST38VF6402 */
+	{ CFI_MFR_SST, 0x536b, fixup_sst39vf_rev_b }, /* SST38VF6401 */
+	{ CFI_MFR_SST, 0x536c, fixup_sst39vf_rev_b }, /* SST38VF6404 */
+	{ CFI_MFR_SST, 0x536d, fixup_sst39vf_rev_b }, /* SST38VF6403 */
 #if !FORCE_WORD_WRITE
 	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers },
 #endif