BeagleBone

Installing Gentoo in the BeagleBone 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 familiar with the Gentoo Linux installation process, there is not much different here.

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 BeagleBone.
 * One SD card (2 GB is enough).
 * A network connection.

Overview
Before we start the installation process, we need to get/build a kernel, bootloader and X-Loader for the BeagleBone.

The BeagleBone doesn't have a NAND/flash device, so the bootloader (U-Boot) needs to be located on the SD card, along with X-Loader and the kernel.

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


 * - To download U-Boot, X-Loader and the kernel.
 * - To create a crosscompiler.
 * - To create a kernel image U-Boot can understand.
 * - To create FAT32 filesystems.

Build a crosscompiler
Build a crosscompiler:

Obtain and build U-Boot
Obtain U-Boot:

Compile U-Boot:

Obtain and build a kernel
For booting the BeagleBone we need a kernel. The vanilla kernel.org doesn't support the BeagleBone as of October 2012, for this reason we'll use a kernel provided by TI.

Obtain the kernel:

Or use the following if you are only interested in the last revision of this branch:

Obtain needed firmware:

Configure the kernel:

Run menuconfig for enable ext4 support:

Enable ext4 as built-in:

Enable devtmpfs support for newer systems:

The kernel includes CPU frequency scaling support, but by default is configured to use the userspace governor, that means that unless you have any CPU frequency scaling manager in the rootfs, the cpu will be stuck at 600MHz.

You can change the governor anytime you want, but if you are like me and prefer the ondemand governor set by default, which makes a CPU frequency scaling manager redundant, or if you prefer the performance governor which is like disabling CPU frequency scaling, you can choose the default governor in the following kernel config menu.

Set the default governor in menuconfig:

Cross-compile the kernel (replace  in the command with an appropriate number of cores on the build computer):

Depending on the gcc version used in your cross compiler, this might not work. The 3.2-staging kernel is not intended to work with gcc-5, but you can create a separate cross compiler with gcc-4. Look at the options in  for information on how to specify this. To keep this running next to your existing cross compiler, you can call it  for example and change the make command accordingly.

Also, when using gcc-4.9.4, you need one patch to prevent a build error:

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

Overview
OMAP-based systems need a special setup of the SD card to boot from it. For more information please check this link.

Formatting the SD card
The following script will format your SD card accordingly, creating two partitions. The first partition size is based on the size of the SD card itself, and it's formatted in vfat. The second partition is the free space left on the card after the first partition, and it's formatted in ext4.

Format the SD card:

Replace  in the command below with the name SD card device. When using a USB-based SD card reader, the card may show up as a device, for example.

Configure U-Boot
The default configuration of U-Boot differs a bit from our setup, we fix that by creating a file called with the following contents:

Copy U-Boot, MLO, and 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 BeagleBone.

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 2nd 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_hardf
 * CHOST: armv7a-hardfloat-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-hardfloat-linux-gnueabi stage3 for best performance, available under the releases/arm/autobuilds directory in your favorite mirror.

Optionally grab a Portage snapshot.

Extracting a stage3
Mount the second partition of the SD card and extract the stage3 you downloaded.

Mount the partition and extracting the stage3:

Extract a Portage snapshot (optional)
Extract the snapshot:

Setup fstab
Edit the file to look like this:

If they exist, remove (or comment out) the following lines since this system does not have a swap partition, CD-ROM, or floppy:

Set 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 inside the chroot, so we can set a default root password.

Generate a password:

Open the shadow file:

Replace the first line with the following line (where  is the output from the  command above):

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 to the startup of our system so we can access our BeagleBone using. Add to the startup:

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. Also, in the case of the BeagleBone, the port is ttyO0(that is a t-t-y-capitalO-zero) instead of the normal ttyS0. So this should be added to the file. Replace  with   on the ttyS0 line, and replace   with.

Finishing the installation
Let's unmount the SD card:

This is pretty much all of the installation. It is highly recommended readers of this guide read all the recommendations of the handbook.

Accessing the console (optional)
If you want to see the BeagleBone boot, connect an USB cable to the mini USB port (you should have it if you aren't powering it using an external PSU...) and load the  kernel module with the following command:

In newer kernels, the ftdi_sio module requires a different interaction:

New devices called ttyUSB0 and ttyUSB1 should show up on /dev. You should use ttyUSB1 with a terminal emulator like picocom or minicom configuring it with 115200bps 8N1

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

Keeping the clock up to date
One of the problems of the BeagleBone 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 Beaglebone installation, I'd recommend setting a date and emerging to keep the clock up-to-date. Also it's recommended to put both and  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.

Special thanks

 * http://beagleboard.org/bone for providing me a Beaglebone to document and support Gentoo on it
 * Siarhei Siamashka (ssvb) for giving helpful hints

External resources

 * BeagleBone on elinux.org