Cubietruck over NFS21. Aug '14

In this post I'll attempt to explain how to set up Cubietruck with NFS root 1. This means that Cubietruck won't store any files on it's internal NAND or µSD card, instead files are stored on a single NFS server. The obvious benefit is that software is managed centrally.

1

http://www.iram.fr/~blanchet/tutorials/read-only_diskless_debian7.pdf

Setting up NFS server

We assume that Cubietruck's root filesystem will be bootstrapped at /var/lib/cubietruck:

sudo mkdir -p /var/lib/cubietruck

Next step is to install NFS server software:

sudo apt-get install nfs-kernel-server

Add to /etc/exports:

/home                 192.168.81.0/24(rw)
/var/lib/cubietruck   192.168.81.0/24(ro,no_root_squash)

NFS services have to be reloaded of course:

sudo /etc/init.d/nfs-kernel-server reload

Setting up DHCP server

In this case we're using dnsmasq to serve IP addresses for the Cubietrucks. The configuration at /etc/dnsmasq.conf should be something like this:

user=nobody
group=nogroup
interface=eth1
listen-address=192.168.81.1
domain=term.koodur.com
dhcp-range=192.168.81.130,192.168.81.180,12h
dhcp-option=option:root-path,"192.168.81.1:/var/lib/cubietruck"

Bootstrapping base system

In this case we're building Debian Jessie ARM branch root filesystem at /var/lib/cubietruck. First get all the tools to bootstrap a Debian system:

sudo apt-get install debootstrap qemu-user-static binfmt-support

Next step is to actually run debootstrap, note that since the target architecture differs we need to copy over binaries related to QEMU compatibility layer:

sudo debootstrap --foreign --arch=armhf testing /var/lib/cubietruck
sudo cp /usr/bin/qemu*-arm-static /var/lib/cubietruck/usr/bin/
sudo chroot /var/lib/cubietruck /debootstrap/debootstrap --second-stage

Chrooting

From now on we can assume all commands will take place inside /var/lib/cubietruck, before entering the chroot you probably want to mount /proc and /dev/pts:

mkdir -p /var/lib/cubietruck/dev/pts
mount --bind /dev/pts /var/lib/cubietruck/dev/pts
mount --bind /proc /var/lib/cubietruck/proc/
mount --bind /home /var/lib/cubietruck/home/

To make it more permantent you can add following to your host machine's /etc/fstab:

/dev/pts    /var/lib/cubietruck/dev/pts none bind 0 2
/proc               /var/lib/cubietruck/proc none bind 0 2
/home               /var/lib/cubietruck/home none bind 0 2

Then you can enter /var/lib/cubietruck simply by chrooting into that directory:

chroot /var/lib/cubietruck

Create /etc/mtab:

ln -s /proc/self/mounts /etc/mtab

Create /etc/resolv.conf:

nameserver 8.8.8.8

Debootstrap does not set any mountpoints so /etc/fstab has to be reconfigured:

proc /proc proc defaults 0 0
/dev/nfs / nfs nolock 0 0
none /tmp tmpfs defaults 0 0
none /var/tmp tmpfs defaults 0 0
none /var/lib/lightdm tmpfs defaults 0 0
none /media tmpfs defaults 0 0
none /var/log tmpfs defaults 0 0
192.168.81.1:/home /home nfs nolock 1 2

# Hide internal NAND mounting options from GUI
/dev/nand1 /mnt/nand1 auto noauto 1 2
/dev/nand2 /mnt/nand2 auto noauto 1 2
/dev/nanda /mnt/nanda auto noauto 1 2
/dev/nandb /mnt/nandb auto noauto 1 2

Same applies to /etc/apt/sources.list:

deb http://ftp.ee.debian.org/debian/ jessie main
deb-src http://ftp.ee.debian.org/debian/ jessie main

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

# jessie-updates, previously known as 'volatile'
deb http://ftp.ee.debian.org/debian/ jessie-updates main
deb-src http://ftp.ee.debian.org/debian/ jessie-updates main

# jessie-backports, previously on backports.debian.org
deb http://ftp.ee.debian.org/debian/ jessie-backports main
deb-src http://ftp.ee.debian.org/debian/ jessie-backports main

To get some extra junk you probably want to add my repository aswell:

echo "deb http://packages.koodur.com jessie main" > /etc/apt/sources.list.d/koodur.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B8A6153D

And finally update package lists:

apt-get update

Installing software for Cubietruck

Following installs MATE desktop with all the bells and whistles:

apt-get install nfs-common locales lightdm \
    mate-desktop-environment mate-media-pulse mate-settings-daemon-pulse pulseaudio \
    vdpauinfo libvdpau-sunxi libump xf86-video-fbturbo mpv estonianidcard \
    chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg-extra \
    libreoffice libreoffice-l10n-et \
    mc htop iftop iotop nmap ntpdate alsa-utils

Reconfigure locales and timezones:

dpkg-reconfigure locales
dpkg-reconfigure tzdata

To get Bluetooth, WiFi and CedarX working fetch kernel modules:

wget http://lauri.vosandi.com/ct/mod.tar
tar xvf mod.tar -C /lib/
depmod  -a 3.4.98-sun7i+

Define modules to be loaded during boot at /etc/modules:

hci_uart
gpio_sunxi
bt_gpio
wifi_gpio
rfcomm
hidp
lirc_gpio
sunxi_lirc
#bcmdhd
sunxi_ss

To make mpv default to hardware accelerated decoding, insert following to /etc/mpv/mpv.conf:

vo=vdpau
hwdec=vdpau
hwdec-codecs=h264

To /etc/rc.local:

chmod 777 /dev/g2d
chmod 777 /dev/disp
chmod 777 /dev/cedar_dev
exit 0

To /etc/X11/xorg.conf:

Section "Screen"
    Identifier  "VGA-0"
    Device      "/dev/fb0"
    Monitor     "LG"
EndSection

Section "Screen"
    Identifier  "HDMI-0"
    Device      "/dev/fb1"
    Monitor     "LG"
EndSection

Section "Device"
    Identifier  "/dev/fb0"
    Driver      "fbturbo"
    Option      "fbdev" "/dev/fb0"
    Option      "SwapBuffersWait" "true"
EndSection

Section "Device"
    Identifier  "/dev/fb1"
    Driver      "fbturbo"
    Option      "fbdev" "/dev/fb1"
    Option      "SwapBuffersWait" "true"
EndSection

To install Adobe Flash 11.5 2:

wget http://www.dl.cubieboard.org/media/flashplayerarm.tar.gz
tar xvf flashplayerarm.tar.gz
mv libpepflashplayer.so /usr/lib/chromium-browser/plugins/
mv default etc/chromium-browser/default
rm -fv flashplayerarm.tar.gz
2

http://docs.cubieboard.org/tutorials/common/begining_on_lubuntu#flashplayer

Preparing Cubietruck

At some point Cubietruck switched using from revision A of A20 processor to revision B. Many scripts don't work currently with rev B 3 and the suggested way to fix several NAND partitioning issues is to reflash Cubietruck with official Lubuntu v2.0 image and then proceed with other installation methods.

wget http://dl.cubieboard.org/software/a20-cubietruck/lubuntu/ct-lubuntu-nand-v2.0/ct-lubuntu-server-nand.img.gz
tar xvf ct-lubuntu-server-nand.img.gz

To install the image use LiveSuit:

wget http://dl.cubieboard.org/software/tools/livesuit/LiveSuitV306_For_Linux64.zip
unzip LiveSuitV306_For_Linux64.zip
cd LiveSuit_for_Linux64/
chmod +x LiveSuit.run
./LiveSuit.run
sudo ~/Bin/LiveSuit/LiveSuit.sh

And point the program to the .img file uncompressed earlier. Once the machine has booted up you can gain access to the commandline via UART header on the board. Substitute kernel and boot arguments and reboot the machine:

mount /dev/nanda /boot
wget http://lauri.vosandi.com/ct/ct-vga.bin -O /boot/script.bin
wget http://lauri.vosandi.com/ct/uImage -O /boot/uImage
wget http://lauri.vosandi.com/ct/uEnv.ct -O /boot/uEnv.txt
reboot

uImage and ct-vga.bin are directly from Igor Pečovnik's µSD image 4. The last file is slightly customized u-boot configuration:

console=tty0
extraargs=console=ttyS0,115200 root=/dev/nfs ip=dhcp ro panic=60
nand_root=/dev/nandb
3

http://dl.cubieboard.org/software/a20-cubietruck/android/README

4

http://www.igorpecovnik.com/2013/12/24/cubietruck-debian-wheezy-sd-card-image/

In case icons are missing it usually means chrooted package installation failed for some packages. Try mounting rootfs read-write on a Cubietruck and run:

/usr/lib/arm-linux-gnueabihf/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache
dnsmasq Debian Cubietruck Allwinner NFS