Mainline Linux on the Beaglebone Black

For some time I've been collecting various ARM devices to run Gentoo on. So far I have collected two Sheevaplugs, a Cubox (original version), three Nokia N900's, three Cubieboards (A20), a Samsung ARM Chromebook, Hardkernel ODROID U2, an IFC6410 and recently a Beaglebone black. I got the BeagleBone Black (BBB) mostly because I heard that the linux mainline kernel would support it as of version 3.13. Today I checked out Linux 3.13-rc7 and found out it indeed boots up! This blog post will provide you with a short guide on how to do this. It assumes previous knowledge of crossdev and a working install on the BeagleBone Black. If you don't have a Gentoo system on it yet, have a look at this guide:

You can skip the u-boot and kernel parts and take the parts from this post instead. And if you also have a working u-boot, just skip straight to the kernel part.

Setting up the cross compiler

This is the trivial part. Set up crossdev properly, and then build a compiler for the proper target:

emerge crossdev
crossdev -S -t armv7a-hardfloat-linux-gnueabi

Getting u-boot to work

The u-boot instructions are taken from the following guide. I didn't find the guide useful for anything but getting u-boot (and a part of the uEnv.txt, read on), so don't get distracted. You don't need their scripts, nor any of the patches they mention. Again, I only reference this for a part of the u-boot instructions. I also changed the instructions to work properly with our crossdev setup.

Get the u-boot source code:

git clone git://
cd u-boot/

Optionally switch to a known to be working branch:

git checkout v2013.10 -b tmp

At the point of writing, if you want to load a zImage, download and apply the following patch:

patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Finally, configure and compile u-boot.

CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make distclean
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make am335x_evm_config
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make

Building the kernel

These instructions are for Linux 3.13-rc7. They may work on later versions, but this cannot be guaranteed. I won't discuss actually getting the kernel source.

CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make omap2plus_defconfig
# menuconfig, in case you want to change stuff before getting it to boot
# initially ;-)
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make menuconfig
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make zImage dtbs -j9


Now copy over the u-boot/MLO, u-boot/u-boot.img linux/arch/arm/boot/zImage and dts/am335x-boneblack.dtb to the first partition (see the initial Gentoo BBB guide at the top of the article). And add the following uEnv.txt file to the same partition:


loadzimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${kernel_file}
loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} ${fdtfile}

mmcroot=/dev/mmcblk0p2 ro
mmcrootfstype=ext4 rootwait

mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}

uenvcmd=run loadzimage; run loadfdt; run mmcargs; bootz ${loadaddr} - ${fdtaddr}

Note that /dev/mmcblk0 is the SD card, and /dev/mmcblk1 is the eMMC.

Now it should boot! Enjoy your mainline kernel with all the latest drivers. And, of course, the ability to use grsecurity. Or just hardened-sources in Gentoo.