Build Instructions for Ubuntu

= Build Instructions for Ubuntu =

Reference: Ubuntu 15.04 Vivid Vervet

= Build Pre-requisites =

sudo apt-get install build-essential git

Useful for building or troubleshooting older builds: sudo apt-get install u-boot-tools sunxi-tools

= Getting the Cross-Toolchain = See also: Toolchain

sudo dpkg --add-architecture armhf
 * Add the ArmHF architecture

sudo sed 's~\(\(deb\(-src\)*\) \([^\[]\)\)~\2 [arch=i386,amd64] \4~' /etc/apt/sources.list | sudo tee /etc/apt/sources.list sudo sed 's~\(\(deb\(-src\)*\) \([^\[]\)\)~\2 [arch=i386,amd64] \4~' /etc/apt/sources.list.d/*.list
 * Modify existing sources, restricting to appropriate architectures (i.e. all i386 and amd64 package sources are prefixed as "deb [arch=i386,amd64]")
 * 1) Manually configure third party sources

sudo bash -c 'cat > /etc/apt/sources.list.d/armhf-ports.list <<EOT deb [arch=armhf] http://ports.ubuntu.com/ `lsb_release -cs` main universe multiverse restricted deb [arch=armhf] http://ports.ubuntu.com/ `lsb_release -cs`-updates main universe multiverse restricted deb [arch=armhf] http://ports.ubuntu.com/ `lsb_release -cs`-security main universe multiverse restricted EOT'
 * Create source list for the port architecture(s) (this adds the armhf port sources to apt)

sudo apt-get update sudo apt-get install crossbuild-essential-armhf
 * Update apt and install crossbuild tools for armhf

= Building u-boot = Mainline u-boot works fine: git clone -b v2015.04 git://git.denx.de/u-boot.git cd u-boot make CROSS_COMPILE=arm-linux-gnueabihf- Mele_A1000_defconfig make -j4 CROSS_COMPILE=arm-linux-gnueabihf-

search in the directory configs/ for your board, the file name looks like _defconfig

(Also refer to Mainline_U-boot)

= Setting up the sd card =

Enter an interactive superuser sudo shell sudo su -

${card} is the SD device (ie /dev/sdc). ${partition} is the partition number (ie. 1). Warning: This will delete the content. dd if=/dev/zero of=${card} bs=1M count=1 dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8 Create partition(s). ie one big partition beginning with sector 2048, type 83 (Linux) fdisk ${card}

mkfs.ext4 ${card}${partition} mount ${card}${partition} /mnt

This will first clean the card (at least the first 1M), install the u-boot bootloader you compiled in the step before, and then you can create -for example- one partition, format it, and mount it to /mnt/ for use in the next steps.

(Also refer to Bootable_SD_card)

= Ubuntu Core = https://wiki.ubuntu.com/Core

Link to Ubuntu Core download: Ubuntu 15.04 (Vivid Vervet) - http://cdimage.ubuntu.com/ubuntu-core/releases/vivid/release/
 * Download Ubuntu Core filesystem

cd /mnt sudo tar zxvf $path_to_root_fs
 * Extract Ubuntu Core filesystem to the mounted SD card

sudo apt-get install qemu-user-static
 * Install qemu-arm-static

cp /usr/bin/qemu-arm-static /mnt/usr/bin/ mount chproc /mnt/proc -t proc mount chsys /mnt/sys -t sysfs
 * Prepare chroot environment

cp /etc/resolv.conf /mnt/etc/resolv.conf will allow network access after chroot-ing (in step 7) by copying the DNS resolver configuration


 * Open a chroot session into the target root filesystem. This will allow you to install packages and configure the target system before it is bootable.

sudo LC_ALL=C LANGUAGE=C LANG=C chroot /mnt

for f in /sys /proc /dev ; do mount --rbind $f /mnt/$f ; done ; chroot /mnt\ will go to a chroot, see Is there an easier way to chroot than bind-mounting? for details about mount rbind apt-get update && apt-get install linux-{headers,image}-generic will install kernel ("linux")

Note: it's possible that apt-get update will not work because no network is present.

= Ubuntu Core for Offline instalation=

apt-get download linux-generic:armhf flash-kernel:armhf linux-base linux-image-generic:armhf linux-headers-generic:armhf devio:armhf
 * Download the Linux Kernel

dpkg -i devio_1.2-1build2_armhf.deb
 * Install flash-kernel

# dpkg -i /tmp/$dependencies # dpkg -i /tmp/$kernel
 * Install the kernel:

cp $path_to_kernel/*deb /mnt/tmp
 * Copy the kernel and any dependencies to the target root filesystem, e.g.

= Configuring the system =

flash-kernel
We are going to use flash-kernel to generate the boot.src. Tell it which hardware we're aiming for. (Devices listed in: /usr/share/flash-kernel/db/all.db) mkdir /mnt/etc/flash-kernel/ echo "Cubietech Cubietruck" >> /mnt/etc/flash-kernel/machine

Kernel arguments: echo 'LINUX_KERNEL_CMDLINE="console=ttyS0,115200 hdmi.audio=EDID:0 disp.screen0_output_mode=EDID:1280x1024p60 root=/dev/mmcblk0p1 rootwait panic=10 ${extra}"' >> /mnt/etc/default/flash-kernel

Kernel modules
Write extra modules that should be loaded at boot time to /mnt/etc/modules. echo "rtc_sunxi" >> /etc/initramfs-tools/modules

Base configuration files
echo "/dev/mmcblk0p1 /           ext4    relatime,errors=remount-ro        0       1" > /mnt/etc/fstab echo "HOSTNAME" > /mnt/etc/hostname

Hint: Please consider using your favorite debian-mirror instead of ftp.debian.org. cat < /mnt/etc/apt/sources.list

deb http://ftp.debian.org/debian/ testing main non-free contrib deb-src http://ftp.debian.org/debian/ testing main non-free contrib

deb http://security.debian.org/ testing/updates main contrib non-free deb-src http://security.debian.org/ testing/updates main contrib non-free

deb http://ftp.debian.org/debian/ testing-updates main contrib non-free deb-src http://ftp.debian.org/debian/ testing-updates main contrib non-free EOF cat < /mnt/etc/apt/sources.list.d/experimental.list deb http://ftp.debian.org/debian/ unstable main non-free contrib deb-src http://ftp.debian.org/debian/ unstable main non-free contrib
 * 1) testing-updates, previously known as 'volatile'

deb http://ftp.debian.org/debian/ experimental main non-free contrib deb-src http://ftp.debian.org/debian/ experimental main non-free contrib EOF cat < /mnt/etc/apt/preferences.d/experimental Package: * Pin: release o=Debian,a=unstable Pin-Priority: 150

Package: * Pin: release a=experimental Pin-Priority: -10 EOF cat < /mnt/etc/network/interfaces
 * 1) This file describes the network interfaces available on your system
 * 2) and how to activate them. For more information, see interfaces(5).

auto lo iface lo inet loopback
 * 1) The loopback network interface

allow-hotplug eth0 iface eth0 inet dhcp EOF
 * 1) The primary network interface

Prepare Login
Remember: We won't have any display output, so we can eiter: spawn a login on the serial console: echo "T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100" >> /mnt/etc/inittab and/or use ssh. Since debian disabled root password-login in jessie, re-enable it: sed -i "s/^PermitRootLogin without-password/PermitRootLogin yes/" /mnt/etc/ssh/sshd_config or copy your key: umask 077; mkdir /mnt/root/.ssh/ cat ~/.ssh/id_rsa.pub >> /mnt/root/.ssh/authorized_keys

chroot and setup
Now chroot in to the new system, install kernel and set everything up. mount -t proc chproc /mnt/proc mount chsys /mnt/sys -t sysfs mount -t devtmpfs chdev /mnt/dev || mount --bind /dev /mnt/dev mount -t devpts chpts /mnt/dev/pts echo -e '#!/bin/sh\nexit 101' > /mnt/usr/sbin/policy-rc.d chmod 755 /mnt/usr/sbin/policy-rc.d  DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot /mnt dpkg --configure -a

LC_ALL=C LANGUAGE=C LANG=C chroot /mnt The next steps are executed inside the chroot: apt-get update apt-get install locales && dpkg-reconfigure locales dpkg-reconfigure tzdata Install the kernel and u-boot (u-boot from debian is not used, but it does no harm and i'll include it for future reference) apt-get -t experimental install linux-image-3.16-rc6-armmp-lpae u-boot u-boot-tools Or, if you want simple frame-buffer support (on some cards) go with kernel >3.19: apt-get -t experimental install linux-image-3.19.0-trunk-armmp-lpae u-boot u-boot-tools Install non-free firmware and add one currently missing file to the wifi-firmware: apt-get install firmware-linux firmware-brcm80211 sunxi-tools flash-kernel wget -O /lib/firmware/brcm/brcmfmac43362-sdio.txt http://dl.cubieboard.org/public/Cubieboard/benn/firmware/ap6210/nvram_ap6210.txt Install a few other things: apt-get install console-setup keyboard-configuration systemd systemd-sysv openssh-server ntp

At this point, debian should have generated a kernel image /boot/vmlinuz-??? and an initrd /boot/initrd.img-??? for you. Generate the /boot/boot.scr, set a password and after a little cleanup you're set: flash-kernel passwd root exit