FreeBSD on Beagle Bone Black (with X11)

X11 clients on the Beagle Bone Black .. that’s X11 over the network, with the X Server elsewhere. No display as yet. The FreeBSD wiki notes that there’s no (mini) HDMI driver yet. So I built some X11 programs, xauth(1) and xmessage(1), and installed them on the Bone. Since I bought a blue case for the Bone, and it is the smallest computer in the house (discounting phones .. let’s call it the smallest hackable computer in the house) the kids decided to call it smurf. Here’s a screenshot of poudriere’s text console as it builds packages.

Poudriere build console

Poudriere build console

Timestamps on the left are since the start of the overall build, so after 20 minutes and 11 seconds I had an xmessage(1) package built. Building that package only took (timestamp in the middle) 1 minute and 41 seconds, with the time preceding that all spent in building dependencies, like X Athena Widgets. Woo! Rock the pre-Qt dancefloor.

Since smurf pulls packages from my (cross-)build machine, all I needed to to was pkg install xauth xmessage to install everything, and that leads to screenshots like this:

Screenshot with xmessage(1)

XMessage running on the Beagle Bone Black

I’d show a screenshot with Qt5 designer, too (cross-compiling all of Qt5 took a little over a day, with 16 hours of that on qt5-webkit), but that mostly shows it dumping core as it fails to find a system- or user-dbus. Once I have that sorted, I’ll have a nice little machine on which it’s totally pointless to run Qt apps, but I will finally have an excuse to do a little QML and C++ to write a Qt5, ARMv6-FreeBSD, Beagle Bone Black user LED application — so’s to rock the house with four blinkin’ LEDs.

FreeBSD on Beagle Bone Black (easy as pie)

For a long time, my Beagle Bone Black  sat on my desk, gathering dust. Recently I decided I would give it a purpose: as a replacement for the crappy DHCP server and DNS on my home router (it’s a Huawei g655d, and it has poor wireless range, a lousy interface, and wonky internal DNS). I ran an update on the Bone, which promptly downloaded a whole bunch of packages from the angstrom distribution. Over plain unauthenticated http. With, as far as I could see, no further checksumming or anything. Bad doggy.

Resigned to replacing the on-board distro anyway, I decided I would try FreeBSD, since that’s my OS of choice — if it didn’t work out, OpenSUSE would do.

Anyway. I wouldn’t be writing this if there weren’t a whole bunch of giants on whose shoulders I could stand, since actually, the whole process was deceptively simple and well-documented.

Hardware Setup: Here’s a picture of my Beagle Bone, on an old DVD-case.

Beagle Bone Black

Beagle Bone Black on FreeBSD

I started from the FreeBSD Beagle Bone wiki page. I power the Bone over USB from a powered hub. There’s a Olimex 3-pin serial cable attached. I spent a frustrating hour with this until I read somewhere that sometimes the TX and RX wires are reversed — so I swapped red and green and voila! You can see that in the picture.

Here’s part of the boot messages:

KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2015 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 10.2-STABLE #0 r287149: Thu Aug 27 06:11:58 UTC 2015
root@releng1.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/BEAGLEBONE arm
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
CPU: Cortex A8-r3 rev 2 (Cortex-A core)
Supported features: ARM_ISA THUMB2 JAZELLE THUMBEE ARMv4 Security_Ext
WB disabled EABT branch prediction enabled
LoUU:2 LoC:3 LoUIS:1
Cache level 1:
32KB/64B 4-way data cache WT WB Read-Alloc
32KB/64B 4-way instruction cache Read-Alloc
Cache level 2:
256KB/64B 8-way unified cache WT WB Read-Alloc Write-Alloc
real memory = 536870912 (512 MB)

The FreeBSD image for Beagle Bone expands to fill the SD card, so I have a nice 8GB drive with a basic FreeBSD installation — hardly any different from when I create a fresh FreeBSD VM in VirtualBox.

Software Setup: then I tried to compile something. There are no binary packages generally available for ARM targets from FreeBSD, but you can compile everything from FreeBSD ports, no problem. Except after about 40 minutes waiting on the very first port that needs to be done, pkg(8), I was about to give up on this path.

At that point, Ralf Nolden asked something that totally turned this little project around: why don’t you use poudriere for cross-compiling?

I’ll point to Randy Westlund for a simple and straightforward recipe. No need to repeat it here, since the only difference between my setup and his are a few minor filesystem path changes. Randy points at Doug and there’s more pointers from there if you want to follow the historical references. Giants.

Suffice to say that poudriere is awesome.

Really. Follow Randy’s “Installing the Tools” steps, take the required modifications
to poudriere.conf from Doug, then continue with “Build the Environment”.

On an i7 860 @2.8GHz, this took less than an hour, if I recall correctly. Maybe an hour and a half, which gave me time to read the documentation on other bits and pieces.

I picked a few packages — isc-dhcp42-server and unbound — and kicked off a poudriere build. I turned off all the DOCS and EXAMPLES options, since I can get those on the build host and they don’t need to be on the Bone. From the extensive logging poudriere produces, I can see that it took a little over an hour and a half. For an overnight build, that’s cheap.

And then the moment of truth:

root@beaglebone:/usr # pkg install isc-dhcp41-server
Updating bbbbuild repository catalogue...
bbbbuild repository is up-to-date.
All repositories are up-to-date.
Updating database digests format: 100%
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
isc-dhcp41-server: 4.1.e_9,2

The process will require 2 MiB more space.
473 KiB to be downloaded.

So there you go! FreeBSD and ARMv6 packaging is as easy as pie. Now the Bone is doing something useful, I can start using poudriere for silly things,
like building Qt5 so I can write a Qt application to control the user LEDs on the board.