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