Cubox-i

This document describes how to install Gentoo on the SolidRun Cubox-i and HummingBoard.

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 an USB keyboard
 * git
 * SD card (with enough space, boot partition, rootfs with a git kernel and Gentoo, 4GB+)
 * network cable for an internet connection (the WiFi driver needs a firmware that can be installed later)
 * another (Linux) computer with a cross compiler for arm installed (the installation for Gentoo is documented here)

Optional
If you want you can install the "Ignition" image of solid-run to see if your machine is working with the serial connection (or the connected keyboard and display). This will overwrite the U-Boot installation!
 * tftp server
 * Ignition
 * Ignition

Installation
The install consists of installing, 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.

Installing Crossdev
This is necessary to build U-Boot and the kernel on your desktop system.

For more details, please refer to the Embedded Handbook and Custom repository articles.

Setup U-Boot
When the Cubox-i was released there was no mainline support for it. So SolidRun maintained its own patched fork. Since 2017-01 a mainline U-Boot works without any patches, so there is no longer a real reason to go with the fork. For historic reasons the subtle differences in the installation of both configurations are shown.

Mainline
A successful build will create two files in the source tree directory, and


 * file is the actual machine detection and initialization and must be flashed on offset 1 KByte of the boot SD card.
 * is the second stage bootloader; it can be flashed at offset 69 KByte from the starting of the boot SD card;

In the mainline version there is no support for a file without a patch. So you can use the legacy method using u-boot-tools, or you can download a uEnv patch to provide more flexibility and easier configuration. The patch follows the usual LinuxOnArm wiki setup for deploying dtb files in versioned subdirectories similar to Wandboard:

U-Boot patch and SD card deploy steps: https://eewiki.net/display/linuxonarm/Wandboard#Wandboard-Bootloader:U-Boot

Get the patch here: http://dev.gentoo.org/~nerdboy/files/0001-cubox4i-uEnv.txt-bootz-n-fixes-after-rcn-patch.patch

More information: http://www.denx.de/wiki/U-Boot

SolidRun
SolidRun provides a custom U-Boot, this is a fork from the upstream and patched by Jon Nettelton. Main feature is addition of console on HDMI support, and the SPL support for Cubox-i. To build the bootloader, do:

A successful build will create two files in the source tree directory, and


 * file is the actual machine detection and initialization and must be flashed on offset 1KByte of the boot SD card.
 * is the second stage bootloader; it can be flashed at offset 42KByte from the starting of the boot SD card; or alternatively can be put as-is on the first partition of the SD card if the partition has a FAT filesystem.

More information: http://wiki.solid-run.com/doku.php?id=products:imx6:software:development:u-boot

Setup serial console
The Cubox-i2ex, CuBox-i2Ultra and CubBox-i4Pro have serial console support via a FTDI FT230X USB to UART serial interface. This allows connecting the Cubox-i directly to another computer. Alternatively the Cubox-i can be connected to a HDMI display and USB keyboard.

The computer connecting to the Cubox-i will need to have the following kernel configuration options enabled:

Connecting to the serial console requires an application such as or. For more information refer to the SolidRun Wiki.

Preparing the SD card
A single partition scheme can be used with mainline U-Boot when using an ext2/3/4 formatted root partition. However when using a Btrfs formatted root partition (or other unsupported filesystem), an ext2/3/4 or fat32 formatted boot partition is required.

Extract stage 3
Get the latest stage 3 and extract it to the root partition:

Edit /etc/fstab
Edit on the root partition on the SD card :

Set the root password
To be able to login later we need to set a root password, we create password hash and edit it to the.

Replace the star or current hash of the root user with the output from the command above.

Enable the serial console
To have a serial console available after booting, change the  line to the following:

Mainline (or Gentoo sources)
The mainline kernel 3.19+ and has great support for Cubox-i devices, complete with working graphics and networking.

Create the install directories:

Setup the cross-compilation environment:

Configure the kernel:

Build and install the kernel (zImage):

The kernel is located at. The kernel will be installed at

Build and install the kernel modules:

The kernel modules will be installed at

Build and install the device trees:

The device trees are located at. The device trees will be installed at

The kernel, modules and devices trees can now be installed to the actual root directory of the device:

Latest patched version

 * These patches apply to the latest kernel. As of this writing you can apply them to sys-kernel/git-sources-4.1-rc1. Gentoo can do this automatically for you. Unzip the latest patch to and create  as is documented here: https://wiki.gentoo.org/wiki//etc/portage/patches.

Create the zImage and the dtb file

You can find other/more patches here: some

WiFi
The following kernel configuration options are required for WiFi support. These options should already be enabled if the kernel was configured with.

The WiFi driver requires firmware to operate, which can be obtained directly from the Linux firmware repository or the package. The required firmware can be determined by examining the output of a running Cubox-i device:

The above output from a Cubox-i4Pro indicates that is the firmware required by the driver. This may be differ depending on the Cubox-i model.

The firmware also requires NVRAM calibration data, which can be obtained from the Freescale (now NXP) repository. The NVRAM calibration data needs to have the correct WiFi regulatory domain set. This can be done by setting the value of the  parameter to the country code in which the device will be operating in. For example, to set the WiFi regulatory domain for the United States:

The firmware and NVRAM calibration data need to be placed in the directory.

Headers
To compile certain applications like Kodi that have modified/additional codecs you need to expose the patched kernel headers. Fortunately there is a script for that:

If you install them into then you don't overwrite the ones provided by the Gentoo package.

Firmware
For using the VPU firmware the instructions in the following GitHub repository can be used:

https://github.com/pH5/coda-bits

Bootloader
U-Boot will normally wait three seconds for user input before attempting to boot. If user input is received, the boot sequence is interrupted and an interactive shell is started. If three seconds pass with no user input, U-Boot will look for an environment configuration on the first partition. If no valid environment configuration is found, U-Boot will display *** Warning - bad CRC, using default environment, and will then continue with the default environment configuration. This is where mainline U-Boot and SolidRun U-Boot differ. Mainline supports and extlinux.conf on the first partition, while SolidRun also supports.

extlinux.conf
U-Boot supports Syslinux style boot configuration. U-Boot only borrows a small subset of the Syslinux configuration options, and does not require Syslinux itself. This is much simpler than using or applying patches to add  support.

Create the directory:

Create the following configuration and adjust accordingly:

uEnv.txt
Using the mainline U-Boot uEnv patch cut from 2017.03, create in your boot partition or directory:

Adjust the video argument to match your display.

uEnv.txt
If you use the Soldidrun U-Boot from this wiki you can use the default settings and no direct modification of the U-Boot configuration might be necessary. If the first partition of the SD card is formatted with ext2 or fat it will read the the file with the configuration from it.

These two lines should be enough to boot the kernel. The U-Boot from this wiki can boot a zImage directly (no conversion to uImage necessary). The zImage and the *.dtb file have to reside in the root folder of this partition next to the. The second line contains the kernelflags (for example the root).

If you have no console output on your screen during boot, try

Interactive
Connect to your Cubox-i with a serial console (or with a keyboard and a display) and interrupt the U-Boot bootloader with and type the following commands.

setenv ipaddr 192.168.0. setenv serverip 192.168.0. setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 ro rootwait console=ttymxc0,115200 tftpboot 0x10800000 uimage bootm 0x10800000

This should boot you in your Cubox-i installation and you should be able to login as root with your password. From here you can continue with a default Gentoo installation. To make this boot configuration permanent follow the next step "Default".

Environment
In the following we will make the settings permanent. The uImage file is copied to the boot partition. The first line contains the settings for loading the kernel into memory. The second holds the arguments for the kernel. The third one is the code to execute the kernel.

The bootcmd is called by default and executes theses three steps in order. The last line makes these variables permanent in the U-Boot settings.

setenv mybootload ext2load mmc 0:1 0x10800000 /uimage setenv mybootset setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 ro rootwait console=ttymxc0,115200 setenv mybootstart bootm 0x10800000 setenv bootcmd run mybootset mybootload mybootstart saveenv

uEnv
U-Boot can also read configuration values from a file. This way the boot process can be modified without going into the U-Boot console and the settings are permanent as well. The following script is modified from the original mini-image used for the installation.

setenv gsetmmc 'root="root=/dev/mmcblk${rootunit}p$rootpart rootfstype=$rootfs ro rootwait"' setenv gconsole console=ttymxc0,115200 consoleblank=0 setenv gbootextra init=/init setenv grootflags "" setenv gvideo mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24 dmfc=3 setenv gbootpreset 'bootdev=mmc; bootunit=0; bootpart=1; bootfs=ext2; envfile=uEnv.txt; bootroot=; bootfile=uImage' setenv grootpreset 'rootunit=0; rootpart=2; rootfs=ext4' setenv gsetenvscript setenv gbootenv "\'run gset\${bootdev}; setenv bootargs \$root \$gvideo \$gconsole \$gbootextra \$grootflags $end\'" setenv gloaduenv 'if ${bootfs}load $bootdev $bootunit:$bootpart $loadaddr $envfile; then env import -t $loadaddr $filesize; fi' setenv grootpresetup 'bootrun=bootm; loadfile=$bootfile; rootdev=$bootdev; rootunit=$bootunit; rootpart=$rootpart; rootfs=$rootfs' setenv gbootload '${bootfs}load $bootdev $bootunit:$bootpart $loadaddr $bootroot/$loadfile' setenv gbootstart '$bootrun' setenv bootcmd run gbootpreset grootpreset gsetenvscript gloaduenv grootpresetup gbootenv gbootload gbootstart

In the minimal uEnv.txt is enough to boot a stock ext4 system on the SD card. To boot from USB you must use  or.

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

Gentoo arm install Handbook

Graphics driver (closed source)
You can find a portage repository with packages for the closed source drivers on github: https://github.com/stefan-langenmaier/gentoo-cubox-i-repository

Graphics drivers (FOSS)
Although it's not fully integrated yet, there is useful 2D/3D functionality in the latest FOSS drivers, some of which were only recently added to the Gentoo ARM overlay.


 * mesa - the latest releases enable vivante/imx (be sure and enable gallium/glx/dri3 in mesa)
 * libdrm - enables "experimental" vivante/etnaviv api
 * xf86-video-armada - builds multiple drivers, depends on various versions of dependencies below
 * libdrm-armada - gpu shim
 * libetnaviv (latest is header-only, older is a library)
 * galcore-headers - public "etnaviv" interface

Note: the packages in the main portage tree call the imx VIDEO_CARD "vivante" but in the above Xorg drivers vivante refers to the legacy GAL drivers which are disabled (the FOSS pieces should probably all be called etnaviv). To try the FOSS graphics stack, you should set  in your  file and add the ARM overlay.

So far the imx/armada drivers seem to work for 2D in X but the log shows an error initializing the etnadrm_gpu driver and claims to fall back to swrast 3D. Still, with dri3 and vivante enabled glxgears gets over 110 fps in Xorg, so there is that... (if you only have dri2 enabled then it really is swrast @ 22 fps)

eSATA
In addition to enabling the Freescale PCIe driver and related SD support, if you want to connect an external eSATA device, there are two main "issues" to keep in mind:


 * Use a separate USB power source, since there is no power provided over eSATA (and the onboard USB is not enough)
 * You must add  to the kernel command line in  (or your )

Kodi
If you want to install Kodi make sure that:


 * is enabled in the bootargs otherwise you will get a "No signal/no video" after 10 minutes
 * for the moment you should use Kodi and libCEC from the custom repos
 * you have make headers_install executed

Open questions

 * open-source hardware-accelerated video driver
 * reverse engineereddrivers
 * kms driver is disabled in patched kernel