This document gathers all the necessary info to set up an SD-Card with a bootable gnu/linux, with your own kernel and with mali binaries installed.

Order your odroid with the uart module. As with any ARM device, serial is indispensable for debugging any boot failures. Make sure that you are using a recent enough driver for cp210x, this module only became useful after linux kernel 3.2, but the fixes to this specific module can easily be backported. Ask libv on irc for more info if you need this.

SD-Card

First off, clear out the first bits of the SD-Card for sanity's sake:

dd if=/dev/zero of=/dev/mmcblkX bs=1M count=5

Then set up some partitions on the SD-Card:

fdisk /dev/mmcblkX

And work it until it looks somewhat like this:

Command (m for help): p

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes
4 heads, 16 sectors/track, 486192 cylinders, total 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x834d1732

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            3072      527359      262144    b  W95 FAT32
/dev/mmcblk0p2          527360    31116287    15294464   83  Linux

The important thing to note is that the first partition should start at 3072, as the space underneath is used by the u-boot and trustedzone binaries, and it should be a FAT based boot partition. Apart from that, you are free to partition as you like, as long as you update u-boot script accordingly.

Note that this for a 16GB card, actual offsets and sizes might look different for you. In this setup, 256MB was reserved for the boot partition, and the remainder was given for one big root filesystem.

Now format all partitions:

mkfs.vfat /dev/mmcblkXp1
mkfs.ext3 /dev/mmcblkXp2

U-boot setup Pt.1

Samsung does currently not provide sources with its build of u-boot, so both Samsung and Hardkernel are violating the GPL.

You can download a tarball with all the u-boot binaries from here

Untar this:

tar -zxvf boot.tar.gz

Then make the script in there executable:

chmod +x sd_fusing.sh

And now make this script install all the blobs to your SD-Card:

./sd_fusing.sh /dev/mmcblkX

After that, your SD-Card should be bootable, if you have a uart, you should be able to see U-boot attempting to load already.

Root filesystem

Pick a root filesystem laid out for arm hardfloat. My current preference is a Linaro ALIP style image, with lightdm and xfce. It can be downloaded here. Once you have downloaded it, you can simply untar it in the root partition of your sd-card. After untarring, you need to move everything in the binary directory one level up. This is there to protect people from overwriting their main filesystem. Do not forget to remove SHA256SUMS :)

Kernel build

First, you need a clone of the odroid kernel.

You can either clone an existing kernel tree, and then fetch the odroid one on top:

git clone /home/user/kernel/linux-2.6/ kernel
cd kernel/
git remote rm origin
git remote add origin https://github.com/hardkernel/linux.git
git fetch
git checkout odroid-3.0.y

Or you can just make a quick copy of the top level tree, without downloading a full (and huge) git repository.

git clone --depth 1 https://github.com/hardkernel/linux.git -b odroid-3.0.y kernel

Make sure that your cross toolchain is in your path.

You can now select one of many odroid machine targets, although i personally find "ubuntu" very shortsighted:

ls arch/arm/configs/odroid*ubuntu*

Here, we pick the odroid-x2 with mali enabled:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- odroidx2_ubuntu_mali_defconfig 

After this we can build our kernel:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j5 zImage modules

Now go and make some tea :)

Once that's done, run:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/PATH_TO_ROOTFS/ modules_install

You can now copy the kernel image to the boot partition:

cp arch/arm/boot/zImage PATH_TO_BOOTFS

U-boot setup Pt.2

Now we create a file called boot.txt in our boot partition, and it should contain the following:

setenv bootargs 'root=/dev/mmcblk0p2 rw rootwait console=tty0 console=ttySAC1,115200n8 mem=2047M'
ext2load mmc 0:1 0x40008000 zImage
bootm 0x40008000

Then run the following to create boot.scr, the file that u-boot looks for:

mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "BOOT Script for ODROID-X2" -d boot.txt boot.scr

First boot setup

I experienced some resolver issues, as apparently the dhcpd nameserver info was not passed on properly (networkmanager?) So i added the following to /etc/resolv.conf to manually override things

nameserver 192.168.x.x

I then went on to install the most important package for any network connected device:

apt-get update
apt-get install openssh-server

I could then ssh into the device and start changing some things.

sudo -s
passwd

Now you can just ssh in as root.

echo "odroid" > /etc/hostname

Log out and in again to see this take effect.

Then drop the linaro user and add your own. Make sure it is added to the video group.

userdel -r linaro
adduser user
adduser user video

You will see loads of locale issues when running any apt things:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

You can fix these by running:

locale-gen en_US.UTF-8

or by whichever locale is listed as LANG when running locale.

Setting up X

Create /etc/X11/xorg.conf with the following content:

Section "Device"
        identifier "FBDEV"
        Driver "fbdev"
        Option "fbdev" "/dev/fb6"
EndSection

Section "Screen"
        identifier "Default Screen"
        Device "FBDEV"
        DefaultDepth 16
EndSection

You can now start the display manager:

lightdm&

I haven't yet figured out how the strange exynos fb drivers can be coaxed into doing 24 bit colour.

Mali binaries

Install es2gears and es2_info through:

apt-get install mesa-utils-extra

This will drag in the full mesa, which includes an openGLESv2 lib, which we really do not need.

mv /usr/lib/arm-linux-gnueabihf/mesa-egl /usr/lib/arm-linux-gnueabihf/.mesa-egl

Nasty, but works.