xref: /openbmc/u-boot/doc/README.atmel_pmecc (revision 49ad40298cc5639436c6d490b699ecb60895ba2d)
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
23*49ad4029SDerald D. WoodsTake 'configs/at91sam9x5ek_nandflash_defconfig' as an example, the board
24*49ad4029SDerald D. Woodsconfiguration file has the following entries:
25bdfd59aaSWu, Josh
26*49ad4029SDerald D. Woods	CONFIG_PMECC_CAP=2
27*49ad4029SDerald D. Woods	CONFIG_PMECC_SECTOR_SIZE=512
28*49ad4029SDerald D. Woods	CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y
295c390a5bSAndreas Bießmann
305c390a5bSAndreas BießmannHow to enable PMECC header for direct programmable boot.bin
315c390a5bSAndreas Bießmann-----------------------------------------------------------
3209c2b8f3SAndreas Bießmann2014-05-19 Andreas Bießmann <andreas@biessmann.org>
335c390a5bSAndreas Bießmann
345c390a5bSAndreas BießmannThe usual way to program SPL into NAND flash is to use the SAM-BA Atmel tool.
355c390a5bSAndreas BießmannThis however is often not usable when doing field updates. To be able to
365c390a5bSAndreas Bießmannprogram a SPL binary into NAND flash we need to add the PMECC header to the
375c390a5bSAndreas Bießmannbinary before. Chapter '12.4.4.1 NAND Flash Boot: NAND Flash Detection' in
385c390a5bSAndreas Bießmannsama5d3 SoC spec (as of 03. April 2014) defines how this PMECC header has to
395c390a5bSAndreas Bießmannlook like. In order to do so we have a new image type added to mkimage to
405c390a5bSAndreas Bießmanngenerate this PMECC header and integrated this into the build process of SPL.
415c390a5bSAndreas Bießmann
42*49ad4029SDerald D. WoodsTo enable the generation of atmel PMECC header for SPL one needs to define
435c390a5bSAndreas BießmannCONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER. The required parameters are taken from
445c390a5bSAndreas Bießmannboard configuration and compiled into the host tools atmel_pmecc_params. This
455c390a5bSAndreas Bießmanntool will be called in build process to parametrize mkimage for atmelimage
465c390a5bSAndreas Bießmanntype. The mkimage tool has intentionally _not_ compiled in those parameters.
475c390a5bSAndreas Bießmann
485c390a5bSAndreas BießmannThe mkimage image type atmelimage also set the 6'th interrupt vector to the
495c390a5bSAndreas Bießmanncorrect value. This feature can also be used to setup a boot.bin for MMC boot.
50