xref: /OK3568_Linux_fs/u-boot/board/sunxi/README.nand (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunAllwinner NAND flashing
2*4882a593Smuzhiyun=======================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunA lot of Allwinner devices, especially the older ones (pre-H3 era),
5*4882a593Smuzhiyuncomes with a NAND. NANDs storages are a pretty weak choice when it
6*4882a593Smuzhiyuncomes to the reliability, and it comes with a number of flaws like
7*4882a593Smuzhiyunread and write disturbs, data retention issues, bloks becoming
8*4882a593Smuzhiyununusable, etc.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunIn order to mitigate that, various strategies have been found to be
11*4882a593Smuzhiyunable to recover from those issues like ECC, hardware randomization,
12*4882a593Smuzhiyunand of course, redundancy for the critical parts.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunThis is obviously something that we will take into account when
15*4882a593Smuzhiyuncreating our images. However, the BROM will use a quite weird pattern
16*4882a593Smuzhiyunwhen accessing the NAND, and will access only at most 4kB per page,
17*4882a593Smuzhiyunwhich means that we also have to split that binary accross several
18*4882a593Smuzhiyunpages.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunIn order to accomodate that, we create a tool that will generate an
21*4882a593SmuzhiyunSPL image that is ready to be programmed directly embedding the ECCs,
22*4882a593Smuzhiyunrandomized, and with the necessary bits needed to reduce the number of
23*4882a593Smuzhiyunbitflips. The U-Boot build system, when configured for the NAND will
24*4882a593Smuzhiyunalso generate the image sunxi-spl-with-ecc.bin that will have been
25*4882a593Smuzhiyungenerated by that tool.
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunIn order to flash your U-Boot image onto a board, assuming that the
28*4882a593Smuzhiyunboard is in FEL mode, you'll need the sunxi-tools that you can find at
29*4882a593Smuzhiyunthis repository: https://github.com/linux-sunxi/sunxi-tools
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunThen, you'll need to first load an SPL to initialise the RAM:
32*4882a593Smuzhiyunsunxi-fel spl spl/sunxi-spl.bin
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunLoad the binaries we'll flash into RAM:
35*4882a593Smuzhiyunsunxi-fel write 0x4a000000 u-boot-dtb.bin
36*4882a593Smuzhiyunsunxi-fel write 0x43000000 spl/sunxi-spl-with-ecc.bin
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunAnd execute U-Boot
39*4882a593Smuzhiyunsunxi-fel exe 0x4a000000
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunOn your board, you'll now have all the needed binaries into RAM, so
42*4882a593Smuzhiyunyou only need to erase the NAND...
43*4882a593Smuzhiyun
44*4882a593Smuzhiyunnand erase.chip
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunThen write the SPL and its backup:
47*4882a593Smuzhiyun
48*4882a593Smuzhiyunnand write.raw.noverify 0x43000000 0 40
49*4882a593Smuzhiyunnand write.raw.noverify 0x43000000 0x400000 40
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunAnd finally write the U-Boot binary:
52*4882a593Smuzhiyunnand write 0x4a000000 0x800000 0xc0000
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunYou can now reboot and enjoy your NAND.