Enabling NAND On-Die ECC for OMAP3 Using Linux/Android OS with YAFFS2

Similar documents
Technical Note. Enabling On-Die ECC NAND with JFFS2. Introduction. TN-29-75: Enabling On-Die ECC NAND with JFFS2. Introduction.

How to handle the spare-byte area of Macronix 36nm NAND Flash

Monitoring Ready/Busy Using the READ STATUS (70h) Command

Technical Note. One-Time Programmable (OTP) Operations. Introduction. TN-29-68: 2Gb: x8, x16 NAND Flash Memory. Introduction

NAND Flash Performance Improvement Using Internal Data Move

Technical Note NAND Flash Performance Increase with PROGRAM PAGE CACHE MODE Command

Overview. TN-29-08: Hamming Codes for NAND Flash Memory Devices Overview

Technical Note. SMART Command Feature Set for the eu500. Introduction. TN-FD-35: eu500 eusb SMART Commands. Introduction

MT29F4G08AAA, MT29F8G08BAA, MT29F8G08DAA, MT29F16G08FAA, MT29F8G08MAA, MT29F16G08QAA,

SMART Self-Test Reference for P400e SATA SSDs

Command Register Settings Description Notes

Technical Note. Client SATA SSD SMART Attribute Reference. Introduction. TN-FD-22: Client SATA SSD SMART Attribute Reference.

1 The Linux MTD, YAFFS Howto

Maximum Monolithic Density Density Number of Stacks N25Q512Axxx. 512Mb 2 256Mb N25Q00AAxxx 1Gb 4 MT25Qxs01Gxxx. 1Gb 2 512Mb MT25Qxs02Gxxx 2Gb 4

User Guide. Storage Executive. Introduction. Storage Executive User Guide. Introduction

OMAP3530 has 256MB NAND flash in PoP (PoP: Package-On-Package implementation for Memory Stacking) configuration.

Technical Note. SMART Command Feature Set for the Introduction. TN-FD-34: 5100 SSD SMART Implementation. Introduction

Enabled (both during preconditioning and measurement) 4KB for random writes, 2MB for sequential writes

Technical Note. SMART Command Feature Set for the M510DC. Introduction. TN-FD-33: M510DC SSD SMART Implementation. Introduction

NAND/MTD support under Linux

Technical Note. Maximize SPI Flash Memory Design Flexibility With a Single Package. Introduction

Technical Note. Improving Random Read Performance Using Micron's SNAP READ Operation. Introduction. TN-2993: SNAP READ Operation.

How to Power On and Power Off the M29F Flash Memory Device

ONFI Standards and What They Mean to Designers

Technical Note. SMART Command Feature Set for the M500DC. Introduction. TN-FD-26: M500DC SSD SMART Implimentation. Introduction

Technical Note. Reset Configurations for MT25Q, MT25T, and N25Q Flash Memory Devices. Introduction

User Guide. Storage Executive Command Line Interface. Introduction. Storage Executive Command Line Interface User Guide Introduction

Power-Up, Power-Down, and Brownout Considerations on MT25Q, MT25T, and MT35X NOR Flash Memory

Comparing Micron N25Q and Macronix MX25L Flash Devices

Technical Note. Migrating from Micron M25PE to Micron MT25Q 128Mb. Introduction. TN-25-36: Migrating from M25PE to MT25Q 128Mb.

Technical Note Using Micron Asynchronous PSRAM with the NXP LPC2292 and LPC2294 Microcontrollers

ESP8266 Application Note Firmware Download Protocol

Open NAND Flash Interface Specification: Block Abstracted NAND

Technical Note. Adding ECC to a Data Bus with DDR4 x16 Components. Introduction. TN-40-41: Adding ECC With DDR4 x16 Components.

Common Flash Interface (CFI) and Command Sets

Technical Note. Migrating from Micron M25P to Micron MT25Q 128Mb. Introduction. TN-25-34: Migrating from M25P to MT25Q 128Mb.

Technical Note. Comparing Micron N25Q and M25P Flash Devices. Introduction. TN-12-12: Comparing N25Q and M25P Flash Devices.

Technical Note. J3F 32Mb, 64Mb, 256Mb Parallel NOR Flash Memory Software Device Drivers. Introduction. TN-12-50: J3F Software Device Drivers

Technical Note. Migrating from Micron M29W Devices to MT28EW NOR Flash Devices. Introduction. TN-13-50: Migrating M29W to MT28EW NOR Flash Devices

Technical Note Designing for High-Density DDR2 Memory

Migrating from Spansion S25FL512S to Micron N25Q 512Mb Flash Device

Technical Note Using CellularRAM to Replace UtRAM

2. General Features The two devices have a different page size and block size. Feature differences are highlighted in Bold Italic type in Table 2-1.

Comparing Toshiba TC58BVG1S3HTAI0 with Macronix MX30LF2GE8AB

Modernizing the NAND framework: The big picture

Technical Note. Migrating from Cypress's FL-S and FS-S to Micron's MT25Q. Introduction

smxnand RTOS Innovators Flash Driver General Features

Technical Note. Refresh Features for Micron e.mmc Automotive 5.0 Devices. Introduction. TN-FC-54: Refresh Features for e.mmc Automotive 5.

Migrating from Macronix MX29GL-G/F and MX68GL-G Devices to MT28EW NOR Flash Devices

Migrating from Spansion Am29F to Micron M29F NOR Flash Memories

Migrating from MX30LF1G08AA to MX30LF1GE8AB

CODE TIME TECHNOLOGIES. mabassi RTOS. BSP Document. ARMv7 Caches (GCC)

SPI Nand flash controller

Technical Note. ONFI 4.0 Design Guide. Introduction. TN-29-83: ONFI 4.0 Design Guide. Introduction

NAND Flash Architecture and Specification Trends

Kinetis Bootloader to Update Multiple Devices in a Field Bus Network

NAND Design-In Notice

Comparing Spansion S34ML04G100 with Macronix MX30LF4G18AC

AN4491 Application note

High Performance Real-Time Operating Systems

Changing the i.mx51 NAND Flash Model for Windows Embedded CE TM 6.0

Migrating from MX30LF1G08AA to MX30LF1G18AC

Migrating from MX60LF8G28AB to MX60LF8G18AC

Flash File Systems Overview

Enhanced Serial Peripheral Interface (espi)

Datasheet. Embedded Storage Solutions. Industrial. SATA III 2.5 Solid State Drive. SED2FV Series. V Aug

Migrating from MX30LF2G(4G)28AB to MX30LF2G(4G)18AC

High-Speed NAND Flash

PARAMETER SYMBOL MIN MAX Address Access Time

Image Sensor Demo System Kits

The UtePC/Yalnix Memory System

AN LPC1700 secondary USB bootloader. Document information. LPC1700, Secondary USB Bootloader, ISP, IAP

Technical Note. Booting from Embedded MMC (e.mmc) Introduction. TN-FC-06: Booting from Embedded MMC. Introduction

Technical Note Using CellularRAM Memory to Replace Single- and Dual-Chip Select SRAM

CPU-1450; ISA Bus BIOS Settings Rev. 1.0 Nov. 04 COPYRIGHT Eurotech S.p.A. All Rights Reserved.

Technical Note. Micron N25Q to Micron MT25Q Migration. Introduction. TN-25-01: Micron N25Q to Micron MT25Q Migration. Introduction

Technical Note. Software Driver for M29EW NOR Flash Memory. Introduction. TN-13-12: Software Driver for M29EW NOR Flash Memory.

Understanding UFFS. Ricky Zheng < > Created: March 2007 Last modified: Nov 2011

Technical Note. Refresh Features for Micron e.mmc Automotive 5.1 Devices. Introduction. TN-FC-60: Refresh Features for e.mmc Automotive 5.

Datasheet. Embedded Storage Solutions. Industrial. SATA III 2.5 Solid State Drive. SED2FIV Series CSXXXXXRC-XX09XXXX. 04 Jul 2016 V1.

A33 Nand Flash Controller Specification

Smart Array Controller technology: drive array expansion and extension technology brief

NAND Flash Module DESCRIPTION: FEATURES: 69F12G24, 69F24G24

Getting Started with the MCU Flashloader

Spansion SLC NAND Flash Memory for Embedded

Comparing UFS and NVMe Storage Stack and System-Level Performance in Embedded Systems

Datasheet. Embedded Storage Solutions. Industrial. SATA III 2.5 Solid State Drive. SED2FV Series. V Aug

User Guide. Micron NAND Flash Simulator (NSIM)

IRON FOR JFFS2. Raja Ram Yadhav Ramakrishnan, Abhinav Kumar. { rramakrishn2, ABSTRACT INTRODUCTION

Datasheet. Embedded Storage Solutions. Industrial. SATA III 2.5 Solid State Drive. SED2FIV Series CSXXXXXRC-XX10XXXX. 22 Aug 2017 V1.

Micron part numbers e MMC registers Multilevel cell (MLC) to single-level cell (pslc) setting flow

Technical Note DDR2 (Point-to-Point) Package Sizes and Layout Basics

Chapter 8 Main Memory

Digi-Star ISOBUS / CAN Application Notes

FLASH Programming in Production of VS1000 Applications

AT09381: SAM D - Debugging Watchdog Timer Reset. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

Keywords: maxq microcontrollers, data flash, in-application programming, in circuit programming, flash, microcontroller, MAXQ7663, MAXQ7664

J1939 user manual. Summary: PowerKey pro series

ESMT (Preliminary) F50L2G41XA (2B)

CANopen. stepim. Reference Manual. Manual Revision: 1.3 Firmware Version:

Transcription:

Introduction Enabling NAND On-Die ECC for OMAP3 Using Linux/Android OS with YAFFS2 Introduction Considerations Process shrinks on the newest generations of NAND Flash devices have lead to a gradual increase in the frequency of random data bit errors the longer a device is in use. To provide newest-generation devices with the same longevity as earlier NAND Flash devices, ECC enhancements to increase fault tolerance are required. Most new processor designs anticipate coupling with NAND Flash devices, and include 4-bit and greater ECC engines within the hardware itself. Some existing processor designs only support 1-bit ECC. This document addresses applications using these existing 1-bit ECC processors. It includes instructions for enabling/disabling Micron on-die ECC, describes mapping for the internal ECC and spare area, and provides an example for enabling the NAND Flash 4-bit on-die ECC feature on a TI OMAP3 platform with the Linux/Android operating system and the YAFFS2 file system (see Appendix: Codebase Modification Example on page 4). Micron NAND Flash MT29F1GxxABxDA, MT29F2GxxABxEA, and MT29F4GxxABxDA devices each include 4-bit on-die ECC, providing enhanced performance for applications using a board that supports only 1-bit ECC. There are two potential trade-offs associated with on-die ECC use; the first is speed. Processor-supported hardware ECC engines are typically very fast due to faster clock speeds compared to on-die ECC implementations. The second potential trade-off is device longevity vs. speed. With NAND Flash memory, as a general rule for designs based on older processors, designers must make a choice between shorter usable life employing 1-bit ECC, or slower performance using 4-bit ondie ECC. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 1 2010 Micron Technology, Inc. All rights reserved. Products and specifications discussed herein are for evaluation and reference purposes only and are subject to change by Micron without notice. Products are only warranted by Micron to meet Micron s production data sheet specifications. All information discussed herein is provided on an as is basis, without warranties of any kind.

Enabling/Disabling On-Die ECC TN-29-56: Enabling On-Die ECC for OMAP3 on Linux/Android OS Enabling/Disabling On-Die ECC Internal ECC can be enabled/disabled using SET FEATURES (EFh). The EFh command, followed by address 90h, followed by four data bytes (only the first data byte is used) will enable/disable internal ECC. To confirm the state of the internal ECC, issue the GET FEATURES (EEh) command. Table 1: Enabling/Disabling Command Sequences Using EFh Action Enable on-die ECC with EFh Disable on-die ECC with EFh Confirm the internal ECC state, then check the first data byte for enablement Command Sequence EFh-90h- 08h-00h-00h-00h-wait EFh-90h- 00h-00h-00h-00h-wait EEh-90h-wait -read 1 -read -read -read Notes: 1. Only this data byte is used; the others are reserved. The on-die ECC state is defined as: 08h = enabled, 00h = disabled Internal ECC and Spare Area Mapping for ECC Internal ECC enables 5-bit detection and 4-bit error correction in 512 bytes (x8) or 256 words (x16) of the main area and 4 bytes (x8) or 2 words (x16) of metadata I in the spare area. The metadata II area, which consists of two bytes (x8) and one word (x16), is not ECC protected. During the busy time for PROGRAM operations, internal ECC generates parity bits when error detection is complete. See Figure 1 and Figure 2 on page 3 for x8 and x 16 spare-area mapping. During READ operations the device executes the internal ECC engine (5-bit detection and 4-bit error correction). When the READ operation is complete, read status bit 0 must be checked to determine whether errors larger than four bits have occurred. Following the READ STATUS command, the device must be returned to read mode by issuing the 00h command. Limitations of internal ECC include the spare area, defined in the figures below, and ECC parity areas that cannot be written to. Each ECC user area (referred to as main and spare) must be written within one partial-page program so that the NAND device can calculate the proper ECC parity. The number of partial-page programs within a page cannot exceed four. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 2 2010 Micron Technology, Inc. All rights reserved.

Internal ECC and Spare Area Mapping for ECC Figure 1: Spare Area Mapping (x8) Max Byte Min Byte Address Address ECC Protected Area Description 1FFh 000h Yes Main 0 User data 3FFh 200h Yes Main 1 User data 5FFh 400h Yes Main 2 User data 7FFh 600h Yes Main 3 User data 801h 800h No Reserved 803h 802h No User metadata II 807h 804h Yes Spare 0 User metadata I 80Fh 808h Yes Spare 0 ECC for main/spare 0 811h 810h No Reserved 813h 812h No User metadata II 817h 814h Yes Spare 1 User metadata I 81Fh 818h Yes Spare 1 ECC for main/spare 1 821h 820h No Reserved 823h 822h No User metadata II 827h 824h Yes Spare 2 User metadata I 82Fh 828h Yes Spare 2 ECC for main/spare 2 831h 830h No User data 833h 832h No User metadata II 837h 834h Yes Spare 3 User metadata I 83Fh 838h Yes Spare 3 ECC for main/spare 3 Bad Block ECC User Data Information Parity (Metadata) 2 bytes 8 bytes 6 bytes Figure 2: Spare Area Mapping (x16) Max word Min word Address Address ECC Protected Area Description 0FFh 000h Yes Main 0 User data 1FFh 100h Yes Main 1 User data 2FFh 200h Yes Main 2 User data 3FFh 300h Yes Main 3 User data 400h 400h No Reserved 401h 401h No User metadata II 403h 402h Yes Spare 0 User metadata I 407h 404h Yes Spare 0 ECC for main/spare 0 408h 408h No Reserved 409h 409h No User metadata II 40Bh 40Ah Yes Spare 1 User metadata I 40Fh 40Ch Yes Spare 1 ECC for main/spare 1 410h 410h No Reserved 411h 411h No User metadata II 413h 412h Yes Spare 2 User metadata I 417h 414h Yes Spare 2 ECC for main/spare 2 418h 418h No User data 419h 419h No User metadata II 41Bh 41Ah Yes Spare 3 User metadata I 41Fh 41Ch Yes Spare 3 ECC for main/spare 3 Bad Block ECC User Data Information Parity (Metadata) 1 word 4 words 3 words tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 3 2010 Micron Technology, Inc. All rights reserved.

Appendix: Codebase Modification Example Appendix: Codebase Modification Example The balance of this technical note describes the necessary changes to the OMAP3530 Beagleboard codebase to enable NAND Flash 4-bit on-die ECC. Components used in this example are described in Table 2 on page 4. The reader should have an understanding of the standard Linux/Android kernel and the bootloader building procedure, plus appropriate NAND Flash knowledge and the data sheet for the specific device(s) to be enabled. Micron technical note TN-29-45 provides instructions for enabling/disabling on-die ECC, and is available at www.micron.com. Table 2: Example Configuration Micron NAND Flash Platform Device Size Spare Area Linux Kernel Version ARM Cross-Compiler OMAP3530 Beagleboard 1 MT29F4G16ABxDA 64 bytes OOB 2 2.6.29 Date: 2008q3 Notes: 1. Subsequent testing on the OMAP3430SDP and the OMAP3430/OMAP 3630 Zoom platforms were also successful. 2. OOB = out-of-band; part of the spare area in NAND Flash reserved for error detection/correction code. Device Code and Hardware Changes X-Loader (MLO) Change Sequence Step 1: Step 2: Step 3: Step 4: U-Boot Change Sequence On-die ECC enablement requires changes to X-Loader, U-Boot, and Kernel (uimage) code. This section provides a high-level view of necessary changes for each application. Also note that changes must be made to the OOB (spare) area layout of each page. This enables YAFFS2 to coexist with the ECC data in the OOB area (see Table 4 on page 13). Add the NAND Flash SET/GET FEATURES commands. Use the NAND Flash SET FEATURES to enable the on-die ECC. Disable standard hardware and software ECC. Verify that NAND Flash timing requirements are met. There are both mandatory and optional changes for U-Boot, presented in sequence as follows: Mandatory Changes: Step 1: Step 2: Step 3: Optional Changes: Step 4: Disable standard hardware and software ECC. Verify that NAND Flash timing requirements (tr::tr_ecc) are met. (In Micron testing/example, no changes were required; the default delay for t R was set to 100µs.) Check status for ECC fails after each READ operation. Add code to check whether on-die ECC was enabled by X-Loader and switch ECC mode accordingly. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 4 2010 Micron Technology, Inc. All rights reserved.

Step 5: Modify the OOB layout to accommodate the new ECC map. (Required if the U-Boot will perform any NAND Flash WRITEs from within the U-Boot.) Kernel (uimage) Change Sequence Step 1: Disable standard hardware and software ECC. Step 2: Modify the OOB layout to accommodate the new ECC map. Step 3: Poll for status after READ (required after every READ); check for errors beyond the 4 handled by the on-die ECC. When an error is logged, there is some form of data corruption. Step 4: Verify that NAND Flash timing requirements are met, with sufficient time to complete the required status check. Source Code Notes Caution 1 X-Loader (MLO): The code samples and descriptions that follow present one method for enabling on-die ECC. While some of the items mentioned are mandatory, others are not. For instance, where the on-die ECC is turned on in X-load is irrelevant, as long as it is turned on. The reader is encouraged to use initiative when placing function calls; use the most efficient locations in the code for the individual customer application. Disclaimer: There many variations in Linux source code. The code changes are generally subtle and may be difficult to identify because the end result for each version is the same. This can make integrating code somewhat challenging. The changes noted for the source code file names, and other indicated differences are for the Linux version shown in Table 2 on page 4; the reader may not encounter exactly the same paths or files when using a different version. Note that some porting may be required. In the following code references necessary changes in the snippets are indicated by red text. 1.1 File: /include/common.h (Add #defines where other NAND_CMDs are located for the GET/SET FEATURES commands.) 1.1.1 Add the following definitions: #define NAND_CMD_READID 0x90 #define NAND_CMD_GET_FEATURES 0xEE /* ONFI */ #define NAND_CMD_SET_FEATURES 0xEF #define NAND_CMD_RESET 0xff Note: GET FEATURES and SET FEATURES commands are defined by ONFI as optional commands in the ONFI 1.0 specification. For ONFI definitions and specifications, see the ONFI Web site at www.onfi.org. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 5 2010 Micron Technology, Inc. All rights reserved.

1.2 File: /drivers/k9f1g08r08.c 1.2.1 Comment out the line: #define ECC_CHECK_ENABLE 1.2.2 Check in the function: nand_read_block() If the action in 1.2.1 disabled the bad block check, force it back on. Use a new #define or remove these directives: #ifdef/#endif 1.2.3 Add in nand_chip(); after READID and before NAND_DISABLE_CE(): set_on_die_ecc(); /* MICRON */ 1.2.4 Add new function: set_on_die_ecc() with prototype somewhere in File: /drivers/k9f1g08r08.c The GET FEATURES command call can also be added here to validate that on-die ECC is activated. void set_on_die_ecc() /* MICRON */ { Int i,addr = 0x90; u16 data_out = 0x8; /* MICRON Send CMD #EF ADDR 08 00 00 00 */ if (NanD_Command(NAND_CMD_SET_FEATURES)) { printf("error: On-Die ECC\n"); NanD_Address(1, addr); delay(100); for(i=0; i<8; i++,data_out=0x0) WRITE_NAND(data_out, NAND_ADDR); delay(1000); return; 1.2.5 Increase delay in nand_read_page() and nand_read_oob() to account for tr_ecc; the delay is placed immediately following NAND_WAIT_READY(): Old: delay(10000); New: delay(20000); In this example, 20000 measured 80µs, exceeding the minimum required 70µs tr_ecc. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 6 2010 Micron Technology, Inc. All rights reserved.

2 U-Boot 2.1 Mandatory Changes to File: /drivers/mtd/nand/omap_gpmc.c 2.1.1 In function board_nand_init(), change ecc.mode to NONE nand->ecc.mode = NAND_ECC_NONE; 2.1.2 In function board_nand_init(), verify that the chip delay satisfies the new tr_ecc value: nand->chip_delay = 100; 2.2 File: /drivers/mtd/nand/nand_base.c (also found at /drivers/mtd/nand.c in some code). In function nand_command_lp(), add the following code to check the status after each READ operation. case NAND_CMD_READ0: chip->cmd_ctrl(mtd, NAND_CMD_READSTART, NAND_NCE NAND_CLE NAND_CTRL_CHANGE); chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE NAND_CTRL_CHANGE); udelay(chip->chip_delay); chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); if(chip->read_byte(mtd) & 0x01){/* MICRON: check error bit */ printf("error: ON-DIE ECC READ FAILURE\n"); // do something here to handle the failure. /* MICRON: restore to data out */ chip->cmd_ctrl(mtd, NAND_CMD_READ0, NAND_NCE NAND_CLE NAND_CTRL_CHANGE); chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE NAND_CTRL_CHANGE); return; /* This applies to read commands */ default: tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 7 2010 Micron Technology, Inc. All rights reserved.

2.3 Optional Changes to File: /drivers/mtd/nand/nand_base.c (also found at /drivers/mtd/nand.c in some code). To intelligently switch the ECC status based on the on-die ECC, add this group: 2.3.1 Define value for GET_FEATURES NAND_CMD. Optionally, this can also be added to ' /include/linux/mtd/nand.h' with other NAND_CMD defines. #define NAND_CMD_GET_FEATURES 0xEE /* MICRON */ 2.3.1.1 To enable the GET FEATURES command, add the following snip into nand_command_lp(). if (column!= -1 page_addr!= -1) { int ctrl = NAND_CTRL_CHANGE NAND_NCE NAND_ALE; /* MICRON: Single ADDRESS Sequence for GET_FEATURES */ if(command == NAND_CMD_GET_FEATURES) { chip->cmd_ctrl(mtd, column, ctrl); /* Serially input address */ else { if (column!= -1) { /* Adjust columns for 16 bit buswidth */ if (chip->options & NAND_BUSWIDTH_16) column >>= 1; chip->cmd_ctrl(mtd, column, ctrl); ctrl &= ~NAND_CTRL_CHANGE; chip->cmd_ctrl(mtd, column >> 8, ctrl); 2.3.1.2 To test for on-die ECC enabled, add function and prototype as needed. Place function call where the test can be utilized; i.e., in nand_read(). /* ############################################## */ /* MICRON: Test on-die ECC status; return: 1/On or 0/Off */ int test_on_die_ecc(struct mtd_info *mtd) { struct nand_chip *chip = mtd->priv; int addr = 0x90; uint8_t data; chip->cmdfunc(mtd,nand_cmd_get_features,addr,-1); tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 8 2010 Micron Technology, Inc. All rights reserved.

ndelay(1000); data = chip->read_byte(mtd); return((data & 0x08)? 1 : 0 ); 2.3.1.3 To provide ECC disabling, add external function prototype: extern void omap_nand_switch_ecc(int32_t); 2.3.1.4 To disable ECC, add this code somewhere after NAND initialization and before READ; i.e., before the start of nand_read(). This is also the place to add the optional ECC test. Note that value passed to omap_nand_switch_ecc() is a new case added to that function. if(chip->ecc.mode!= NAND_ECC_NONE && test_on_die_ecc(mtd)) { omap_nand_switch_ecc(2); 2.4 File: /drivers/mtd/nand/omap_gpmc.c In function board_nand_init(), undo the changes made to ecc.mode in section 2.1.1. The mode will be selected later. 2.4.1 In function omap_nand_switch(), add an if clause for a new mode, NONE. /* Setup the ecc configurations again */ /* MICRON */ if (hardware == 2) { // noecc using on-die nand->ecc.mode = NAND_ECC_NONE; nand->ecc.layout = NULL; printf("info:: NO ECC selected\n"); else if (hardware) { nand->ecc.mode = NAND_ECC_HW; nand->ecc.layout = &hw_nand_oob; tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 9 2010 Micron Technology, Inc. All rights reserved.

2.5 File: /drivers/mtd/nand/nand_base.c. If writing to NAND while in U-Boot, the OOB layout must change. Replace the existing nand_oob_64 layout structure with the following new one: /* MICRON: modified OOB Layout */ static struct nand_ecclayout nand_oob_64 = {.eccbytes = 32,.eccpos = { 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 40, 41, 42, 43, 44, 45, 46, 47, 56, 57, 58, 59, 60, 61, 62, 63, ;.oobfree = { {.offset = 4,.length = 4, {.offset = 20,.length = 4, {.offset = 36,.length = 4, {.offset = 52,.length = 4,, tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 10 2010 Micron Technology, Inc. All rights reserved.

3 Kernel (uimage): 3.1 File: /drivers/mtd/nand/omap2.c 3.1.1 In function, omap_nand_probe(), set the ECC to NONE. TN-29-56: Enabling On-Die ECC for OMAP3 on Linux/Android OS info->nand.ecc.mode = NAND_ECC_NONE; 3.2 File: /drivers/mtd/nand/nand_base.c Replace the old OOB layout data structure with the new configuration: static struct nand_ecclayout nand_oob_64 = {.eccbytes = 32,.eccpos = { 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 40, 41, 42, 43, 44, 45, 46, 47, 56, 57, 58, 59, 60, 61, 62, 63, ;.oobfree = { {.offset = 4,.length = 4, {.offset = 20,.length = 4, {.offset = 36,.length = 4, {.offset = 52,.length = 4,, 3.2.1 In function nand_command_lp(), in the switch(command) statement, declare variables to be used while polling for status. switch (command) { int status,cnt; /* MICRON: local vars used */ case NAND_CMD_CACHEDPROG: tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 11 2010 Micron Technology, Inc. All rights reserved.

3.2.1.1 Following NAND_CMD_READSTAR (after CMD #30 is issued), start polling for a READY status. Poll at least as long as the tr_ecc value. After READY is returned, check the ECC ERROR status. Readers will have to decide what to do for their specific applications when an ERROR is present. case NAND_CMD_READ0: chip->cmd_ctrl(mtd, NAND_CMD_READSTART, NAND_NCE NAND_CLE NAND_CTRL_CHANGE); chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE NAND_CTRL_CHANGE); /* MICRON: wait until part RDY; tr_ecc max */ for(cnt=0; cnt<70; cnt++) { ndelay(1000); /* 1 usec delay */ chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); status = chip->read_byte(mtd); if( (status & NAND_STATUS_READY ) ) break; /* MICRON: Look for STATUS bit ERR */ if( (status & NAND_STATUS_FAIL) ) { printk(kern_warning "WARNING :: READ Operation ECC Error: 0x%02x delay %d usec\n", status,cnt+1); /* do something on fail */ /* MICRON: re-issue CMD0 after STATUS Check */ chip->cmd_ctrl(mtd, NAND_CMD_READ0, NAND_NCE NAND_CLE NAND_CTRL_CHANGE); chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE NAND_CTRL_CHANGE); /* This applies to read commands */ default: tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 12 2010 Micron Technology, Inc. All rights reserved.

Configuration Requirements On-Die ECC Requirements TN-29-56: Enabling On-Die ECC for OMAP3 on Linux/Android OS Configuration Requirements As noted previously, a modified out-of-band (OOB) layout is required for YAFFS2 to work properly with 4-bit on-die ECC. On-die ECC allocation requirements are listed in Table 3 and a graphic representation is provided in Table 4. Table 3: OOB Layout Requirements for On-Die ECC (per 2KB Page) Allocation Required Area OOB available bytes 64 bytes OOB bytes reserved for bad-block marking 8 bytes OOB bytes not covered by ECC 8 bytes OOB parity bytes required for on-die ECC 32 bytes OOB bytes available, covered by on-die ECC 16 bytes OOB bytes required by YAFFS2 1 14 bytes Notes: 1. See Table 5 on page 14. Table 4: 64B Per 2KB Page, OOB (Spare) Area Usage OOB/Spare Area: Standard Use OOB/Spare Area: with On-Die ECC Use 0 1 2 0 1 2 62 63 62 63 Reserved bytes per data sheet ECC parity bytes used by NAND. ECC protected YAFFS2 metadata bytes Unused bytes not covered by ECC. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 13 2010 Micron Technology, Inc. All rights reserved.

YAFFS2 Requirements TN-29-56: Enabling On-Die ECC for OMAP3 on Linux/Android OS NAND Loading Considerations: YAFFS2 requires 14 bytes of metadata per 2KB page. (ECC bytes are omitted in this example because the device provides the ECC (see Table 5.) YAFFS2 metadata requirements are provided in Table 5. Using a modified OOB layout, YAFFS2 can store metadata in the 16 bytes covered by the on-die ECC. This makes it possible to omit YAFFS2-specific ECC bytes. The available metadata area is interlaced with the on-die ECC bytes to enable YAFFS2 functionality. Table 5: YAFFS2 Requirements for On-Die ECC Required Allocation 32-bit chunk ID 32-bit object ID Number of data bytes in YAFFS2 chunk Sequence number for this block ECC on tags ECC on data Required Area 4 bytes 4 bytes 2 bytes 4 bytes Former 3 bytes not required Former 12 bytes not required NAND Loading Considerations: Care should be taken when programming X-Loader, U-Boot, etc. into the NAND Flash device. The loader code used to program the NAND Flash may require modifications, depending on the method used to program the device. Table 6 lists the necessary partitions and settings for proper use. Loading requirements are as follows: X-Loader must be programmed with 1-bit hardware ECC enabled. The 4-bit on-die ECC must be enabled prior to any programming. (The loader must be configured to enable/disable the on-die ECC feature.) Table 6: Partition Settings and Loading Requirements Typical MTD Partition NAND State During Flow Name NAND Addr Program Use 1 X-Loader 0x0 (Block 0) Hardware 1-bit ECC Hardware 1-bit ECC 2 U-Boot 0x0080000 On-die 4-bit ECC On-die 4-bit ECC 2.1 U-Boot ENV 0x01C0000 On-die 4-bit ECC On-die 4-bit ECC 3 Kernel 0x0200000 On-die 4-bit ECC On-die 4-bit ECC 3.1 File System 0x2000000 On-die 4-bit ECC On-die 4-bit ECC 3.2 User Data 0xC000000 On-die 4-bit ECC On-die 4-bit ECC 3.2 Cache 0xE000000 On-die 4-bit ECC On-die 4-bit ECC tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 14 2010 Micron Technology, Inc. All rights reserved.

Summary Summary This technical note describes one method of enabling 4-bit on-die ECC in Micron NAND Flash MT29F1GxxABxDA, MT29F2GxxABxEA, and MT29F4GxxABxDA devices for designers using processors that normally provide only 1-bit ECC. Using 4-bit on-die ECC in this way can help to extend the life of the NAND Flash device. Because designs differ, each application may require some unique code development. In applications where the processor only supports 1-bit ECC, using Micron NAND Flash with 4-bit on-die ECC can give designers greater flexibility in their designs, along with increased longevity for the device. 8000 S. Federal Way, P.O. Box 6, Boise, ID 83707-0006, Tel: 208-368-3900 www.micron.com/productsupport Customer Comment Line: 800-932-4992 Micron and the Micron logo are trademarks of Micron Technology, Inc. All other trademarks are the property of their respective owners. tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 15 2010 Micron Technology, Inc. All rights reserved.

Revision History TN-29-56: Enabling On-Die ECC for OMAP3 on Linux/Android OS Revision History Rev. A..............................................................................................12/10 Initial release tn2956_ondie_ecc_omap3_linux.fm - Rev. A 12/10 EN 16 2010 Micron Technology, Inc. All rights reserved.