freebsd/arm on a raspberry pi

1,181 views
Skip to first unread message

Dave Cheney

unread,
Dec 1, 2012, 6:37:43 AM12/1/12
to golang-nuts
Hello,

This evening I managed to get Go tip running on freebsd/arm. Thanks to
the sterling work of Minux Go was able to build to the point that I
can run godoc.

# uname -a
FreeBSD raspberry-pi 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r243694M:
Thu Nov 29 19:52:08 PST 2012
root@bsdbox:/src/FreeBSD/obj/arm.armv6/src/FreeBSD/head/sys/RPI-B arm
# go version
go version devel
# go run ~/src/hellofreebsd.go
Hello, 世界

The pi isn't the best platform to develop on, it doesn't have a decent
console, and my original model B only has 240 mb of ram free for the
operating system, which really isn't enough. Several packages consume
over 100mb of ram when compiling (net, I'm looking at you) and linking
most of the final executables easily consumes 100mb and peaks closer
to 150mb. This is virtually all the free memory on a 240mb system, and
generally tends to crash the os.

@minux, I compiled with cgo disabled as I felt it saved memory,
certainly when linking. The few cgo enabled builds that did produce a
binary, they all crashed :(

The FreeBSD build I am using is very unstable, so until FreeBSD-10
gets closed to shipping, progress will be slow.

If you're interested in the recipe or more details, please contact me off list.

Cheers

Dave

minux

unread,
Dec 2, 2012, 6:06:26 PM12/2/12
to Dave Cheney, golang-nuts
This is really encouraging news. I believe you're the second person to have
Go working on FreeBSD/ARM. congratulations!

On Sat, Dec 1, 2012 at 7:37 PM, Dave Cheney <da...@cheney.net> wrote:
This evening I managed to get Go tip running on freebsd/arm. Thanks to
the sterling work of Minux Go was able to build to the point that I
can run godoc.

# uname -a
FreeBSD raspberry-pi 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r243694M:
Thu Nov 29 19:52:08 PST 2012
root@bsdbox:/src/FreeBSD/obj/arm.armv6/src/FreeBSD/head/sys/RPI-B  arm
# go version
go version devel
# go run ~/src/hellofreebsd.go
Hello, 世界

The pi isn't the best platform to develop on, it doesn't have a decent
console, and my original model B only has 240 mb of ram free for the
operating system, which really isn't enough. Several packages consume
over 100mb of ram when compiling (net, I'm looking at you) and linking
most of the final executables easily consumes 100mb and peaks closer
to 150mb. This is virtually all the free memory on a 240mb system, and
generally tends to crash the os.
the general advice is to have at least 512MiB memory if you want to complete
all.bash.
For me I hacked qemu and freebsd kernel GUMSTIX-QEMU config to have
512MiB memory so that I can compile all the packages and run all the tests.

@minux, I compiled with cgo disabled as I felt it saved memory,
certainly when linking. The few cgo enabled builds that did produce a
binary, they all crashed :(
I'd like to know more about the crash.

The FreeBSD build I am using is very unstable, so until FreeBSD-10
gets closed to shipping, progress will be slow.

If you're interested in the recipe or more details, please contact me off list.
Just curious, are you planing to write a blog post about this?
or better, we can edit GoArm wiki entry to include info. about Go on FreeBSD/ARM. 

Note: although I used GUMSTIX kernel, I hacked qemu to provide LDREXD/STREXD
instructions which only appear on ARMv6. At present, Go on FreeBSD/ARM only
supports ARMv6 or ARMv7 hosts (the new GOARM detection code works really well,
so you don't need to bother setting correct GOARM environment variable).

Dave Cheney

unread,
Dec 2, 2012, 6:31:00 PM12/2/12
to minux, golang-nuts
On Mon, Dec 3, 2012 at 10:06 AM, minux <minu...@gmail.com> wrote:
> This is really encouraging news. I believe you're the second person to have
> Go working on FreeBSD/ARM. congratulations!

Thank you, but you did all the work, I just pulled the bits together.

> the general advice is to have at least 512MiB memory if you want to complete
> all.bash.
> For me I hacked qemu and freebsd kernel GUMSTIX-QEMU config to have
> 512MiB memory so that I can compile all the packages and run all the tests.

au.element14.com is sold out of 512mb Pi's :(

> I'd like to know more about the crash.

I will try to generate some more useful debugging information. Sadly
the image I used had gdb 6.x and no /usr/ports so gdb wasn't available
to me.

> Just curious, are you planing to write a blog post about this?
> or better, we can edit GoArm wiki entry to include info. about Go on
> FreeBSD/ARM.

The core problem (compounded by the secondary probably of not having
the right TTL to USB jtag cable) is the freebsd support for the pi is
under heavy flux, even the build and compile sequence is under heavy
revision, so it is a little like chasing a runaway train at the
moment. Once the Pi support stabilises to something repeatable, i'll
certainly be blogging more about.

> Note: although I used GUMSTIX kernel, I hacked qemu to provide LDREXD/STREXD
> instructions which only appear on ARMv6. At present, Go on FreeBSD/ARM only
> supports ARMv6 or ARMv7 hosts (the new GOARM detection code works really
> well,
> so you don't need to bother setting correct GOARM environment variable).

Yes, that worked brilliantly.

Dorival Pedroso

unread,
Dec 3, 2012, 6:30:12 PM12/3/12
to golan...@googlegroups.com, minux
hi dave, i've got a spare 512mb Pi and am happy to donate (especially within australia... ;-). cheers. dorival (in brisbane)

minux

unread,
Dec 23, 2012, 1:27:39 PM12/23/12
to Dave Cheney, golang-nuts
Hi Dave,
  any updates on this topic?

Dave Cheney

unread,
Dec 23, 2012, 4:35:10 PM12/23/12
to minux, golang-nuts
'fraid not, still waiting on the usb jtag serial cable for the Pi and
a more stable freebsd image.

Dave Cheney

unread,
Dec 28, 2012, 9:42:52 PM12/28/12
to minux, golang-nuts
Luckily things have improved. The FreeBSD folks have improved the
stability on the raspberry pi 512mb. Using the
freebsd-pi-clang-20121228.img.gz below, the platform stability has
improved significantly and I can execute ./make.bash without incident.

http://www.peach.ne.jp/archives/rpi/

Please contact me off list if you are interested in testing, the
process is still a bit ropey.

Cheers

Dave

Dave Cheney

unread,
Dec 31, 2012, 5:44:52 AM12/31/12
to minux, golang-nuts
Success!

ALL TESTS PASSED

---
Installed Go for freebsd/arm in /root/go
Installed commands in /root/go/bin
[root@raspberry-pi ~/go/src]# hg id
88ae367d61aa+ tip

You need to apply CLs 7037043 and 7031044. There is no cgo, and no
floating point support available in the image that I am testing with.

Cheers

Dave

minux

unread,
Jan 1, 2013, 3:42:42 AM1/1/13
to Dave Cheney, golang-nuts

On Mon, Dec 31, 2012 at 6:44 PM, Dave Cheney <da...@cheney.net> wrote:
Success!

ALL TESTS PASSED
This is really exciting news for new year! thanks.

happy new year. 

Dave Cheney

unread,
Jan 1, 2013, 8:38:13 PM1/1/13
to minux, golang-nuts
You deserve all the credit, all I did was download some code and run it.

[root@raspberry-pi ~]# go version
go version devel +d8ad9cc047e1 Tue Jan 01 21:47:42 2013 +1100 freebsd/arm
[root@raspberry-pi ~]# go tool dist env
GOROOT="/root/go"
GOBIN="/root/go/bin"
GOARCH="arm"
GOOS="freebsd"
GOHOSTARCH="arm"
GOHOSTOS="freebsd"
GOTOOLDIR="/root/go/pkg/tool/freebsd_arm"
GOCHAR="5"
GOARM="5"
[root@raspberry-pi ~]# go env
GOARCH="arm"
GOBIN=""
GOCHAR="5"
GOEXE=""
GOGCCFLAGS="-g -O2 -fPIC -marm"
GOHOSTARCH="arm"
GOHOSTOS="freebsd"
GOOS="freebsd"
GOPATH="/root"
GOROOT="/root/go"
GOTOOLDIR="/root/go/pkg/tool/freebsd_arm"
CGO_ENABLED="0"

minux

unread,
Jan 2, 2013, 2:34:40 AM1/2/13
to Dave Cheney, golang-nuts
I still need to thank you for trying it and help identifying and fixing the cacheflush
bug (note for further Go porters, when you are porting Go on an emulated system,
please double check the implementation of runtime.cacheflush, as the emulator
might not emulate the effects of icache well).

On Wed, Jan 2, 2013 at 9:38 AM, Dave Cheney <da...@cheney.net> wrote:
[root@raspberry-pi ~]# go version
go version devel +d8ad9cc047e1 Tue Jan 01 21:47:42 2013 +1100 freebsd/arm
[root@raspberry-pi ~]# go tool dist env
GOROOT="/root/go"
GOBIN="/root/go/bin"
GOARCH="arm"
GOOS="freebsd"
GOHOSTARCH="arm"
GOHOSTOS="freebsd"
GOTOOLDIR="/root/go/pkg/tool/freebsd_arm"
GOCHAR="5"
GOARM="5"
I'd expect GOARM=6 on Pi, are you setting GOARM=5 here?

Dave Cheney

unread,
Jan 2, 2013, 2:46:42 AM1/2/13
to minux, golang-nuts
> I'd expect GOARM=6 on Pi, are you setting GOARM=5 here?

No, this is the auto detection working. This kernel image is missing
"options vfp" so does not support the co processor. I tried a build
with GOARM=6 but hit a illegal instruction trap, which I assume (but
didn't investigate) was because the kernel doesn't support vfp.
Reply all
Reply to author
Forward
0 new messages