NAND

In the sunxi world, NAND (a type of flash memory) signifies the on board flash memory of a sunxi device. Our main u-boot version currently does not support booting from NAND and an altered allwinner version needs to be used instead.

= Background =

Our SoCs have a very specific boot process. First it executes a tiny on chip rom (BROM) which then checks the buttons for FEL mode and then starts checking the various storage options for a valid boot signature at the right location.

There is no real difference between NAND and an SD-card apart from the fact that directly attached flash use the Sunxi NAND controller directly while SD-Cards come with a standard interface and an embedded controller. The sunxi nand controller is harder to implement than the sunxi sd-card controller, and the sample code provided by allwinner is rather large (and shared between U-boot and the kernel).

Then there is the NAND hw randomizer that gets in the way. Allwinner uses one setting for the BROM and the second boot stage (boot0/SPL), and another setting for normal use. With this setup, it is currently not implemented to access both bits at the same time. This currently provides another barrier for implementation, as one first needs to be able to read/write this area. While this is not beyond fixing, these are quite a few hoops to jump through.

As a result of the above, we have to use the existing second and third stages of the allwinner nand boot process, and we need to use nand-part for partitioning. If we had proper u-boot support, we would not need any of that.

= Booting off nand =

Our main u-boot still is not capable of booting off nand, although this is in active development.

A little older u-boot variant: https://github.com/linux-sunxi/u-boot-sunxi/tree/lichee-dev-a20

= Installing to NAND from an SD card =

There is a nice, full howto available to achieve this.

= Altering NAND =

get nand-part
There is a utility which is part of sunxi-tools, called nand-part.

nand-part output
Below is the typical output of the nand partitioning of a Mele A1000.

check partition table copy 0: mbr: version 0x00000100, magic softw311 OK check partition table copy 1: mbr: version 0x00000100, magic softw311 OK check partition table copy 2: mbr: version 0x00000100, magic softw311 OK check partition table copy 3: mbr: version 0x00000100, magic softw311 OK mbr: version 0x00000100, magic softw311 9 partitions partition 1: class =         DISK, name =       BOOTFS, partition start =     2048, partition size =    32768 user_type=0 partition 2: class =         DISK, name =      LROOTFS, partition start =    34816, partition size =    65536 user_type=2 partition 3: class =         DISK, name =    LSYSTEMFS, partition start =   100352, partition size =   524288 user_type=2 partition 4: class =         DISK, name =      LDATAFS, partition start =   624640, partition size =  3145728 user_type=2 partition 5: class =         DISK, name =         MISC, partition start =  3770368, partition size =     2048 user_type=2 partition 6: class =         DISK, name =  LRECOVERYFS, partition start =  3772416, partition size =    65536 user_type=2 partition 7: class =         DISK, name =     LCACHEFS, partition start =  3837952, partition size =   262144 user_type=2 partition 8: class =         DISK, name =          env, partition start =  4100096, partition size =     4096 user_type=0 partition 9: class =         DISK, name =        UDISK, partition start =  4104192, partition size =        0 user_type=0 check partition table copy 0: mbr: version 0x00000100, magic softw311 OK check partition table copy 1: mbr: version 0x00000100, magic softw311 OK check partition table copy 2: mbr: version 0x00000100, magic softw311 OK check partition table copy 3: mbr: version 0x00000100, magic softw311 OK mbr: version 0x00000100, magic softw311 9 partitions partition 1: class =         DISK, name =       BOOTFS, partition start =     2048, partition size =    32768 user_type=0 partition 2: class =         DISK, name =      LROOTFS, partition start =    34816, partition size =    65536 user_type=2 partition 3: class =         DISK, name =    LSYSTEMFS, partition start =   100352, partition size =   524288 user_type=2 partition 4: class =         DISK, name =      LDATAFS, partition start =   624640, partition size =  3145728 user_type=2 partition 5: class =         DISK, name =         MISC, partition start =  3770368, partition size =     2048 user_type=2 partition 6: class =         DISK, name =  LRECOVERYFS, partition start =  3772416, partition size =    65536 user_type=2 partition 7: class =         DISK, name =     LCACHEFS, partition start =  3837952, partition size =   262144 user_type=2 partition 8: class =         DISK, name =          env, partition start =  4100096, partition size =     4096 user_type=0 partition 9: class =         DISK, name =        UDISK, partition start =  4104192, partition size =        0 user_type=0