Cubox-i

Currently editing the page

Goal
The goal of these instructions is to have a running installation of Gentoo on a Cubox-i, with a kernel up-to-date enough to run on current btrfs root filesystem.

Prerequisite

 * Cubox-i
 * if you want to configure over a serial console you need a CuBox-i2ultra or a CuBox-i4pro
 * otherwise you need an hdmi display and and usb keyboard
 * another (Linux) computer with a cross compiler for arm installed
 * git
 * tftp server
 * u-boot-tools
 * mini-image
 * sd-card (with enough space, boot partition, rootfs with a git kernel and gentoo, 4GB+)
 * network cable for an internet connection

Installation
The install consists of partitioning and formatting, the sd-card. Copying over a stage3 tarball, configuring it so that it can boot and it can be accessed. Creating a kernel. Booting the kernel on the machine. Installing the kernel for an automatic boot. Continue a default Gentoo installation.

Setup Custom u-Boot
 u-Boot can be compiled from source as well. Nevertheless we start with a precompiled here, so this step can be skipped.

Setup serial console
If the model is a CuBox-i2ultra or a CuBox-i4pro it can be connected direclty with your other computer. If not you need to attach it to an hdmi display and connect a usb keyboard.

Preparing SD Card
To start we flash the mini-image on the sd-card. This way there is already u-boot properly installed and we can test if the serial connection (or connected keyboard and display) is working.

If the first test worked okay you can partition and format the card. As in the goal described in a two partition scheme will be used.
 * /dev/mmcblk0p0 will be ext2 with 100MB (boot)
 * /dev/mmcblk0p1 will be btrfs with the rest of the capacity (root)

/dev/mmcblk0 can be different in your computer probably /dev/sdX

The minimal configuration of the root has to be done already on the other computer
 * 1) extract stage3
 * 2) edit /etc/fstab
 * 3) set root password
 * 4) enable serial console

extract stage 3
Get from Gentoo Mirrors the latest /releases/arm/autobuilds/current-stage3-armv7a_hardfp/ and extract it to the root partition

cd /mnt/sdcard-root tar xvjpf /path/to/download/stage3-*.tar.bz2

edit /etc/fstab
edit on the root partition on the sdcard /etc/fstab

/dev/mmcblk0p1         /boot           ext2            noauto,noatime  1 2 /dev/mmcblk0p2         /               btrfs           noatime         0 1


 * 1) /dev/SWAP             none            swap            sw              0 0
 * 2) /dev/cdrom            /mnt/cdrom      auto            noauto,ro       0 0
 * 3) /dev/fd0              /mnt/floppy     auto            noauto          0 0

edit root password
to be able to login later we need to set a root password, we create passwor hash and edit it to the /etc/shadow


 * 1) openssl passwd -1


 * 1) nano -w /mnt/sdcard-root/etc/shadow
 * 2) #replace the start or current hash of the root user with the output from the command above

enable serial console
to also have a serial console after we booted the current system we need to modify


 * 1) nano /mnt/sdcard-root/etc/inittab

s0:12345:respawn:/sbin/agetty -L 115200 ttymxc0 vt100
 * 1) # and change the s0 line to the following

This should be enough that a kernel can boot the system and that we can work with it afterwards

Kernel
At the moment the are multiple sources for kernels available all with their specific advantages and drawbacks.


 * https://github.com/SolidRun/linux-imx6 the kernels here are all 3.0.x, they are the offical ones from solidrun with all the patches included but unfortunately to old for a current btrfs system
 * a vanilla kernel 3.12+ might run on the cubox-i but it does not contain all the patches to use the complete hardware
 * https://github.com/SolidRun/linux-linaro-stable-mx6 is new merge of 3.10.x and all the patches, *in the following we are going with this one*
 * (2014-03-01) I had some problems with make dtbs, and had to make some modifications, you can find the here, but be warned I have no idea what I am doing.
 * There are also some patches for 3.14-rc around. I could not test them. 3.14 or 3.15 should include more support for the Cubox-i in the vanilla kernel.


 * 1) export ARCH=arm
 * 2) export CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi-


 * 1) git clone https://github.com/linux4kix/linux-linaro-stable-mx6


 * 1) cd linux-linaro-stable-mx6


 * 1) make imx_v7_cubox-i_hummingboard_defconfig
 * 2) make menuconfig
 * 3) # add btrfs to the kernel (built-in)
 * 4) # add ARM_APPENDED_DTB to the kernel


 * 1) make


 * 1) cd arch/arm/boot
 * 2) cat zImage dts/imx6q-cubox-i.dtb > zImage-dtb
 * 3) mkimage -A arm -O linux -C none -T kernel -a 0x10008000 -e 0x10008000 -n "linux-cubox-i-3.10.30" -d zImage-dtb uImage

Continue Gentoo install
Steps that should be done right after the installation
 * 1) setup network
 * 2) set date
 * 3) emerge-webrsync
 * 4) emerge ntpd
 * 5) /etc/init.d/sshd

Premade Image


Open Questions

 * HDMI