Udoo



This document describes how to install Gentoo using mainline u-boot and kernel plus FOSS graphics on the Udoo Quad and Dual kickstarter boards. See this gist for a quick and dirty howto on Udoo Neo,

Prerequisite

 * Udoo Quad/Dual
 * if you want to configure over a serial console you need a micro-USB cable.
 * otherwise you need an HDMI display and a USB keyboard (and hope ;)
 * git
 * SD card (with enough space, rootfs with a kernel and Gentoo, 4GB+)
 * network cable for an internet connection (the WiFi driver should actually work with a newer kernel)
 * 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 Udoobuntu image to see if your machine is working with the serial connection (or the connected keyboard and display). This will overwrite your card!
 * tftp server
 * Udoobuntu
 * Udoobuntu

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. Building U-Boot and 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 Udoo was released there was no mainline support for it. So the vendor maintained its own patched fork of bootloader and kernel. That said, since 2014.04 a mainline U-Boot works without any patches, so there is no longer a real reason to go with the fork. Just use mainline (and possibly some RCN convenience patches).

If you're already familiar with the LinuxOnArm wiki approach and like the convenience of uEnv.txt configuration, then you can download and apply the optional patch below.

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, which is the default kernel make install path:

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

Get the patch here: https://dev.gentoo.org:/~nerdboy/files/0001-udoo-uEnv.txt-bootz-n-fixes-ala-rcn-2017.11.patch

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

Setup serial console
The Udoo Quad/Dual boards all have serial console support via a FTDI FT230X USB to UART serial interface. This allows connecting the Udoo directly to another computer. Alternatively the Udoo can be connected to an HDMI display and USB keyboard.

The computer connecting to the Udoo 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.

Note with U-Boot uEnv.txt patch above, you can make the sdcard a single ext4 partition with /boot directory instead of the two partitions shown below. The patch also allows you to change the rootfs via the "mmcroot" variable.

Preparing the SD card
As noted above, 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 Udoo 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 kernels. As of this writing you can apply them to sys-kernel/git-sources-4.xx or the matching gentoo-sources. 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 the individual 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  or the armv7-multiplatform config.

Install the sys-kernel/linux-firmware and net-wireless/wpa_supplicant packages and you should be all set.

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 Udoo U-Boot differ. Mainline supports and extlinux.conf on the first partition, and it also supports  with the patch. The Udoo version of u-boot-imx supports both methods natively.

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

extlinux.conf
Vanilla U-Boot also 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:

Adjust the video argument to match your display.

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 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)

Sam3 Microcontroller (Arduino Due compatible)
The main "thing" about Udoo boards is that they have a built-in Arduino-compatible ARM cortex-M microcontroller. The original Udoo Quad/Dual boards have an Atmel Sam3 (equivalent to a Cortex-M3, no FPU) connected directly to the i.MX ARM via serial (ttymxc3 on the ARM side). This can be adjusted via a jumper on the board. As of the 4.14 mainline kernel there is a new imx-rproc driver similar to the BeagleBone PRU drivers (as well as the rpmsg char interface).

You can use the latest crossdev-99999999 to build a multilib arm-none-eabi toolchain for ARM embedded processors; currently gcc 5.4.0_r4 and 6.4.0 in the ada-overlay have some extra patches for armv8-M and somewhat saner support for thumb/hardfloat/softfloat but it should be possible with the current versions in the main Portage tree. Without the extra patches, you should add "--with-multilib-list=aprofile" to EXTRA_ECONF on your crossdev command, and for bare metal toolchains you should also add USE="-nptl -sanitize -vtv".

Hardware Random Number Generator
The FSL/NXP i.MX6 boards have a hardware random number generator.

All of the Freescale CAAM kernel options should be enabled as modules (built-in may have trouble with rngd).

Driving /dev/random with the hardware CAAM module is done via the following steps.

Apply settings in /etc/conf.d/rngd
Add the following to /etc/conf.d/rngd

Check that /dev/random is slow
To verify that we have done everything correctly, open a new terminal and do: It will start displaying gibberish (random) but will stop at some point or at least slow down. Now issue CTRL+C to stop it.

Test if it works
Again, issue: in another terminal. Now the random information should be flowing faster than the first time around. Now issue CTRL+C to stop it.

Using the kernel entropy source (a USB keyboard attached, display connected) /dev/random spews approx. 100 "chars" of random information before it blocks. After loading the module and starting rng-tools, it should print out many lines without blocking.

Add rng-tools to boot
If all is good, add rngd to boot.

Add loading of caamrng to boot
Add the following to /etc/conf.d/modules so that the module gets loaded at boot

Open questions

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