Odroid-XU4

Installing Gentoo on an Odroid-XU4
This will be a step by step guide on getting a fully functional Gentoo distribution of GNU/Linux onto your Odroid-XU4. It will begin with assuming the user has done nothing to the XU4 and assuming that the XU4 has internet access to it. The guide will walkthrough how to install gentoo from another OS onto another partition, then configuring the bootloader(U-Boot) to boot off of that partition. This guide is based off of https://wiki.gentoo.org/wiki/Installation_alternatives#Installing_Gentoo_from_an_existing_Linux_distribution

Specific hardware needed: A sd-card to USB device.

Steps:

1) Put the sd-card into a sd-card-to-USB device and begin to partition it. If it is a fresh sd-card from hardkernel then there should be plenty of room to split the first partition in 2(my card is 16gb). My favorite way to do this is using Gparted.

2) Boot into the system currently installed onto the XU4, Ubuntu/Debian/other it doesn’t really matter(Does it work?). On the current OS of the XU4, mount the empty partition to /mnt (mine is mmcblk0p2, yours is whatever partition you made) 3) Get the stage3 tarball from www.gentoo.org, you will need the ARMv7a|HardFP and change the filename/date accordingly

4) Extract the tarball, we now have a root file system that we can start working with

5) Once extracted, go to the / directory then chroot into the partition 6) We need to get the portage snapshot, before we can do this we must set the date (emerge-webrsync didn’t work on my machine for some reason) 7) Before we do anything we must alter the make.config file, if we don’t compilations will take a long time on a single arm core. Be sure to add makeopts=”-j9”. Use flags are up to you, for the purpose of this guide I kept them as small as possible. Future experimentation would be switching -march=armv7-a to native, though that will cause problems for distcc, but that’s for another guide.

Below is a sample make.config

CFLAGS="-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" CHOST="armv7a-hardfloat-linux-gnueabi" PORTDIR="/usr/portage" DISTDIR="/usr/portage/distfiles" PKGDIR="/usr/portage/packages" LC_MESSAGES=C USE="-bindist" MAKEOPTS="-j9"
 * 1) These settings were set by the catalyst build script that automatically
 * 2) built this stage.
 * 3) Please consult /usr/share/portage/config/make.conf.example for a more
 * 4) detailed example.
 * 1) WARNING: Changing your CHOST is not something that should be done lightly.
 * 2) Please consult https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable befor$
 * 1) This sets the language of build output to English.
 * 2) Please keep this setting intact when reporting bugs.

8) Before we compile a kernel we must update the system, note this will take a while(several hours, gcc takes about half of the time, be sure you have makeopts=”-j9”), be sure that the date was set correctly before running emerge 9) Time to compile the kernel, unfortunately the official gentoo sources do not work for the odroid-xu4 SoC. If one tries to compile with gentoo-sources and configure the XU4 to boot, it will fail. If one tries to boot the XU4 with a non-gentoo kernel/different config, the system will boot however there will be problems(network interfaces not being detected for example). What needs to happen is one must git clone hardkernel’s official kernel and then compile it with any features one might want. There are 2 ways to do this, manual and automatically with genkernel. Below is how to do it with genkernel. 10) Modify boot loader to boot new kernel and filesystem Below is my boot.ini, adjust the setenv zimage kernel line and setenv bootrootfs line ODROIDXU-UBOOT-CONFIG

setenv version 4.2.0-rc1-41 setenv zimage kernel-genkernel-arm-4.2.0-rc1+ setenv uinitrd uInitrd-${version} setenv fdtbin exynos5422-odroidxu4-${version}.dtb
 * 1) U-Boot Parameters (DO NOT MODIFY)
 * 1) setenv zimage vmlinuz-${version}

setenv zimage_addr_r 0x40008000 setenv initrd_addr_r 0x42000000 setenv fdtbin_addr_r 0x44000000

setenv initrd_high "0xffffffff" setenv fdt_high "0xffffffff"

setenv bootrootfs "root=/dev/mmcblk0p2 rootwait rw" setenv console "console=ttySAC2,115200n8"
 * 1) Default boot argument

setenv bootargs "${bootrootfs} ${console}"

fatload mmc 0:1 ${zimage_addr_r} ${zimage} fatload mmc 0:1 ${initrd_addr_r} ${uinitrd} fatload mmc 0:1 ${fdtbin_addr_r} ${fdtbin} bootz ${zimage_addr_r} ${initrd_addr_r} ${fdtbin_addr_r}"
 * 1) boot commands

11) Set a root password

12) Boot the new kernel and into the new Gentoo environment and that’s it! You should be able to boot without problem! Welcome to Gentoo on the Odroid-XU4 !

Extras)

Create a non-root user https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Finalizing

Networking hasn’t been declared yet, please verify the interfaces have been detected before the below commands are executed Adding SSHD as a default service

If on a switch it’s necessary to declare a static ip Since everything is being define manually, resolv.conf must have a nameserver in it  Start installing all necessary software that you need!

Notes) It might be work experimenting with march=native rather than pre-defined as it is currently, but if the use case for the xu4 is distcc this will cause problems.

The current guide uses the stock initrd, using genkernel to generate a new initrd has not been tested