This instruction is no longer correct. New version is here
Took some time but it seems we’re there too 🙂
Alexander Rybalko, who works on USB drivers for the platform got remote telnet shell to the device: http://pastebin.com/6NqQLWD2
Having fixed serial console for userland applications (two lines change) and after some tweaking of SDHCI driver I got access to multiuser shell too: multiuser.txt
Still not usable for putting together distros but stable enough for those who are willing to get their hands dirty with kernel side.
Here is short how to on getting FreeBSD boot on Raspberry Pi:
Get sources:
git clone git://github.com/gonzoua/freebsd-pi.git
cd freebsd-pi
git checkout rpi
Fetch u-boot files from here: freebsd-pi-uboot-20120806-sd.tar.gz.
Build sources and create SD card image with script like this:
#!/bin/sh
set -e
export TARGET_ARCH=arm
export SRCROOT=/usr/home/gonzo/Sources/freebsd-pi
export MAKEOBJDIRPREFIX=/usr/home/gonzo/Sources/obj
export KERNCONF=RPI-B
KERNEL_BIN=`realpath $MAKEOBJDIRPREFIX`/arm.arm/`realpath $SRCROOT`/sys/$KERNCONF/kernel.bin
make -C $SRCROOT kernel-toolchain
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes buildkernel
make -C $SRCROOT TARGET_CPUTYPE=armv6 MALLOC_PRODUCTION=yes buildworld
IMG=bsd-pi.img
rm -f $IMG
dd if=/dev/zero of=$IMG bs=128M count=8
MDFILE=`mdconfig -a -f bsd-pi.img`
gpart create -s MBR ${MDFILE}
gpart add -s 32m -t '!12' ${MDFILE}
gpart add -s 896m -t '!12' ${MDFILE}
gpart set -a active -i 1 ${MDFILE}
newfs_msdos -L boot -F 16 /dev/${MDFILE}s1
newfs /dev/${MDFILE}s2
mount_msdosfs /dev/${MDFILE}s1 /mnt
tar -x -v -z -C /mnt -f freebsd-uboot-sd.tar.gz
cp $KERNEL_BIN /mnt
umount /mnt
mount /dev/${MDFILE}s2 /mnt
make -C $SRCROOT DESTDIR=/mnt installworld
make -C $SRCROOT DESTDIR=/mnt distribution
# Minimal config
echo 'hostname="freebsd-pi"' > /mnt/etc/rc.conf
echo '/dev/mmcsd0s2 / ufs rw 1 1' > /mnt/etc/fstab
umount /mnt
mdconfig -d -u $MDFILE
dd image to SD card, insert it to Raspberry Pi and check serial port for some output
There is also U-Boot configuration that uses dhcp/tftp method by default freebsd-pi-uboot-20120806-netboot.tar.gz. It’s more suitable for kernel hacking but requires environment setup.
Hello There!!
Thans a lot for the imformation!!
As soon as I fix some mess I’ve made, I’ll try this out!
Kind Regards!!
Thank you for great information.
Now I’m creating image file and I will test this image tomorrow with my r-pi.
By the way, I have below error in script.
x boot.scr: Can’t set user=1001/group=0 for boot.scr
x bootcode.bin: Can’t set user=1001/group=0 for bootcode.bin
x cmdline.txt: Can’t set user=1001/group=0 for cmdline.txt
x config.txt: Can’t set user=1001/group=0 for config.txt
x loader.bin: Can’t set user=1001/group=0 for loader.bin
x start.elf: Can’t set user=1001/group=0 for start.elf
x u-boot.bin: Can’t set user=1001/group=0 for u-boot.bin
x uEnv.txt: Can’t set user=1001/group=0 for uEnv.txt
tar: Error exit delayed from previous errors.
So, I change tar line as below(added –uname root)
[NEW]
tar -x -v -z –uname root -C /mnt -f freebsd-uboot-sd.tar.gz
Yours
Yoshiro MIHIRA
Thanks, I’ll modify script.
Hi,
What should the tar command look like?
tar doesn’t take -x and -uname together.
tar xvz –uname root
Thanks!
What is next roadmap? make it stable?
Next milestone – get USB working and improve stability and performace. At the moment SD card driver uses PIO mode so it’s not really fast.
Cool! Any plan for ARM ports?
at least we can use it for web or ftp server 😀
I got USB 3.3V serial adapter(TTL-232R-3V3 FTDI USB). And I can login
FreeBSD-pi with serial console !!
I would like to use USB interface with FreeBSD-pi(network(LAN and wifi) and uaudio). If you commit any updated source please let us to know. I will debug.
Just wanted to feed back, major thanks for your work.
I can report that following the above instructions I have a RPi booted with 10-Current. Had a bit of an issue building on 9.0-Release due to tar not supporting –uname out of the box, but solved that just by extracting, reowning and recompressing the file to work with the script.
One comment though is that the serial interface in uboot is set to 115200, but the first tty is set to 9600… Adjusting the tty to 115200 was easy enough and let me get onto the device!
Thanks again! Looking forward to some usb-age and network-age.
Hi, I seem to be hitting the same issue where tar is not taking -uname and -x at the same time. How did you workaround the problem?
Great ! Any chance to have OpenBSD ?
I don’t know the state of affairs in OpenBSD but if they have support for armv6 (which seems to be the case) – I see no major road blocks for making a port.
What about hard floting points?
VFP/NEON support is in HEAD so I guess there will be no problem with it
Hi, great job,
are there any possibility to merge port files and FTD with 9-RELEASE?
I was trying to do this using files from your git-src but I think there is to much changes made.
my tree is based on projects/armv6 bracnh that has been merged to HEAD recently. I’m not sure how much it would take to get these changes to stable/9.
http://web.archiveorange.com/archive/v/jLTVccKByCJ9JA3o0lA7
I am getting such errors.
what can I do to fix them?
% uname -a
FreeBSD xxxxxxxx.com 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r239692: Sat Aug 25 16:34:59 PDT 2012 root@xxxxxxxx.com:/usr/obj/usr/src/stable/9/sys/GENERIC amd64
Yes. It’s known issue with later version of FreeBSD, both CURRENT and 9.1. I started merging bits back to subversion, so you can try building latest HEAD from svn with this patch: http://people.freebsd.org/~gonzo/arm/rpi/rpi-head-20120825.diff
thanks for getting back so quickly.
After applying the patch, I am getting:
————————————————————–
>>> stage 1: configuring the kernel
————————————————————–
cd /usr/home/stdp/freebsd-pi/sys/arm/conf; PATH=/usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/tmp/legacy/usr/sbin:/usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/tmp/legacy/usr/bin:/usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/tmp/legacy/usr/games:/usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/tmp/usr/sbin:/usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/tmp/usr/bin:/usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin config -d /usr/home/stdp/obj/arm.arm/usr/home/stdp/freebsd-pi/sys/RPI-B /usr/home/stdp/freebsd-pi/sys/arm/conf/RPI-B
config: /usr/home/stdp/freebsd-pi/sys/arm/conf/RPI-B:21: only one machine directive is allowed
*** [buildkernel] Error code 1
Stop in /usr/home/stdp/freebsd-pi.
*** [buildkernel] Error code 1
Stop in /usr/home/stdp/freebsd-pi.
The build script should be changed as well. Use somethin like this:
#!/bin/sh
set -e
export TARGET=arm
export TARGET_ARCH=armv6
export SRCROOT=/src/FreeBSD/head
export MAKEOBJDIRPREFIX=/src/FreeBSD/obj
export KERNCONF=RPI-B
make -C $SRCROOT kernel-toolchain
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes buildkernel
make -C $SRCROOT MALLOC_PRODUCTION=yes buildworld
I haven’t checked buildworld yet, though
Thanks but I am still getting the same error.
Appreciate your help.
could you post whole script output somewhere? Thanks
Hi there, sorry for the delay. Now I have decided to run FreeBSD on my pi this long weekend 🙂
I just got the new git tree and tried to apply patch http://people.freebsd.org/~gonzo/arm/rpi/rpi-head-20120825.diff – but many of the changes seem to have already been applied. i.e. its not patching cleanly.
Also, looking at the build script changes you just mentioned, SRCROOT=/src/FreeBSD/head – I do not have such dir anywhere. SRCROOT should point to the git tree location??
Thanks for the continuous help!
should I get latest base from freebsd.org and apply the patch you mentioned?
i.e. http://svn.freebsd.org/base/head/
patch: http://people.freebsd.org/~gonzo/arm/rpi/rpi-head-20120825.diff
I am doing that now, will let you know how that goes.
Actually, working bits of RPI code is in HEAD. So you don’t need whole this patch. Just bits of it. Try first vanilla head to see if serial/framebuffer works for you. Meanwhile I’ll prepare new patch.
Yeah, so with latest head, the patch doesn’t apply cleanly and buildkernel fails.
thanks.
My bad, latest kernel builds with the patch but the build script fails just on the start:
“Makefile.inc1”, line 147: Unknown target armv6:arm.
*** [kernel-toolchain] Error code 1
Stop in /usr/home/hari/git_stuff/freebsd-pi.
For git tree use TARGET=arm TARGET_ARCH=arm, for svn – TARGET=arm TARGET_ARCH=armv6
Thanks for the quick reply 🙂
I am afraid that I do not understand the difference between these 2 you mentioned.
Don’t we just have to play with the git tree?
I started merging Raspberry Pi stuff to subversion. At the moment you can build bootable RPI-B kernel from http://svn.freebsd.org/base/head. No SD card support though.
git tree is based on older projects/armv6 tree and will be removed after I got all the changes merged back to HEAD. But for now you can use it for experiments. Just use this script without any patches applied.
Hi,
Btw is there any timeline for FreeBSD Raspberry Pi development? Are you planning to release the .img here? since no one doing so for FreeBSD arm ports
No, there is no proper timeline. I work on it in my free time, so development schedule is somewhat hectic
Very cool. I have no u-boot experience and I am just beginning to explore it. I would like to dhcp/tftp boot the rpi, with a linux kernel though. I was wondering, if you know, would booting a linux kernel be as simple as substituting the linux kernel for a bsd kernel you are using in this example. Thanks, I’m looking at as many u-boot resources as I can find but I’m still a little lost.
You should ask this on a Linux RaspberryPi forum, since Linux and FreeBSD booting are really quite different.
Continuing http://kernelnomicon.org/?p=164#comment-918
Here is how my build script looks:
#!/bin/sh
set -e
export TARGET=arm
export TARGET_ARCH=arm
export SRCROOT=/home/hari/git_stuff/freebsd-pi
export MAKEOBJDIRPREFIX=/usr/home/hari/obj
export KERNCONF=RPI-B
make -C $SRCROOT kernel-toolchain
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes buildkernel
make -C $SRCROOT MALLOC_PRODUCTION=yes buildworld
IMG=bsd-pi.img
rm -f $IMG
dd if=/dev/zero of=$IMG bs=128M count=8
MDFILE=`mdconfig -a -f bsd-pi.img`
gpart create -s MBR ${MDFILE}
gpart add -s 32m -t ‘!12’ ${MDFILE}
gpart add -s 896m -t ‘!12’ ${MDFILE}
gpart set -a active -i 1 ${MDFILE}
newfs_msdos -L boot -F 16 /dev/${MDFILE}s1
newfs /dev/${MDFILE}s2
mount_msdosfs /dev/${MDFILE}s1 /mnt
tar -x -v -z -C /mnt -f freebsd-pi-uboot-20120806-sd.tar.gz
cp $KERNEL_BIN /mnt
umount /mnt
mount /dev/${MDFILE}s2 /mnt
make -C $SRCROOT DESTDIR=/mnt installworld
make -C $SRCROOT DESTDIR=/mnt distribution
# Minimal config
echo ‘hostname=”freebsd-pi”‘ > /mnt/etc/rc.conf
echo ‘/dev/mmcsd0s2 / ufs rw 1 1’ > /mnt/etc/fstab
umount /mnt
mdconfig -d -u $MDFILE
Just replace
make -C $SRCROOT MALLOC_PRODUCTION=yes buildworld
with
make -C $SRCROOT MALLOC_PRODUCTION=yes TARGET_CPUTYPE=armv6 buildworld
and it should work.
Also make sure you did
git checkout rpi
after git clone.No need to apply any patches for this tree
Sorry for the iterations we are going through but it still fails.
Here is what I have:
1) this is my kernel:
$ uname -a
FreeBSD xxxxx 10.0-CURRENT FreeBSD 10.0-CURRENT #3 r239996M: Sun Sep 2 01:45:39 PDT 2012 root@xxxxx:/usr/obj/usr/src/head/sys/GENERIC amd64
2) I checked out the git tree:
git clone git://github.com/gonzoua/freebsd-pi.git
cd freebsd-pi
git checkout rpi
3) here is the buildscript:
#!/bin/sh
set -e
export TARGET=arm
export TARGET_ARCH=arm
export SRCROOT=/home/hari/git_stuff/freebsd-pi
export MAKEOBJDIRPREFIX=/usr/home/hari/obj
export KERNCONF=RPI-B
make -C $SRCROOT kernel-toolchain
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes buildkernel
make -C $SRCROOT MALLOC_PRODUCTION=yes TARGET_CPUTYPE=armv6 buildworld
IMG=bsd-pi.img
rm -f $IMG
dd if=/dev/zero of=$IMG bs=128M count=8
MDFILE=`mdconfig -a -f bsd-pi.img`
gpart create -s MBR ${MDFILE}
gpart add -s 32m -t ‘!12′ ${MDFILE}
gpart add -s 896m -t ‘!12′ ${MDFILE}
gpart set -a active -i 1 ${MDFILE}
newfs_msdos -L boot -F 16 /dev/${MDFILE}s1
newfs /dev/${MDFILE}s2
mount_msdosfs /dev/${MDFILE}s1 /mnt
tar -x -v -z -C /mnt -f freebsd-pi-uboot-20120806-sd.tar.gz
cp $KERNEL_BIN /mnt
umount /mnt
mount /dev/${MDFILE}s2 /mnt
make -C $SRCROOT DESTDIR=/mnt installworld
make -C $SRCROOT DESTDIR=/mnt distribution
# Minimal config
echo ‘hostname=”freebsd-pi”‘ > /mnt/etc/rc.conf
echo ‘/dev/mmcsd0s2 / ufs rw 1 1′ > /mnt/etc/fstab
umount /mnt
mdconfig -d -u $MDFILE
4) running the script fails:
/usr/home/hari/git_stuff/freebsd-pi/lib/libc/net/nsparser.y: In function ‘_nsaddsrctomap’:
/usr/home/hari/git_stuff/freebsd-pi/lib/libc/net/nsparser.y:169: warning: implicit declaration of function ‘free’
In file included from nsparser.c:398:
/usr/home/hari/git_stuff/freebsd-pi/lib/libc/../../include/stdlib.h: At top level:
/usr/home/hari/git_stuff/freebsd-pi/lib/libc/../../include/stdlib.h:93: warning: conflicting types for ‘free’
/usr/home/hari/git_stuff/freebsd-pi/lib/libc/net/nsparser.y:169: warning: previous implicit declaration of ‘free’ was here
*** [nsparser.o] Error code 1
Stop in /usr/home/hari/git_stuff/freebsd-pi/lib/libc.
*** [lib/libc__L] Error code 1
Stop in /usr/home/hari/git_stuff/freebsd-pi.
*** [libraries] Error code 1
Stop in /usr/home/hari/git_stuff/freebsd-pi.
*** [_libraries] Error code 1
Stop in /usr/home/hari/git_stuff/freebsd-pi.
*** [buildworld] Error code 1
Stop in /usr/home/hari/git_stuff/freebsd-pi.
I keep forgetting about this issue. Sources grew incompatible with -CURRENT. Try building svn. Checkout latest head from http://svn.freebsd.org/base/head
Then apply this patch: http://people.freebsd.org/~gonzo/arm/rpi/rpi-head-20120902.diff
Use the same script but TARGET_ARCH should be armv6 and remove TARGET_CPUTYPE=armv6 from buildworld line
The rest is just the same.
Sorry about this breakage. I totally forgot about it 🙁
No problem, thanks for the continues help.
Now buildkernel is failing because it cannot find
sdhci_if.h.
Is there any ethernet support for HEAD?
I’ve had no luck with this (will post my build script below) – I should point out I don’t have serial hardware yet, so I can’t see what’s going on, but I’ve uncommented the 4 lines (sc kbdmux etc) in RPI-B for the frame buffer so I should expect to see kernel boot messages on screen (right?) – I just get the rainbow coloured screen and no activity light thereafter. (I wrote an /etc/rc.local script to mount the boot partition and write dmesg etc to it so at least I could see if it made it that far, but that doesn’t seem to be happening)
Do I absolutely have to have serial hardware connected to make it boot?
I’m building on FreeBSD 9.1 RC1 if that makes a difference, the patch you supply above seems to apply correctly with no issues and the boot partition contains my kernel.bin:
-rwxrwxrwx 1 matthewf staff 2823544 7 Sep 14:36 KERNEL.BIN
I will have another go after posting this, including a complete rebuild of everything (the kernel.bin looks sane and is ARM
/usr/obj/arm.armv6/usr/src/sys/RPI-B]# file kernel kernel.bin
kernel: ELF 32-bit LSB executable, ARM, version 1 (FreeBSD), dynamically linked (uses shared libs), not stripped
kernel.bin: data)
I couldn’t figure out if USB/Ethernet support was in HEAD, but I see Alex Rybalko’s paste bin seems to indicate he has it working?
Build script for anyone else:
#!/bin/sh
set -e
export TARGET=arm
export TARGET_ARCH=armv6
export SRCROOT=/usr/src
export MAKEOBJDIRPREFIX=/usr/obj
export KERNCONF=RPI-B
KERNEL_BIN=`realpath $MAKEOBJDIRPREFIX`/arm.armv6/`realpath $SRCROOT`/sys/$KERNCONF/kernel.bin
make -C $SRCROOT kernel-toolchain
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes buildkernel
make -C $SRCROOT MALLOC_PRODUCTION=yes buildworld
IMG=bsd-pi.img
rm -f $IMG
dd if=/dev/zero of=$IMG bs=128M count=8
MDFILE=`mdconfig -a -f bsd-pi.img`
gpart create -s MBR ${MDFILE}
gpart add -s 32m -t ‘!12’ ${MDFILE}
gpart add -s 896m -t ‘!12’ ${MDFILE}
gpart set -a active -i 1 ${MDFILE}
newfs_msdos -L boot -F 16 /dev/${MDFILE}s1
newfs /dev/${MDFILE}s2
mount_msdosfs /dev/${MDFILE}s1 /mnt
tar -x -v -z –uname root -C /mnt -f freebsd-pi-uboot-20120806-sd.tar.gz
cp $KERNEL_BIN /mnt
umount /mnt
mount /dev/${MDFILE}s2 /mnt
make -C $SRCROOT DESTDIR=/mnt installworld
make -C $SRCROOT DESTDIR=/mnt distribution
# Minimal config
echo ‘hostname=”freebsd-pi”‘ > /mnt/etc/rc.conf
echo ‘/dev/mmcsd0s2 / ufs rw 1 1’ > /mnt/etc/fstab
# this is my “write back to the boot partition” script – optional
cp /root/rc.local /mnt/etc/rc.local
umount /mnt
mdconfig -d -u $MDFILE
My latest conclusion is that u-Boot isn’t working (or I need serial hardware connected [ordered]) I’ve even tried the net boot tar.gz version – which you’d expect to DHCP and try to grab a kernel – but nothing happens.
[I’ve now updated HEAD and got the DWC OTG bits too].
Wish I could figure out what was wrong – is it possible to build a FreeBSD kernel that boots in the “normal” way without u-Boot?
i built my kernel with freebsd-current (HEAD), but the mmc/sdhci does not detected?
MMC/SD merge is work in progress, I hope to finish it today and commit tomorrow or the day after tomorrow
No work. Black display.
Raspberry model “B” 512mb.
fix?
I’m working on getting kernel compatible with new firmware. New instruction will be posted by the end of this week.
Good news. Waiting…
Tell me when it will be ready new instruction
There is one outstanding issue I have to take care of before publishing proper instruction. Unless something else pops up – it should be done in two-three days I hope.
Pacman:v- the iconic recreation character can be employed
if you experience like leaping for joy. Now that you’ve got all
those clients, losing them will not be an option. We value a spirit of
cooperation, which is seen in our ability to perform in teams and
partnerships.
Feel free to surf to my homepage … facebook infiltrator
Quality content is the main to attract thee users to pay a visit the
site, that’s what this web site is providing.
Gonzo, dude:
This comment thread is a SPAM LINK MAGNET. Please erase the last few comments, and close this thread to further comments. (Also, link to your newer Rasperberry PI how-to…)