Creating a custom FreeBSD build for Raspberry Pi

The default FreeBSD kernel for Raspberry Pi can be found here in the FreeBSD source browser.  It's everything you need to boot FreeBSD on a Pi, and includes GPIO support.  However, the Pi is a nice small computer, so it's likely that you'll want it to include options such as Wifi, and pf.  In my case, I wanted IPSEC and support for USB Serial via uftdi.

In order to add drivers to the kernel, it's useful to have a list of the drivers that can be added.  That exists here.  The man pages, are a useful place to look up what a specific driver does, what hardware it supports, etc.

I added this stuff.

# WLAN required for wireless
device		wlan
device		wlan_wep
device		wlan_ccmp
device		wlan_tkip

# USB wireless support
device		ehci
device		uhci
device		ohci
device		wlan_amrr
device 		firmware

device		urtw
device		zyd
device		ural
device		upgt
device		uath
device		run
device		rum

# USB ethernet support
device		smcphy
device		mii
device		smsc

# USB serial 
# device uftdi

#proc filesystem
options 	PROCFS			#Process filesystem (requires PSEUDOFS)
options 	PSEUDOFS		#Pseudo-filesystem framework

#pf
device		pf

# IPsec interface.
device		enc

I also renamed my kernel configuration

ident		RPI-B-WIFI

The kernel options I added give me:

  • WLAN support
  • All the USB Wifi drivers
  • pf, the packet filter
  • the /proc filesystem
  • the enc device, for IPSEC
  • uftdi

I copied this kernel configuration (name RPI-B-WIFI) to the right spot on my local source tree

cp RPI-B-WIFI src/FreeBSD/head/sys/arm/conf/

Then I used the freebsd-arm-tools to create a 4GB disk image, with this kernel, a small swap, and the full ports tree:

sh build-arm-image.sh -s4 -u -p -mtom@khubla.com -w512 -kRPI-B-WIFI

12 Responses to "Creating a custom FreeBSD build for Raspberry Pi"

  • Eric
    May 24, 2013 - 7:39 am Reply

    Could you share the image if possible?

  • brahmann
    July 24, 2013 - 12:26 am Reply

    Hey!
    trying to build img,
    this error stops
    cp …..head/sys/RPI-B/bcm2835-rpi-b.dtb: No such file or directory

    what need to do with it?
    thx for any answer,
    head revision 253591

    • brahmann
      July 24, 2013 - 12:32 am Reply

      but i find that it`s now called rpi.dtb at the same place, now will try to build with change script build-arm-image.sh

  • brahmann
    July 24, 2013 - 5:37 am Reply

    yep, all done ) with this edit of build-arm-image.sh
    now bcm2835-rpi-b.dtb in script need to be replaced by rpi.dtb , they just compiled all in one rpi.dtb 🙂
    thanks for base script 🙂

    root@avalon:/root # ipfw show
    65535 442 50698 allow ip from any to any
    root@avalon:/root # mount
    /dev/mmcsd0s2a on / (ufs, local, noatime, journaled soft-updates, nfsv4acls)
    devfs on /dev (devfs, local)
    root@avalon:/root # cat /etc/fstab
    /dev/mmcsd0s2a / ufs rw,noatime 1 1
    /dev/mmcsd0s2b none swap sw 0 0
    root@avalon:/root # uname -a
    FreeBSD avalon 10.0-CURRENT FreeBSD 10.0-CURRENT #2 r253591M: Wed Jul 24 10:39:02 EEST 2013 root@:/usr/tmp/newbuildraspbery/obj/arm.armv6/usr/tmp/newbuildraspbery/head/sys/RPI-B arm
    root@avalon:/root #

    – something top cut ————-

    last pid: 819; load averages: 0.13, 0.17, 0.12 up 0+00:09:07 11:30:10
    15 processes: 1 running, 14 sleeping
    CPU: 0.4% user, 0.0% nice, 1.6% system, 0.4% interrupt, 97.7% idle
    Mem: 9236K Active, 10M Inact, 27M Wired, 19M Buf, 416M Free
    Swap: 512M Total, 512M Free

  • alexchen
    October 2, 2013 - 10:37 pm Reply

    I first use freebsd on raspberry pi, now I have a question about use wifi RTL8188CUS under freebsd,I can not find the device wlan when use “ifconfig -a”, how should I do? Thank you

    • tom@khubla.com
      October 4, 2013 - 7:43 pm Reply

      What’s in your dmesg?

  • Ruben
    March 6, 2016 - 5:34 pm Reply

    I’m installing SNORT on Raspberry PI 2 and receive a “Bus Error” when I start the application …. any ideas?

    Thanks

    Ruben

Leave a Reply