Welcome, Guest

Author Topic: Debian booted from NAND  (Read 6386 times)

martinayotte

  • Full Member
  • ***
  • Posts: 125
  • Karma: +2/-0
Debian booted from NAND
« on: July 21, 2013, 03:36:17 PM »
Hi everyone,

After researches and trials, I've finally got my Debian booted from NAND.

Here is the quick recipe :

- Cross-compile new u-boot as describe in http://linux-sunxi.org/Building_on_Debian#build_u-boot_for_nand
   (as instructions mentionned, edit include/configs/sun4i.h to have your own CONFIG_BOOTCOMMAND. In my case, I've set it to #define CONFIG_BOOTCOMMAND     "setenv bootargs root=/dev/nandb console=ttyS0,115200 rootwait panic=10 ${extra}; fatload nand 0 0x43000000 script.bin; fatload nand 0 0x48000000 linux/uImage; bootm 0x48000000\0")
- Cross-compile http://linux-sunxi.org/Sunxi-tools
- Boot a Debian from a microSD, and bring a copies of sunxi-tools/nand-part and u-boot-sunxi/u-boot.bin via scp
- repartition the NAND with "nand-part /dev/nand 'linux 8000000'" (the nanda boot partition always stay there)
- verify parition "nand-part", it should look like :

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
partition  0: class =         DISK, name =   bootloader, partition start =    32768, partition size =    32768 user_type=0
partition  1: class =         DISK, name =        linux, partition start =    65536, partition size =  8000000 user_type=0
0 partitions

- mkdir /mnt/mmc0 ;mkdir /mnt/nanda ; mkdir /mnt/nandb
- mount /dev/mmcblk0p1 /mnt/mmc0
- mount /dev/nanda /mnt/nanda
- cp /mnt/mmc0/script.bin /mnt/nanda/script.bin
- cp /mnt/mmc0/linux/uImage /mnt/nanda/linux/uImage
- cp <copy-location>/u-boot.bin /mnt/nanda/linux/u-boot.bin
- mkfs.ext4 /dev/nandb
- mount /dev/nandb /mnt/nandb
- copy the whole rootfs from microsd to /mnt/nandb, avoiding the /lost+found, /mnt and /proc
   (personnally, I've used a tar piped in a tar to do this copy)
- umount /mnt/nanda and /mnt/nandb
- halt
- unplug the microsd
- replug the power and it will boot from the NAND

The only caveat I found is that once the NAND booted, the /dev/mmcblk0p1 is pointing to other SD card, the microSD doesn't seems to be accessible anymore, except by rebooting from it. (Anyone have a clue about this ?)

Enjoy !


« Last Edit: July 21, 2013, 04:22:27 PM by martinayotte »