1bdfd59aaSWu, JoshHow to enable PMECC(Programmable Multibit ECC) for nand on Atmel SoCs 2bdfd59aaSWu, Josh----------------------------------------------------------- 3bdfd59aaSWu, Josh2012-08-22 Josh Wu <josh.wu@atmel.com> 4bdfd59aaSWu, Josh 5bdfd59aaSWu, JoshThe Programmable Multibit ECC (PMECC) controller is a programmable binary 6bdfd59aaSWu, JoshBCH(Bose, Chaudhuri and Hocquenghem) encoder and decoder. This controller 7bdfd59aaSWu, Joshcan be used to support both SLC and MLC NAND Flash devices. It supports to 8bdfd59aaSWu, Joshgenerate ECC to correct 2, 4, 8, 12 or 24 bits of error per sector (512 or 9bdfd59aaSWu, Josh1024 bytes) of data. 10bdfd59aaSWu, Josh 11bdfd59aaSWu, JoshFollowing Atmel AT91 products support PMECC. 12bdfd59aaSWu, Josh- AT91SAM9X25, X35, G25, G15, G35 (tested) 13bdfd59aaSWu, Josh- AT91SAM9N12 (not tested, Should work) 14bdfd59aaSWu, Josh 15bdfd59aaSWu, JoshAs soon as your nand flash software ECC works, you can enable PMECC. 16bdfd59aaSWu, Josh 17bdfd59aaSWu, JoshTo use PMECC in this driver, the user needs to set: 18bdfd59aaSWu, Josh 1. the PMECC correction error bits capability: CONFIG_PMECC_CAP. 19bdfd59aaSWu, Josh It can be 2, 4, 8, 12 or 24. 20bdfd59aaSWu, Josh 2. The PMECC sector size: CONFIG_PMECC_SECTOR_SIZE. 21bdfd59aaSWu, Josh It only can be 512 or 1024. 22bdfd59aaSWu, Josh 23bdfd59aaSWu, JoshTake AT91SAM9X5EK as an example, the board definition file likes: 24bdfd59aaSWu, Josh 25bdfd59aaSWu, Josh/* PMECC & PMERRLOC */ 26bdfd59aaSWu, Josh#define CONFIG_ATMEL_NAND_HWECC 1 27bdfd59aaSWu, Josh#define CONFIG_ATMEL_NAND_HW_PMECC 1 28bdfd59aaSWu, Josh#define CONFIG_PMECC_CAP 2 29bdfd59aaSWu, Josh#define CONFIG_PMECC_SECTOR_SIZE 512 30*5c390a5bSAndreas Bießmann 31*5c390a5bSAndreas BießmannHow to enable PMECC header for direct programmable boot.bin 32*5c390a5bSAndreas Bießmann----------------------------------------------------------- 33*5c390a5bSAndreas Bießmann2014-05-19 Andreas Bießmann <andreas.devel@googlemail.com> 34*5c390a5bSAndreas Bießmann 35*5c390a5bSAndreas BießmannThe usual way to program SPL into NAND flash is to use the SAM-BA Atmel tool. 36*5c390a5bSAndreas BießmannThis however is often not usable when doing field updates. To be able to 37*5c390a5bSAndreas Bießmannprogram a SPL binary into NAND flash we need to add the PMECC header to the 38*5c390a5bSAndreas Bießmannbinary before. Chapter '12.4.4.1 NAND Flash Boot: NAND Flash Detection' in 39*5c390a5bSAndreas Bießmannsama5d3 SoC spec (as of 03. April 2014) defines how this PMECC header has to 40*5c390a5bSAndreas Bießmannlook like. In order to do so we have a new image type added to mkimage to 41*5c390a5bSAndreas Bießmanngenerate this PMECC header and integrated this into the build process of SPL. 42*5c390a5bSAndreas Bießmann 43*5c390a5bSAndreas BießmannTo enable the generation of atmel PMECC header for SPL one need to define 44*5c390a5bSAndreas BießmannCONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER. The required parameters are taken from 45*5c390a5bSAndreas Bießmannboard configuration and compiled into the host tools atmel_pmecc_params. This 46*5c390a5bSAndreas Bießmanntool will be called in build process to parametrize mkimage for atmelimage 47*5c390a5bSAndreas Bießmanntype. The mkimage tool has intentionally _not_ compiled in those parameters. 48*5c390a5bSAndreas Bießmann 49*5c390a5bSAndreas BießmannThe mkimage image type atmelimage also set the 6'th interrupt vector to the 50*5c390a5bSAndreas Bießmanncorrect value. This feature can also be used to setup a boot.bin for MMC boot. 51