From patchwork Wed Dec 5 06:59:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 203795 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A10322C0087 for ; Wed, 5 Dec 2012 18:03:41 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tg8x5-0000jq-J7; Wed, 05 Dec 2012 06:59:27 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tg8x1-0000jS-IV for linux-arm-kernel@lists.infradead.org; Wed, 05 Dec 2012 06:59:25 +0000 Received: from [10.217.3.59] ([10.217.3.59]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id qB56s0oL018636; Tue, 4 Dec 2012 22:54:02 -0800 (PST) Message-ID: <50BEF0C0.7060807@atmel.com> Date: Wed, 05 Dec 2012 14:59:12 +0800 From: Josh Wu User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: Bryan Evenson Subject: Re: at91: Status of NAND flash access References: <91586D499ADFD74FBCFB8425266A5DE4013765CC370A@pluto.melinkcorp.local> <50BDD661.7070803@atmel.com> <91586D499ADFD74FBCFB8425266A5DE4013765CC3D14@pluto.melinkcorp.local> In-Reply-To: <91586D499ADFD74FBCFB8425266A5DE4013765CC3D14@pluto.melinkcorp.local> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121205_015923_878177_D49D5BBB X-CRM114-Status: GOOD ( 56.73 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org On 12/5/2012 12:24 AM, Bryan Evenson wrote: >> -----Original Message----- >> From: Josh Wu [mailto:josh.wu@atmel.com] >> Sent: Tuesday, December 04, 2012 5:54 AM >> To: Bryan Evenson >> Cc: linux-arm-kernel@lists.infradead.org >> Subject: Re: at91: Status of NAND flash access >> >> Hi, Bryan >> >> On 12/3/2012 10:39 PM, Bryan Evenson wrote: >>> I have a kernel build of 3.7-rc5 that is built for the AT91SAM9G25. >> The kernel has issues when it tries to read the filesystem from NAND >> flash. If I change to an NFS setup then the filesystem loads. >> According to your question, it is not very clear to me, so could you >> give more detail then I can help. >> >> What type (ubi, jffs2, or others) of your filesystem is used? How do >> you flush the file system into the nand flash, by SAM-BA, or U-Boot? >> With or without pmecc? >> And what ecc type (pmecc, soft, none) do you enabled in the kernel? >> > I have a UBI filesystem, built using OE (2011.03-maintenance branch). > I've been burning the filesystem to flash using SAM-BA, following the > instructions on the Atmel Linux4SAM site (on this page here: http://www.at91.com/linux4sam/bin/view/Linux4SAM/FlashRootFs_9x5). I checked the website, so your filesystem enable the PMECC with 2bits error bits. > > Here are all my MTD and filesystem related flags I have enabled in my > kernel configuration. If you see any missing that I should have set > for UBI access of NAND flash, please let me know. In your defconfig, the UBI filesystem is included. > > Also note that I am using the instructions found here to build this > kernel: http://www.eewiki.net/display/linuxonarm/AT91SAM9x5, which > means I am using the kernel extracted from the listed fork with the > listed patches applied. > > # > # Bus devices > # > CONFIG_MTD=y > CONFIG_MTD_CMDLINE_PARTS=y > CONFIG_MTD_OF_PARTS=y > > # > # User Modules And Translation Layers > # > CONFIG_MTD_CHAR=y > CONFIG_MTD_BLKDEVS=y > CONFIG_MTD_BLOCK=y > > # > # RAM/ROM/Flash chip drivers > # > CONFIG_MTD_MAP_BANK_WIDTH_1=y > CONFIG_MTD_MAP_BANK_WIDTH_2=y > CONFIG_MTD_MAP_BANK_WIDTH_4=y > CONFIG_MTD_CFI_I1=y > CONFIG_MTD_CFI_I2=y > > # > # Disk-On-Chip Device Drivers > # > CONFIG_MTD_NAND_ECC=y > CONFIG_MTD_NAND=y > CONFIG_MTD_NAND_IDS=y > CONFIG_MTD_NAND_ATMEL=y > > # > # LPDDR flash memory drivers > # > CONFIG_MTD_UBI=y > CONFIG_MTD_UBI_WL_THRESHOLD=4096 > CONFIG_MTD_UBI_BEB_LIMIT=20 > CONFIG_MTD_UBI_GLUEBI=y > CONFIG_DTC=y > CONFIG_OF=y > > # > # Device Tree and Open Firmware support > # > CONFIG_PROC_DEVICETREE=y > CONFIG_OF_FLATTREE=y > CONFIG_OF_EARLY_FLATTREE=y > CONFIG_OF_ADDRESS=y > CONFIG_OF_IRQ=y > CONFIG_OF_DEVICE=y > CONFIG_OF_I2C=y > CONFIG_OF_NET=y > CONFIG_OF_MDIO=y > CONFIG_OF_MTD=y > CONFIG_BLK_DEV=y > CONFIG_BLK_DEV_LOOP=y > CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 > > # > # File systems > # > CONFIG_EXT2_FS=y > CONFIG_EXT2_FS_XATTR=y > CONFIG_EXT2_FS_POSIX_ACL=y > CONFIG_EXT2_FS_SECURITY=y > CONFIG_EXT3_FS=y > CONFIG_EXT3_DEFAULTS_TO_ORDERED=y > CONFIG_EXT3_FS_XATTR=y > CONFIG_EXT3_FS_POSIX_ACL=y > CONFIG_EXT3_FS_SECURITY=y > CONFIG_EXT4_FS=y > CONFIG_EXT4_FS_XATTR=y > CONFIG_EXT4_FS_POSIX_ACL=y > CONFIG_EXT4_FS_SECURITY=y > CONFIG_JBD=y > CONFIG_JBD2=y > CONFIG_FS_MBCACHE=y > CONFIG_FS_POSIX_ACL=y > CONFIG_FILE_LOCKING=y > CONFIG_FSNOTIFY=y > CONFIG_DNOTIFY=y > CONFIG_INOTIFY_USER=y > CONFIG_FANOTIFY=y > CONFIG_GENERIC_ACL=y > > # > # Pseudo filesystems > # > CONFIG_PROC_FS=y > CONFIG_PROC_SYSCTL=y > CONFIG_PROC_PAGE_MONITOR=y > CONFIG_SYSFS=y > CONFIG_TMPFS=y > CONFIG_TMPFS_POSIX_ACL=y > CONFIG_TMPFS_XATTR=y > CONFIG_MISC_FILESYSTEMS=y > CONFIG_JFFS2_FS=y > CONFIG_JFFS2_FS_DEBUG=0 > CONFIG_JFFS2_FS_WRITEBUFFER=y > CONFIG_JFFS2_ZLIB=y > CONFIG_JFFS2_RTIME=y > CONFIG_UBIFS_FS=y > CONFIG_UBIFS_FS_ADVANCED_COMPR=y > CONFIG_UBIFS_FS_LZO=y > CONFIG_UBIFS_FS_ZLIB=y > CONFIG_NETWORK_FILESYSTEMS=y > CONFIG_NFS_FS=y > CONFIG_NFS_V2=y > CONFIG_NFS_V3=y > CONFIG_NFS_V3_ACL=y > CONFIG_NFS_V4=y > CONFIG_ROOT_NFS=y > CONFIG_NFS_USE_KERNEL_DNS=y > CONFIG_LOCKD=y > CONFIG_LOCKD_V4=y > CONFIG_NFS_ACL_SUPPORT=y > CONFIG_NFS_COMMON=y > CONFIG_SUNRPC=y > CONFIG_SUNRPC_GSS=y > CONFIG_NLS=y > CONFIG_NLS_DEFAULT="iso8859-1" > CONFIG_NLS_CODEPAGE_437=y > CONFIG_NLS_CODEPAGE_850=y > CONFIG_NLS_ISO8859_1=y > >>> I've seen some patches on this list lately related to AT91 NAND flash >> (specifically this thread: http://lists.infradead.org/pipermail/linux- >> arm-kernel/2012-November/133748.html) and I believe my problems may be >> related to this issue. But, I'm having trouble following the thread to >> find the current status. >>> Can anyone tell me what the status is on NAND flash access for the >> AT91 series with the 3.7-rc5 kernel? If this version has a known bug, >> is there a different suggested version I use that fixes the issue? >> In 3.7-rc5, I think the atmel nand driver should work well with >> AT91SAM9G25EK board even without the patch you mentioned in above URL. >> >> Just for PMECC, you need add following code in >> arch/arm/boot/dts/at91sam9x5cm.dtsi: >> - nand-ecc-mode = "soft"; >> + nand-ecc-mode = "hw"; >> + atmel,has-pmecc; /* Enable PMECC */ >> + atmel,pmecc-cap = <2>; /* PMECC error >> bits*/ >> + atmel,pmecc-sector-size = <512>; /* sector >> size for PMECC, it is not page size */ >> >> Also you can check the readme file in: >> Documentation/devicetree/bindings/mtd/atmel-nand.txt >> > I did not have the NAND flash setup correctly in the dtsi. I applied the patch > that you provided, rebuilt and reloaded my kernel. Unfortunately, the filesystem > is still not being read from flash correctly. It looks like the kernel > correctly identifies the NAND flash and sets up the partitions, but has problems > when it attempts to read out the filesystem. Here is the kernel boot output. > Do you see anything that tells you what may be going wrong? [ 1.226562] UBI: attaching mtd1 to ubi0 [ 1.230468] uncorrectable error : ^^^^^^^^^^^^ After checking the log, it shows the nand driver use the soft ecc. So the pmecc is not enable yet. Checking the 3.7-rc7, I found the patch I gave to you is not complete for pmecc enable, here is the whole patch to enable PMECC in dtsi. Please apply it and give me the feedback. Sorry for the missing of the part of at91sam9x5.dtsi. diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 0cc062b..32ca418 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -281,7 +281,11 @@ #address-cells = <1>; #size-cells = <1>; reg = <0x40000000 0x10000000 + 0xffffe000 0x600 /* PMECC Registers */ + 0xffffe600 0x200 /* PMECC Error Location Registers */ + 0x00100000 0x100000 /* ROM code */ >; + atmel,pmecc-lookup-table-offset = <0x8000 0x10000>; atmel,nand-addr-offset = <21>; atmel,nand-cmd-offset = <22>; gpios = <&pioD 5 0 diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi index 31e7be2..4027ac7 100644 --- a/arch/arm/boot/dts/at91sam9x5cm.dtsi +++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi @@ -26,7 +26,10 @@ ahb { nand0: nand@40000000 { nand-bus-width = <8>; - nand-ecc-mode = "soft"; + nand-ecc-mode = "hw"; + atmel,has-pmecc; /* Enable PMECC */ + atmel,pmecc-cap = <2>; + atmel,pmecc-sector-size = <512>; nand-on-flash-bbt; status = "okay";