Cubieboard/Installing on NAND

First, download and uncompress a couple of files:

Debian Wheezy SD-card image from http://guillaumeplayground.net/mele-a2000-headless-debian-wheezy-armhf-with-nand-install-v1/ (Thanks Guillaume).

NAND boot partition and MBR image: http://dl.cubieforums.com/loz/boot_partition/bootloader/cubie_nand_uboot_partition_image.bin (Thanks Lawrence: http://www.cubieforums.com/index.php/topic,73.msg235.html#msg235)

The first step to installation is to copy the SD-card image to an SD card (make sure it's large enough!)

I'm using a Mac. If you are too, you can do this by:


 * Typing mount. The mounted partition on the card will be listed in there somewhere, with a name like /dev/diskXs1 (where X is a number).
 * Unmount it by typing unmount /dev/diskXs1 (replace the X with the number from the previous steps). If there is more than one partition on the card (/dev/diskXs2, /dev/diskXs3 etc.) unmount them all.
 * Now, you need to copy the Debian SD card image onto the SD card, with a command like sudo dd bs=4096 if=~/Downloads/debian_wheezy_armhf_v1_mele.img of=/dev/diskX - again, the X</tt> should be the same number as in the previous steps. Note that there's no trailing sY</tt> this time, because we're copying the image over the whole disk, and the numerical 'sY' suffixes refer to partitions.
 * After the dd</tt> command is complete, the system will probably auto-mount the new boot partition on the SD card (this is just a small MS-DOS formatted partition that's used for booting). Eject it, and remove the SD card.
 * Now you have Debian on the SD card!

On Linux, the steps will be quite similar. On Windows they will not, but the goal is the same.

Next you can boot your Cubieboard with the system on the SD card. Plug it in to your Ethernet network, plug in the SD card, and plug in the power. The power light will come on immediately, followed shortly (maybe 15-20 seconds later) by LED 2. In about 30 seconds, booting will be complete, and the Cubieboard will have obtained an IP from your DHCP server or router. You'll need to find out what this IP is from your router.

After you have the Cubieboard's IP, you can ssh to it. On a UNIX system like a Mac or Linux, that's just a simple ssh root@&lt;CUBIEBOARD IP ADDRESS&gt;</tt> in a terminal. The password is also root</tt>. You should be logged in and get a command prompt.

The next step is to get the Debian system onto the internal NAND.

First, we need to get the boot partition we downloaded earlier on onto the NAND. You can either copy it over using SCP, then use dd</tt> to write it to /dev/nand</tt> (dd bs=4096 if=./cubie_nand_uboot_partition_image.bin of=/dev/nand</tt>), or just copy it directly there with SCP (on my Mac, scp ~/Downloads/cubie_nand_uboot_partition_image.bin root@&lt;CUBIEBOARD IP ADDRESS&gt;:/dev/nand</tt>).

After that wait for 30 seconds (this seems like it should not be necessary, but guides I read recommended it, and I'm paranoidly cargo-culting the advice), then a 'reboot' is in order.

After the board reboots, SSH in to it again. Now, we'll create our Linux partition. The image we copied to the NAND already has the partition table and the boot partition on it, so all we need to do is format the partition we'll use by doing mkfs.ext4 /dev/nandb</tt>. After that, we can mount it with mount /dev/nandb /mnt</tt>.

Next, we'll copy the Linux kernel off the SD card. It's on the SD card's boot partition, not the one containing the root filesystem, so we'll mount it by creating a directory to mount it into (mkdir /tmp/boot</tt>), and then mounting it (mount /dev/mmcblk0p1 /tmp/boot</tt>). After that, we copy the kernel image out of it into a boot directory on our new partition (mkdir /mnt/boot</tt> then cp /tmp/boot/uImage /mnt/boot/uImage</tt>).

If you want to use Hwpack features, you should copy uImage</tt> and <tt>script.bin</tt> files from Hwpack <tt>kernel</tt> directory instead of <tt>/tmp/boot/uImage</tt>.

All that remains now is to copy over the Linux filesystem. I used <tt>rsync</tt> for that (thanks patwood: http://www.cubieforums.com/index.php/topic,73.msg241.html#msg241).

First, I created a file to contain all the directories I didn't want the contents of. The contents of that file were:

/dev/* /proc/* /sys/* /media/* /mnt/* /run/* /tmp/*

Then a simple <tt>rsync -avc --exclude-from=EXCLUDE_FILE / /mnt</tt> copied the files.

For using Cubieboard-specific modules from Hwpack, copy the Hwpack <tt>rootfs</tt> directory contents to <tt>/mnt</tt>.

That's it! Do a <tt>shutdown -h now</tt>, and when the lights go out, remove the SD card. Now, power the Cubieboard back up, and you'll have Debian running entirely from the NAND.

Now, it's time to properly set things up. An <tt>apt-get update</tt> then an <tt>apt-get dist-upgrade</tt> is a pretty good first step to get things up to date. You'll probably want to then create a user account and change the root password. My next steps were to edit <tt>/etc/hostname</tt> to give my board a good name, then <tt>apt-get install man</tt> and <tt>apt-get install g++</tt>. Most of the software you'll need can be installed with <tt>apt-get</tt> - but I won't go into more detail, that's all just generic Debian and Linux stuff, not specific to the Cubieboard.