Gentoo on -XU

Post Reply
marc
Posts: 7
Joined: Mon Mar 10, 2014 11:17 pm
languages_spoken: english
ODROIDs: odroid-xu
Has thanked: 0
Been thanked: 0
Contact:

Gentoo on -XU

Unread post by marc » Sat May 31, 2014 5:51 pm

Hi,

EDIT: This board was supposed to be used as HTPC by running XBMC/Kodi. Due to other dependencies, this was never completed. The only fully functional kernel is a 3.4.x. It is possible to boot from uSD/eMMC with a 4.7 kernel, but it has no support for USB or Ethernet.


This guide is based on [GUIDE] Building your own Ubuntu card from scratch written by mdrjr. Thank you mdrjr.


So, you've got yourself a fantastic odroid-xu and want to gentoo on it? Let's get you started then :)

Installation scenario
The purpose of this guide is to get a SD or eMMC card ready to be booted from your -XU board, running gentoo, without needing for a cross-compile environment. Cross-compiling on gentoo is rather easy but not necessary for this guide.

What you need?
- odroid-xu board
- SD/eMMC card with a functional linux image for your odroid-xu OR a pc running linux
- SD/eMMC card that shall be used to install gentoo into

What you'll get?
- SD or eMMC card ready to be booted from your -XU board, running gentoo

This guide assumes your card is at /dev/mmcblk1. If not, change $SDCARD value accordingly.

Bootloader installation
There is a guide for preparing SD cards for ubuntu which is applicable to Gentoo also (check [GUIDE] Building your own Ubuntu card from scratch for more details). There is no need to compile the boot-loader as it's available as pre-built bootloader (I'll not cover bootloader building because nothing changes over the pre-builts one).

So, get the boot tarball, clean the area where the bootloader and other files shall be written to and install bootloader:

Code: Select all

# Set SD/eMMC card location (change accordingly)
SDCARD=/dev/mmcblk1

# Get bootloader, install script
wget odroid.in/guides/ubuntu-lfs/boot.tar.gz

# Emptying your card
sudo dd if=/dev/zero of=$SDCARD bs=1M

# Installing bootloader
tar zxvf boot.tar.xz
cd boot
chmod +x sd_fusing.sh
sudo ./sd_fusing.sh $SDCARD
cd ..
SD/eMMC preparation
Bootloader is installed, but there are no partitions in the card. We'll create 2 partitions (for /boot and for /) but any other can be created. Just make sure any extra partitions are made after...

Code: Select all

sudo fdisk $SDCARD
n
p
1
3072
+64M
n
p
2
134114
<just press enter here>
t
1
c
w

# Call partprobe to get our new partitions read by the kernel
sudo partprobe
Format and mount our partitions
At this step we'll format our partitions

Code: Select all

mkfs.vfat -n boot $SDCARD"1"
mkfs.ext4 -L rootfs $SDCARD"2"
mdrjr has a kernel-update script that requires the / partition to have a certain UUID. If you intend to use it then change the UUID to the same UUID that odroid uses on Official Ubuntu so later on you can use the kernel-update script :)

Code: Select all

#optional (to be able to run mdrjr kernel-update script)
tune2fs $SDCARD"2" -U e139ce78-9841-40fe-8823-96a304a09859
Lets disable Journaling to prevent excessive wearing of your card

Code: Select all

tune2fs -O ^has_journal $SDCARD"2"
And mount the partitions.

Code: Select all

mkdir rootfs
mkdir bootfs
sudo mount $SDCARD"1" bootfs
sudo mount $SDCARD"2" rootfs
Install stage3 tarball and prepare for first boot
Grab a stage3 tarball from your preferred mirror and install it:

Code: Select all

MIRROR=http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-armv7a_hardfp
CURRENT_TARBALL=`curl -s $MIRROR/ | grep 'tar.bz2"' | sed -e 's@.*a href="\(.*\).tar.bz2".*@\1@'`

echo "Current stage3 tarball is: $CURRENT_TARBALL.tar.bz2"

wget $MIRROR/$CURRENT_TARBALL.tar.bz2
tar xjpf $CURRENT_TARBALL.tar.bz2 -C ./rootfs
Enter chroot
Enter into your brand new Gentoo Linux installation and update portage:

Code: Select all

mount -t proc proc rootfs/proc
mount --rbind /dev rootfs/dev
mount --rbind /sys rootfs/sys
cp -L /etc/resolv.conf rootfs/etc/ 
chroot rootfs/ /bin/bash
source /etc/profile
emerge --sync
Right now, you may configure your system as you would in any other Gentoo installation (make.conf, use flags, locales, timezone, etc). One important configuration is fstab. Use the following:

Code: Select all

mount -t devtmpfs devtmpfs /dev
cat << __EOF__ >> /etc/fstab
/dev/mmcblk0p2		/		ext4		defaults,noatime	0 1
/dev/mmcblk0p1		/mnt/boot	vfat		noauto,defaults,rw,owner	0 0
tmpfs			/dev/shm	tmpfs		nodev,nosuid,mode=1777	0 0
__EOF__
Kernel compile
As you may see in OFFICIAL Sources Resource, the following official resources available for -XU are:
For 5410-based Products (XU)
XU Wiki: http://odroid.com/dokuwiki/doku.php?id=en:odroid-xu

Kernels:
- 3.4 Used on Android and Linux Github
- 3.14 Testing Kernel Github

Bootloaders:
- U-Boot 2012.07 (Supports 3/4 USB 2.0 Ports, Networking, ext4 and ZFS) Github U-Boot for -xu branch (U-boot for exynos wiki).

Although there are some patches to support the exynos 5410 of the odroid-xu, the mainline kernel still doesn't have support for the -xu (maybe in 3.16?). So, to compile a kernel, grab the sources from Hardkernel's github or install layman and set it to use my overlay (present in github).

Code: Select all

emerge layman -av

# Add overlay to layman configuration
cp /etc/layman/layman.cfg /etc/layman/layman.cfg.bkp && \
cat /etc/layman/layman.cfg.bkp | \
sed '/^overlays/a \            https://raw.githubusercontent.com/wabbit01/odroid-xu-support/master/overlay.xml' > \
/etc/layman/layman.cfg

# Overlay
layman -a odroid-xu-support
After adding my overlay, you may emerge your kernel (at the time of writing only 3.4 kernel booted and don't have the debug UART cable to debug why the 3.14 doesn't boot). You may also use mdrjr kernel update script present in the forum.

Code: Select all

emerge odroidxu-sources -av
There is a default configuration file in github if needed (.config). If you use that then:

Code: Select all

cd /usr/src/linux && \
wget https://raw.githubusercontent.com/wabbit01/odroid-xu-support/master/config-kernel-3.4.99 -O .config
After configuration of the kernel, make it and put it in the boot partition:

Code: Select all

cd /usr/src/linux && make && make modules_install && make zImage
mount /mnt/boot
cp arch/arm/boot/zImage /mnt/boot
cd /
Until now, no U-boot configuration was setup. It currently reads a boot.ini file in the boot partition. To setup this, and to have 1080p hdmi working, do the following:

Code: Select all

cat << __EOF__ >> /mnt/boot/boot.ini
setenv initrd_high "0xffffffff"
setenv fdt_high "0xffffffff"
setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; bootm 0x40008000"
setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=/dev/mmcblk0p2 rootwait rw mem=2047M"
boot
__EOF__
Another boot.ini file (more comprehensive but not thoroughly tested) available at Github.
Other important configurations
There is no framebuffer (yet) for -xu, so, to use your -xu after booting it up, make sure that network and ssh are configured correctly upon boot-up:

Code: Select all

/etc/init.d/sshd start
rc-update add sshd

# Set a new root password
passwd

# Set automatic network configuration
emerge dhcpcd -av
cd /etc/init.d
ln -s net.lo net.eth0
rc-update add net.eth0
Clean-up and other optional configurations
Great! Now your should be able to boot from your odroid-xu board and access it via ssh. Leave the chroot and unmount any mount points and try to boot your board. NOTE: Don't forget to check if the DIP switches on the board are set correctly to boot from your SD (DIP switch#1 off) or from eMMC (DIP switch#1 on).

After boot-up, you may add some more mount points to use a SD card for portage compilation area instead of wearing your precious new SD/eMMC card with gentoo. Add the following to fstab and move files to folders:

Code: Select all

cat << __EOF__ >> /etc/fstab
# Other SD card to use for portage compilation
/dev/mmcblk1p1		/mnt/external_sd	ext4		defaults,noatime	0 0

# BINDS
/mnt/external_sd/usr/src	/usr/src	none	bind	0 0
/mnt/external_sd/usr/portage	/usr/portage	none	bind	0 0
/mnt/external_sd/var/cache	/var/cache	none	bind	0 0
/mnt/external_sd/var/log	/var/log	none	bind	0 0
/mnt/external_sd/var/tmp	/var/tmp	none	bind	0 0
__EOF__

mkdir /mnt/external_sd/
mkdir /mnt/external_sd/usr/
mkdir /mnt/external_sd/var/
All done! Now, you should have a bootable Gentoo SD/eMMC card, that should be accessible via ssh only! No framebuffer working!

Right now haven't put X11 or xbmc working. Any input would be appreciated.

Do you think this guide is missing something? Then tell me about it and it shall be updated :D
Last edited by marc on Tue Aug 23, 2016 12:32 am, edited 1 time in total.

efeschiyan
Posts: 9
Joined: Tue Sep 09, 2014 7:19 am
languages_spoken: english
ODROIDs: ODROID-XU3, ODROID-VU
Has thanked: 0
Been thanked: 0
Contact:

Re: Gentoo on -XU

Unread post by efeschiyan » Fri Oct 31, 2014 2:56 am

That's awesome. :ugeek:
Is this procedure applicable for the XU3 ?
If not - what kind of stuff should be changed/updated?
I am planning to put Gentoo on my XU3, and if I succeed I'll create a new repository for it.

bMd
Posts: 9
Joined: Sat Nov 08, 2014 12:35 am
languages_spoken: english
ODROIDs: XU3, XU4, C1, C1+, C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Gentoo on -XU

Unread post by bMd » Thu Nov 13, 2014 12:29 am

efeschiyan wrote:That's awesome. :ugeek:
Is this procedure applicable for the XU3 ?
If not - what kind of stuff should be changed/updated?
I am planning to put Gentoo on my XU3, and if I succeed I'll create a new repository for it.
Getting XU3 in the near future, did you successfully install Gentoo on your XU3 following this guide?

omegablue
Posts: 1
Joined: Wed Dec 24, 2014 5:11 am
languages_spoken: english
ODROIDs: xu3-lite
Has thanked: 0
Been thanked: 0
Contact:

Re: Gentoo on -XU

Unread post by omegablue » Mon Jan 12, 2015 10:40 pm

The Odroid xu3-lite Quick Install Guide is in progress. If you speak Spanish you can go here.
http://alice.bugs3.com/blog/2015/01/gen ... -xu3-lite/

If you do not know Spanish you can wait for this
https://wiki.gentoo.org/wiki/Odroid_xu3 ... tall_Guide

I will publish an image but I do not have the time to do all that I want ;-)

Have a nice day

bMd
Posts: 9
Joined: Sat Nov 08, 2014 12:35 am
languages_spoken: english
ODROIDs: XU3, XU4, C1, C1+, C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Gentoo on -XU

Unread post by bMd » Fri Jan 30, 2015 1:37 am

Awesome, thanks omegablue!!!! Gonna purchase another XU3 now. :-)

Post Reply

Return to “Ubuntu (All Linux'es)”

Who is online

Users browsing this forum: No registered users and 2 guests