FreeBSD on Raspberry Pi: baby steps

May 21, 2012 — 10 Comments

Thanks to Robert Watson I got my hands on brand new raspberry pi device (model B) and now trying to get FreeBSD running on it. That turned out to be non-trivial task. For one – there is no way to netboot the board. At least I failed to find it. It seems that initial Linux bring-up was done on evaluation modules with proper bootloader, JTAG support and whatnot and for public use limited boot loader was released. So instead porting FreeBSD on it I face the task of porting U-Boot. Which is not something entirely impossible.

CPU support is already there. USB ethernet used in R-Pi is very similar to the one that is used on PandaBoard. So the major task is to add DWT OTG driver to U-Boot. But we’ll do it step by step.

Step 1: Boot sequence.

Stock boot loader consists of three binary blobs: bootcode.bin, loader.bin, start.elf. I didn’t find exact description of boot process but what I figured so far: they’re not ARM binaries, they’re ran on GPU. start.elf is responsible for splitting memory between GPU and ARM core. There several versions of it, the only difference is amount of memory allocated for GPU. Details of the GPU part of the boot process are not essential. What is essential is that all these blobs are there to fetch kernel.img from boot partition, place it at physical address 0x00000000 and pass control to this address. The rest is up to instructions in the kernel.img file.

Step 2: Hello world from U-Boot.

After some hacking I finally got U-Boot printing “PI-BOOT” from arch_cpu_init. And ofter that it hangs somewhere in serial ports init function. Fun, fun, fun. Git repo: (rpi branch).

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- raspberry_pi_config
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

Looks like boot loader does not like overwriting kernel.img so I created small script that just creates boot partition from scratch: I use it on linux and there are some hardcoded values but it should give you the general idea of what needs to be done for deployment.

More steps to follow.



10 responses to FreeBSD on Raspberry Pi: baby steps

  1. Great post and great work! However, I cloned your repo and built a u-boot and tested it on my pi, but all I got was some garbage on the serial line. The serial console output works fine if boot one of the linux kernels found on the net. Seems like I have som debugging to do…

    A RPi u-boot would be nice to have since it will make kernel testing, debugging and deployment easier. But as the NIC is on USB one has to bring up the USB stack first.

  2. Do you have model A or model B? Try to change CONFIG_SYS_NS16550_CLK include/configs/raspberry_pi.h
    Try 500000000 or 250000000. From datasheet I got the impression that initial frequency is 250000000, but turned out the correct value is as twice as big.

  3. I’m using Ubuntu 12.04 . Strictly following what you posted here.

    $ git clone
    $ cd u-boot-pi/
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- raspberry_pi_config
    make: *** No rule to make target `raspberry_pi_config’. Stop.
    make: *** [raspberry_pi_config] Error 1

    2) It seems the current u-boot doesn’t afford a support for raspberry pi, as I couldn’t find anything related to raspberry pi under u-boot/include/configs/ .

    How did you successfully build u-boot for raspberry_pi then???


    • The code is in rpi branch.

      Try following sequence:

      $ git clone
      $ cd u-boot-pi/
      $ git checkout rpi
      $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- rpi_b_config

      • Hi, gonzo, thank you very much… It works now
        I think “git checkout rpi” can be ignored, since here on my computer, it shows

        $ git checkout rpi
        Already on ‘rpi’

        BTW, are you maintaining u-boot ? why not integrate your u-boot-rpi into current u-boot?

        Thanks …

  4. And yes, as you mentioned, even if I can do
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- rpi_b_config
    no “u-boot.img” has been produced.
    How to generate this u-boot.img? I think u-boot.img is a must for booting Raspberry Pi, right?


  5. So has there been any further progress with this project?
    I also wonder if it is possible to compile on the pi its self rather then using cross compiling tools?

Trackbacks and Pingbacks:

  1. Raspberry Piの資料リンク集 « nanoblog - September 9, 2012

    […] Raspberry-Pi-Schematics-R1.0.pdf Raspberry PiでFreeBSDを動作させるためのU-Boot FreeBSD on Raspberry Pi: baby steps ≪ FreeBSD developer’s notebook U-Boot for Raspberry Pi, step 2 ≪ FreeBSD developer’s notebook U-Boot for Raspberry Pi, […]

  2. 有没有哪个玩家给树莓派装了freebsd系统,有下载链接么? - 树莓派 - 开发者第1052171个问答 - October 2, 2013

    […] 全部需要自制 回复: 嗯 研究研究 回复: 可以看看: 回复: 真的有人在研究这个啊 回复: 首先同步 HEAD(-CURRENT) […]

Leave a Reply

Text formatting is available via select HTML. <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>