README.nand 2.0 KB

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