This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Xu4

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
Warning
This article has been flagged as dirty for not conforming to the wiki guidelines. It is now grouped in the list of articles to be cleaned.

This article is a step by step guide on getting a fully functional Gentoo distribution of GNU/Linux on 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 walk through 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 Installation alternatives article.

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

Installation

Partitioning

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

A signed u-boot has to be used, creating a uboot, bootloader from source is possible but require a signed stage. Odroid has been signing these stages, check their support forum. More information from Odroid here

This method uses the already existing bootloader from the image used to bootstrap the system. It is recommended to do this before the partitioning in case the command overwrites the start of a partition.

Warning
This is a VERY dangerous command. If a mistake is made, permanent loss of data can occure.
CODE Device names
/dev/mmcblkX where the initial system is located
/dev/mmcblkY where the final gentoo system will be located

Boot loader installation:

root #dd if=/dev/mmcblkX of=/dev/mmcblkY skip=1 seek=1 bs=512 count=2046

Partitions example:

root #fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 58.2 GiB, 62537072640 bytes, 122142720 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
Disklabel type: dos
Disk identifier: 0x3cedfd53

Device         Boot  Start       End   Sectors  Size Id Type
/dev/mmcblk0p1        2048    526335    524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      526336 122142719 121616384   58G 83 Linux

Formatting the partitions

It is recommended to have the sys-fs/dosfstools and sys-fs/exfat-utils available on the host and final system.

root #mkfs.vfat -F32 -n BOOT /dev/mmcblkYp1
root #mkfs.ext4 -L root /dev/mmcblkYp2

Boot the current distro

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)

root #mount /dev/mmcblk0p2 /mnt
root #cd /mnt

Get the appropriate stage3

Get the stage3 tarball from gentoo.org, you will need the ARMv7a|HardFP and change the filename/date accordingly

Extract stage3

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

root #tar -xjvf stage3-armv7a_hardfp-20160523.tar.bz2
root #rm stage3-armv7a_hardfp-20160523.tar.bz2

Copy X11 configuration files

Just in case...

root #cp -a /etc/X11 /mnt/etc/

chroot to the new environment

Once extracted, go to the / directory then chroot into the partition:

root #cd /
root #mount -t proc none /mnt/proc
root #mount --rbind /sys /mnt/sys
root #mount --rbind /dev /mnt/dev
root #cp -L /etc/resolv.conf /mnt/etc
root #chroot /mnt /bin/bash
root #env-update (might fail without the portage snapshot)
root #source /etc/profile

Get a Portage snapshot

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

root #date MMDDHHMMYYYY
root #cd /usr
root #tar -xvjf portage-latest.tar.bz2
root #emerge –sync
root #rm portage-latest.tar.bz2

Set up make.conf

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.

root #nano /etc/portage/make.conf
CODE make.config sample
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable before changing
CHOST="armv7a-hardfloat-linux-gnueabi"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C

USE="-bindist"
MAKEOPTS="-j3"

Update the system

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=”-j3”, as bigger values tend to saturate memory), be sure that the date was set correctly before running emerge:

root #emerge --sync
root #emerge --update --deep --newuse @world
root #emerge --depclean
root #emerge -a app-portage/gentoolkit (needed for revdep-rebuild)
root #revdep-rebuild

Build the kernel

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.

Ensure that partitions are correctly mapped:

root #nano /etc/fstab


root #mount /dev/mmcblk1p1 /boot

Verify dev-vcs/git and sys-devel/bc are installed so that the next steps can operated as expected. Emerge the packages if necessary.

For the 1st time:

root #cd /usr/src
root #git clone https://github.com/hardkernel/linux.git -b odroidxu4-4.14.y --depth 1 odroidxu4-4.14.y
root #ln -s odroidxu4-4.14.y linux

Followed by from now and future updates from the git tree:

root #mount /dev/mmcblk0p1 /boot
root #cd /usr/src/odroidxu4-4.14.y/
root #git pull # simply put, it synchronizes the local with the remote repository;
root #cd ..
root #genkernel --kernel-config=/usr/src/linux/arch/arm/configs/odroidxu4_defconfig all

You will then need the dev-embedded/u-boot-tools to create a uInitrd from the current initramfs, once all the files are created, let's copy all of them to /boot

root #cd /usr/src/odroidxu4-4.14.y/
root #mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -d /boot/initramfs-genkernel-arm-`make kernelrelease` uInitrd-`make kernelrelease`
root #cp arch/arm/boot/zImage /boot/zImage-`make kernelrelease`
root #cp arch/arm/boot/dts/exynos5422-odroidxu4.dtb uInitrd-`make kernelrelease` /boot

Remember the value returned by make kernelrelease you will need to adjust the file names in the boot.ini

In case someone would like to use any of the menuconfig, for instance, or add / remove any driver or something else to / from the new kernel, I think it would be useful to copy the final /usr/src/linux/.config file back to /usr/src/linux/arch/arm/configs/odroidxu4_defconfig, or to copy the /usr/src/linux/.config to some safe place for further use.

Set up the boot loader

Modify boot loader to boot new kernel and filesystem:

root #cd /boot
root #nano boot.ini

Below is the original boot.ini from the latest Ubuntu image, adjust the line with:

CODE original
fatload mmc 0:1 0x40008000 zImage

to

CODE new
fatload mmc 0:1 0x40008000 kernel-genkernel-arm-4.9.34


CODE Complete boot.ini
ODROIDXU-UBOOT-CONFIG

# U-Boot Parameters
setenv initrd_high "0xffffffff"
setenv fdt_high "0xffffffff"

# Mac address configuration
setenv macaddr "00:1e:06:61:7a:39"

#------------------------------------------------------------------------------------------------------
# Basic Ubuntu Setup. Don't touch unless you know what you are doing.
# --------------------------------
setenv bootrootfs "console=tty1 console=ttySAC2,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro fsck.repair=yes net.ifnames=1"

# --- Screen Configuration for HDMI --- #
# ---------------------------------------
# Uncomment only ONE line! Leave all commented for automatic selection.
# Uncomment only the setenv line!
# ---------------------------------------
# ODROID-VU forced resolution
# setenv videoconfig "video=HDMI-A-1:1280x800@60"
# -----------------------------------------------
# ODROID-VU forced EDID
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1280x800.bin"
# -----------------------------------------------
# 1920x1200 60hz without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1200_60hz.bin"
# -----------------------------------------------
# 1920x1200 30hz without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1200_30hz.bin"
# -----------------------------------------------
# 1920x1080 (1080P) with monitor provided EDID information. (1080p-edid)
# setenv videoconfig "video=HDMI-A-1:1920x1080@60"
# -----------------------------------------------
# 1920x1080 (1080P) without monitor data using generic information (1080p-noedid)
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1080.bin"
# -----------------------------------------------
# 1920x1080 50hz (1080P) with monitor provided EDID information. (1080p 50hz-edid)
# setenv videoconfig "video=HDMI-A-1:1920x1080@50"
# -----------------------------------------------
# 1920x1080 50hz (1080P) without monitor data using generic information (1080p 50hz-noedid)
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1080_50hz.bin"
# -----------------------------------------------
# 1680x1050 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1680x1050.bin"
# -----------------------------------------------
# 1600x1200 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1600x1200.bin"
# -----------------------------------------------
# 1600x900 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1600x900.bin"
# -----------------------------------------------
# 1440x900 with monitor provided EDID information.
# setenv videoconfig "video=HDMI-A-1:1440x900@60"
# -----------------------------------------------
# 1440x900 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1440x900.bin"
# -----------------------------------------------
# 1366x768 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1366x768.bin"
# -----------------------------------------------
# 1360x768 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1360x768.bin"
# -----------------------------------------------
# 1280x1024 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1280x1024.bin"
# -----------------------------------------------
# 1280x720 (720P) with monitor provided EDID information. (720p-edid)
# setenv videoconfig "video=HDMI-A-1:1280x720@60"
# -----------------------------------------------
# 1280x720 (720P) without monitor data using generic information (720p-noedid)
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1280x720.bin"
# -----------------------------------------------
# 1024x768 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1024x768.bin"
# -----------------------------------------------
# 1024x600 without monitor data using generic information (ODROID VU7+)
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1024x600.bin"
# -----------------------------------------------
# 800x600 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/800x600.bin"
# -----------------------------------------------
# 800x480 without monitor data using generic information (ODROID 7")
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/800x480.bin"
# -----------------------------------------------
# 720x576 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/720x576.bin"
# -----------------------------------------------
# 720x480 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/720x480.bin"
# -----------------------------------------------
# 640x480 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/640x480.bin"
# -----------------------------------------------
# 480x800 without monitor data using generic information
# setenv videoconfig "drm_kms_helper.edid_firmware=edid/480x800.bin"

# --- HDMI / DVI Mode Selection ---
# ------------------------------------------
# - HDMI Mode
setenv vout "hdmi"
# - DVI Mode (disables sound over HDMI as per DVI compat)
# setenv vout "dvi"

# --- HDMI CEC Configuration ---
# ------------------------------------------
setenv cecenable "false" # false or true
# set to true to enable HDMI CEC

# Enable/Disable ODROID-VU7 Touchsreen
setenv disable_vu7 "true" # false

# CPU Governor Selection
# Available governos: conservative, userspace, powersave, ondemand, performance, schedutil
setenv governor "performance"

# External watchdog board enable
setenv external_watchdog "false"
# debounce time set to 3 ~ 10 sec, default 3 sec
setenv external_watchdog_debounce "3"


#------------------------------------------------------------------------------
#
# HDMI Hot Plug detection
#
#------------------------------------------------------------------------------
#
# Forces the HDMI subsystem to ignore the check if the cable is connected or
# not.
# false : disable the detection and force it as connected.
# true : let cable, board and monitor decide the connection status.
#
# default: true
#
#------------------------------------------------------------------------------
setenv HPD "true"

setenv hdmi_phy_control "HPD=${HPD} vout=${vout}"

# Load kernel, initrd and dtb in that sequence
fatload mmc 0:1 0x40008000 kernel-genkernel-arm-4.9.34
fatload mmc 0:1 0x42000000 uInitrd
if test "${board_name}" = "xu4"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "xu3"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu3.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "xu3l"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu3-lite.dtb; setenv fdtloaded "true"; fi
#failsafe
if test "${fdtloaded}" != "true"; then fatload mmc 0:1 0x44000000 exynos5422-odroidxu4.dtb; fi

fdt addr 0x44000000

if test "${cecenable}" = "false"; then fdt rm /cec@101B0000; fi
if test "${disable_vu7}" = "false"; then setenv hid_quirks "usbhid.quirks=0x0eef:0x0005:0x0004"; fi
if test "${external_watchdog}" = "true"; then setenv external_watchdog "external_watchdog=${external_watchdog} external_watchdog_debounce=${external_watchdog_debounce}"; fi

# final boot args
setenv bootargs "${bootrootfs} ${videoconfig} ${hdmi_phy_control} ${hud_quirks} smsc95xx.macaddr=${macaddr} ${external_watchdog} governor=${governor}"

# Boot the board
bootz 0x40008000 0x42000000 0x44000000

Set a root password

root #passwd

Reboot

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

X11

Willing for a graphical environment, X11 is a classical - although there is a pretty interesting article in a recent Odroid Magazine about Wayland - so there is the need for the specific driver. Emerge layman and add the hossie overlay:

root #emerge -vD --quiet-build layman && layman -S && layman -a hossie

Emerge the exynos armsoc X11 driver:

root #emerge -vuDN --quiet-build x11-drivers/xf86-video-armsoc

Emerge all xorg/X11 stuff according to the usual Gentoo_Handbook at https://wiki.gentoo.org/wiki/Handbook:Main_Page

The original Ubuntu image has a "xorg.conf" configuration file and "xorg.conf.d" directory for extra configurations in /etc/X11, that has already both been copied to Gentoo in an earlier step. Then, it should be possible to get a graphical desktop like fluxbox or WindowMaker, for instance.

EGL/GLES/OpenCL MALI drivers

Usually the latest working driver is located here: 5422_mali

Or from the odroid debian package: mali-fbdev

unmask the opencl use flag

Tentative to create an ebuild should be based on : New_eselect-opengl_design

Create a non-root user

Handbook:AMD64/Installation/Finalizing

Networking

Networking hasn’t been declared yet, please verify the interfaces have been detected before the below commands are executed

root #cd /etc/init.d
root #ln -s net.lo net.eth0
root #rc-update add net.eth0 default

SSH for remote access

Adding SSHD as a default service

root #rc-update add sshd default

If on a switch it’s necessary to declare a static ip

root #cd /etc/conf.d
root #nano net

Name server

Since everything is being define manually, resolv.conf must have a nameserver in it:

root #cd /etc
root #nano resolv.conf
root #nameserver 8.8.8.8

Start installing all necessary software that you need!

Fan/temperature control

Gentoo puts all of the temperature monitors in the /sys/devices/virtual/thermal/ directory. In order to change the fan settings you must modify the .dtb, these are located in /usr/src/linux/arch/arm/boot/dts.

One can modify the exynos5422-odroidxu4.dts easily, however notice that exynos5422-odroidxu3-common.dtsi is included, here is where one portion of the fan control:

CODE
fan0: pwm-fan {
    compatible = "pwm-fan";
    pwms = <&pwm 0 20972 0>;
    cooling-min-state = <0>;
    cooling-max-state = <3>;
    #cooling-cells = <2>;
    cooling-levels = <255 255 255 255>;
};

Where 255 = 100%

To change the CPU states modify the exynos5422-cpu-thermal.dtsi file

Note
It might be worth 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