Freebsd on Raspberry Pi 2 and Golang

- FreeBSD Golang

FreeBSD is now fully supported on the Raspberry Pi2, makes it a fun small computer to experiment with BSD.

If you have a Raspberry Pi 1, you can simply install 10.2-RELEASE image.

For Raspberry Pi 2, you need 11.0-CURRENT which is the development branch, images can be found here.

dd the image as usual to a SD card, it will be auto resized at first boot. (See growfs_enable="YES") in rc.conf.

CPU frequency

To enable on demand cpu overclocking (ranging from 600 to 1000MHz), enable powerd by adding this to rc.conf.

powerd_enable="YES"
powerd_flags="-a hadp"

Production speed

FreeBSD CURRENT is the development version, some debugging tools may slow down your system.

As stated in UPDATING if you are running CURRENT:

ln -s 'abort:false,junk:false' /etc/malloc.conf

Wifi

Depending on your wifi dongle this may be different, for RealTek devices add an entry to /etc/wpa_supplicant.conf:

network={
    ssid="myssid"
    psk="mypass"
}

And this to /etc/rc.conf:

wlans_urtwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"

And this to /boot/loader.conf

legal.realtek.license_ack=1

And type service netif restart.

Installing the ports

The ports are a long list of third parties software you can install on your system, first synchronize the ports tree:

portsnap fetch
portsnap extract

It’s highly recommend you install portmaster to keep your ports updated:

cd /usr/ports/ports-mgmt/portmaster/
make install clean

To later update your ports tree and ports:

portsnap fetch update
portmaster -a

To compile and install a port simply go to its directory and run make install clean.

Keeping the sources updated (optional)

All the FreeBSD sources are available and can be used to recompile the whole system.

Subversion needs some space in /tmp to complete this task, edit /etc/fstab to grow tmpfs to at least 70M the reboot:

tmpfs /tmp tmpfs rw,mode=1777,size=70m 0 0
cd /usr/ports/security/ca_root_nss
make install clean
svnlite checkout https://svn.FreeBSD.org/base/head /usr/src

To keep it in sync later, just type:

cd /usr/src
svnlite update

Keeping your FreeBSD updated can be achieved by recompiling the system aka make world, note that this could take a long time on a Raspberry Pi but still doable (remember to use make -j 4 on RPi2).

Installing Go (optional)

If you are into Go and need a recent version, first you need to compile Go 1.4 as a bootstraper (note that you also need to install git):

cd /usr/ports/lang/go14
make install clean

Then you can compile a more recent Go, for example using /usr/local/go:

cd /usr/local
git clone https://go.googlesource.com/go
cd go/src
env TMPDIR=/var/tmp GOARM=7 GOROOT_BOOTSTRAP=/usr/local/go14 ./all.bash

Add /usr/local/go/bin to your PATH.