Gentoo Logo

Gentoo on the TrimSlice

Content:

1.  Overview

Installing Gentoo in the TrimSlice is pretty simple if you're already a Gentoo user. You need to use an SD card, at least of 2 GB of size. If you are familar with the Gentoo Linux installation process, there is not much different here.

Warning: Please keep in mind that this guide was tested on the TrimSlice devkit, so bluetooth and wifi support are out of the scope of this guide since the devkit lacks those.

2.  Requirements

To be able to install Gentoo, you'll need the following:

  • An x86/amd64 based PC with Gentoo and an SD card reader on it
  • A TrimSlice
  • One SD card (2 GB is enough)
  • A network connection

3.  Preparing to install your TrimSlice

Overview

Before we start the installation process, we need to get/build a kernel for the TrimSlice

Emerging needed tools

For building the stuff needed to boot our TrimSlice, we need the following tools emerged on the host system where we're going to build them.

  • sys-devel/crossdev - to create a crosscompiler
  • dev-embedded/u-boot-tools - to create a kernel image U-Boot can understand

Code Listing 3.1: Emerge needed tools

# emerge sys-devel/crossdev dev-embedded/u-boot-tools

Build a crosscompiler

Code Listing 3.2: Building a crosscompiler

# crossdev -S armv7a-unknown-linux-gnueabi

Obtaining/Building a kernel

For booting the TrimSlice we need a kernel. The vanilla kernel.org doesn't have all the drivers, etc needed for the TrimSlice yet. Therefore we'll use the kernel maintained by Compulab(The company behind TrimSlice).

Compulab's git tree is available at http://gitorious.org/trimslice-kernel. On this guide we'll be using the 1.01-upstream branch.

Code Listing 3.3: Obtaining the kernel

# wget http://gitorious.org/trimslice-kernel/trimslice-kernel/archive-tarball/trimslice/1.01-upstream

(Extract and change to the directory)
# tar zxvf 1.01-upstream && cd trimslice-kernel-trimslice-kernel

Code Listing 3.4: Configuring the kernel

# make ARCH=arm trimslice_defconfig

(You could run menuconfig after this)

Code Listing 3.5: Cross-compiling the kernel

(Replace 9 with the number of cores you have on your computer)
# make -j9 ARCH=arm CROSS_COMPILE=armv7a-unknown-linux-gnueabi- uImage

Once it gets built we'll have a kernel image on arch/arm/boot/uImage.

Creating the boot script

Since we're using an SD card to do our install, we'll have to create a boot script that U-Boot will read from the SD card upon startup so it knows where to load the kernel from and the specific parameters to boot from SD.

Create a file called boot.script with the following contents:

Code Listing 3.6: boot.script content

setenv bootargs 'root=/dev/mmcblk0p1 rw rootwait console=tty1 console=ttyS0,115200n8 mem=384M@0M mem=512M@512M nvmem=128M@384M vmalloc=248M nohdparm noinitrd init=/sbin/init rootwait loglevel=8 video=tegrafb'
ext2load mmc 0:1 4080000 /boot/uImage
bootm 4080000

Now we need to convert it to a format U-Boot can understand.

Code Listing 3.7: Converting boot.script to boot.scr

(The output file needs to be named boot.scr)
# mkimage -A arm -T script -C none -n "TrimSlice boot script" -d boot.script boot.scr

It will generate a file called boot.scr that contains the commands U-Boot will execute upon starting. We'll copy that file to the /boot directory.

4.  SD card setup

Overview

We'll just create a partition that uses all the space on the card.

Warning: I've been told that most of the USB SD card readers display the SD card as an /dev/sd* device, so make sure you modify the parameters i mention as /dev/mmcblk0 accordingly.

Creating the partition table and formatting the SD card

First we need to create the partition table on the SD card. This will erase all the contents on the card, so make sure you don't have any important data on it.

Code Listing 4.1: Creating a new partition table with one partition

(Make sure you're root)
# fdisk /dev/mmcblk0

(Create an empty partition table)
Command (m for help): o

(Create a new partition using all the space)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 1): 1
First sector (2048-15654911, default 2048): (Hit enter) 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15654911, default 15654911): (Hit enter)
Using default value 15654911

(Write the changes)
Command (m for help): w

Now we'll format the new partition

Code Listing 4.2: Formatting the new partition

# mkfs.ext3 -i 4096 /dev/mmcblk0p1

Copying the kernel to the SD card

Now we'll mount the first partition on the card and copy the needed files (the ones that we built before) to boot our TrimSlice.

Code Listing 4.3: Copying the kernel to the SD card

(Make sure you're root)
# mkdir /mnt/p1 ; mount /dev/mmcblk0p1 /mnt/p1 ; mkdir /mnt/p1/boot

# cp boot.scr /mnt/p1/boot
# cp arch/arm/boot/uImage /mnt/p1/boot

5.  Installing Gentoo

Overview

The installation on this device is a bit different, and therefore easy, as we can't install Gentoo on it by booting an installation environment. For installing Gentoo (and any other distro, really) you need to put the SD card on your PC and prepare there the minimal installation.

What we'll have to do to setup our installation is:

  1. Extract stage3 to the 1st partition of the SD card
  2. Extract portage snapshot (required to emerge things and ntp(see below))
  3. Setup fstab
  4. Setup root password
  5. Configure hostname and networking (optional, but recommended)
  6. Enable SSH access (optional, but recommended)
  7. Enable serial console access (optional, but recommended)

Stages information

Here's some information about the stages.

  • Architecture: arm
  • Subarchitecture: armv7a
  • CHOST: armv7a-unknown-linux-gnueabi
  • Profile: default/linux/arm/10.0

We'll be using the new EABI, also called gnueabi. That is armel on Debian.

Therefore, we need an armv7a-unknown-linux-gnueabi stage3 for best performance, available under the releases/arm/autobuilds directory in your favorite mirror

Optionally you can also grab a portage snapshot

Extracting a stage3

Extract the stage3 you downloaded.

Code Listing 5.1: Extracting the stage3

(Make sure you're root)
(Extract the stage3, it may take a while)
# tar xjpf stage3-armv7a-20101118.tar.bz2 -C /mnt/p1

Extracting a portage snapshot (optional)

Code Listing 5.2: Extracting the snapshot

(Extract the snapshot, it may take a while)
# tar xjpf portage-latest.tar.bz2 -C /mnt/p1/usr

Setup fstab

Edit the /mnt/p1/etc/fstab file to look like this:

Code Listing 5.3: /mnt/p2/etc/fstab

(This is the important part)
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/mmcblk0p1		/		ext3		noatime		0 1

(Remove the following lines as we don't have SWAP, cdrom, or floppy)
/dev/SWAP		none		swap		sw		0 0
/dev/cdrom		/mnt/cdrom	auto		noauto,ro	0 0
#/dev/fd0		/mnt/floppy	auto		noauto		0 0

Setting the default root password

This is the most important part of the installation. As without the root password we won't be able to login!

For setting the password, we need to be able to run passwd. However that's not possible since our PC can't run ARM binaries. Therefore we need to modify the file that contains the passwords (/etc/shadow) inside the chroot, so we can set a default root password.

Code Listing 5.4: Change the default root password

(Generate a password)
# openssl passwd -1

# nano -w /mnt/p1/etc/shadow

(Replace the first line with the following line)
root:s3cr3t:14698:0:::::
(Replace s3cr3t with the output the openssl command gave you)

(For example, this line makes the password be gentoo)
root:$6$I9Q9AyTL$Z76H7wD8mT9JAyrp/vaYyFwyA5wRVN0tze8pvM.MqScC7BBm2PU7pLL0h5nSxueqUpYAlZTox4Ag2Dp5vchjJ0:14698:0:::::

Setup hostname and networking

Please read the network configuration chapter of the ARM handbook to configure the network.

Enabling SSH access (optional)

We can add sshd to the startup of our system so we can access our TrimSlice using ssh.

Code Listing 5.5: Adding sshd to the startup

# ln -s /mnt/p1/etc/init.d/sshd /mnt/p1/etc/runlevels/default

Enabling serial console access (optional)

By default the ttyS0 port is configured at 9600 bps. However, almost all of the ARM devices run the serial port at 115200 bps. So this should be added to the /etc/inittab file:

Code Listing 5.6: Configuring serial console

# nano -w /mnt/p1/etc/inittab

(Replace 9600 with 115200 on the ttyS0 line)
s0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100

Finishing the installation

Let's unmount the SD card

Code Listing 5.7: Unmounting the SD card

(May take a while depending the speed of your SD card)
# umount /mnt/p1

This is pretty much all of the installation. I'd highly recommend that you read all the recommendations of the handbook.

6.  Booting up our new system

Once you have the card ready, put it into the TrimSlice... and you should be able to boot it.

7.  After booting

One of the problems of the TrimSlice is that it doesn't save the date because it doesn't have a battery for the clock.

After logging into our new Gentoo on TrimSlice installation, I'd recommend setting a date and emerging net-misc/ntp to keep the clock up-to-date. Also it's recommended to put both ntp-client and ntpd to boot on startup, so you get a proper date setup.

However, keep in mind that NTP requires a network connection and a NTP server being reachable, either on the local network or on the Internet.

Code Listing 7.1: Emerging net-misc/ntp

(Make sure you're root)
# emerge net-misc/ntp

(Put both ntp-client and ntpd to boot on startup)
# rc-update add ntpd default
# rc-update add ntp-client default

(Start ntp-client and ntpd)
# /etc/init.d/ntp-client start
# /etc/init.d/ntpd start

8.  Accelerated graphics drivers

Overview

The TrimSlice has a graphic chip that needs a binary driver provided by Nvidia for accelerated graphics. Those can be found on the overlay below.

Tegra Overlay

I've created an overlay for providing ebuilds for installing the accelerated graphics drivers and libraries that are available on the Nvidia L4T.

The overlay is available in the official gentoo overlays repository: http://git.overlays.gentoo.org/gitweb/?p=proj/tegra.git;a=summary.

Please check the documentation about using overlays: http://www.gentoo.org/proj/en/overlays/userguide.xml.

Emerging the accelerated graphics driver

Once you've added the overlay to your list of overlays, you can emerge the drivers:

Code Listing 8.1: Emerging the accelerated graphics driver

# emerge -v tegra-drivers

9.  References

You may find more documentation about the device itself and Linux-related at the following links:

10.  Thanks

  • trimslice.com for providing me a TrimSlice devkit to document and support Gentoo on it
  • Siarhei Siamashka (ssvb) for giving helpful hints



Print

Page updated September 3, 2011

Summary: This guide shows you how to install Gentoo on the TrimSlice.

Raúl Porcel
Author

Donate to support our development efforts.

Copyright 2001-2014 Gentoo Foundation, Inc. Questions, Comments? Contact us.