Tom Rini 3aaabfe9ff Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi 2 jaren geleden
..
MAINTAINERS 3aaabfe9ff Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi 2 jaren geleden
Makefile 6c2c7e9cb9 arm: sunxi: add support for DIP detection to CHIP board 3 jaren geleden
README.nand 88718be300 mtd: rename CONFIG_NAND -> CONFIG_MTD_RAW_NAND 4 jaren geleden
README.sunxi64 e72a6be4fc sunxi: binman: Add support for including SCP firmware 3 jaren geleden
board.c 116e1ed1ab sunxi: board: Add support for SUNIV 2 jaren geleden
chip.c 6c2c7e9cb9 arm: sunxi: add support for DIP detection to CHIP board 3 jaren geleden
dram_sun4i_auto.c d0ffd15cff sunxi: dram_sun4i/5i: use DRAM_MEMORY_TYPE_DDR3 instead of magic number 3 2 jaren geleden
dram_sun5i_auto.c d0ffd15cff sunxi: dram_sun4i/5i: use DRAM_MEMORY_TYPE_DDR3 instead of magic number 3 2 jaren geleden
dram_timings_sun4i.h d133647af4 sunxi: dram: Optionally use standard JEDEC timings for sun[457]i 9 jaren geleden
gmac.c 425084610e sunxi: Clean up inclusions of asm/arch/gpio.h 2 jaren geleden

README.nand

Allwinner NAND flashing
=======================

A lot of Allwinner devices, especially the older ones (pre-H3 era),
comes with a NAND. NANDs storages are a pretty weak choice when it
comes to the reliability, and it comes with a number of flaws like
read and write disturbs, data retention issues, bloks becoming
unusable, etc.

In order to mitigate that, various strategies have been found to be
able to recover from those issues like ECC, hardware randomization,
and of course, redundancy for the critical parts.

This is obviously something that we will take into account when
creating our images. However, the BROM will use a quite weird pattern
when accessing the NAND, and will access only at most 4kB per page,
which means that we also have to split that binary accross several
pages.

In order to accomodate that, we create a tool that will generate an
SPL image that is ready to be programmed directly embedding the ECCs,
randomized, and with the necessary bits needed to reduce the number of
bitflips. The U-Boot build system, when configured for the NAND (with
CONFIG_MTD_RAW_NAND=y) will also generate the image sunxi-spl-with-ecc.bin
that will have been generated by that tool.

In order to flash your U-Boot image onto a board, assuming that the
board is in FEL mode, you'll need the sunxi-tools that you can find at
this repository: https://github.com/linux-sunxi/sunxi-tools

Then, you'll need to first load an SPL to initialise the RAM:
sunxi-fel spl spl/sunxi-spl.bin

Load the binaries we'll flash into RAM:
sunxi-fel write 0x4a000000 u-boot-dtb.bin
sunxi-fel write 0x43000000 spl/sunxi-spl-with-ecc.bin

And execute U-Boot
sunxi-fel exe 0x4a000000

On your board, you'll now have all the needed binaries into RAM, so
you only need to erase the NAND...

nand erase.chip

Then write the SPL and its backup:

nand write.raw.noverify 0x43000000 0 40
nand write.raw.noverify 0x43000000 0x400000 40

And finally write the U-Boot binary:
nand write 0x4a000000 0x800000 0xc0000

You can now reboot and enjoy your NAND.