FreeBSD/armv6z/clang on Raspberry Pi 512MB (with U-Boot + ubldr)

Daisuke Aoyama aoyama at peach.ne.jp
Tue Jan 1 01:00:36 UTC 2013


Happy New Year!

I have updated clang RPI code based on SVN r244906.

major change is:
o always use unaligned for clang (see
http://lists.freebsd.org/pipermail/freebsd-arm/2012-December/004464.html)
o remove NO_INLINE from kernel config, add MSDOSFS since test10
o drop invalidate I-Cache, add flush BTB instead
o increase MIN_PERIOD to 200 for down clock mode stability
o workaround for broken stupid dev/mmc (should be rewritten)
o control HS mode in bcm2853_sdhci, replace bus_space handle
o add hw.bcm2835.sdhci.hs MIB (disabled by default)
o add isb/dsb/dmb and mb/rmb/wmb macro in atomic.h
o add bs_barrier, bs_vaddr operation
o hand optimaized asm routine(bcm2835_asm.S) for tc_get_timecount and SD card transfer

Above changes make over 80% faster than previous kernel by ports/benchmarks/unixbench.

Before:
----------------------------------------------------------------------------------------
Execl Throughput                                43.0       83.3       19.4
File Copy 1024 bufsize 2000 maxblocks         3960.0     1464.0        3.7
File Copy 256 bufsize 500 maxblocks           1655.0     1563.0        9.4
File Copy 4096 bufsize 8000 maxblocks         5800.0     1405.0        2.4
Pipe Throughput                              12440.0    79059.7       63.6
Pipe-based Context Switching                  4000.0     6815.1       17.0
Process Creation                               126.0      242.2       19.2
Shell Scripts (8 concurrent)                     6.0       27.9       46.5
----------------------------------------------------------------------------------------

After (depend on your SD card spec, of course):
----------------------------------------------------------------------------------------
Execl Throughput                                43.0       89.8       20.9 (1.1x)
File Copy 1024 bufsize 2000 maxblocks         3960.0     2622.0        6.6 (1.8x)
File Copy 256 bufsize 500 maxblocks           1655.0     1595.0        9.6 (1.0x)
File Copy 4096 bufsize 8000 maxblocks         5800.0     7287.0       12.6 (5.1x)
Pipe Throughput                              12440.0   101503.0       81.6 (1.3x)
Pipe-based Context Switching                  4000.0    10609.1       26.5 (1.6x)
Process Creation                               126.0      274.7       21.8 (1.1x)
Shell Scripts (8 concurrent)                     6.0       27.9       46.5 (1.0x)
----------------------------------------------------------------------------------------

Also, SD card should be set to 25MHz and 4bit respectively. (DS mode, 100Mbps = 12.5MB/s)
----------------------------------------------------------------------------------------
root at raspberry-pi:~ # dd if=/dev/mmcsd0 of=/dev/null bs=1m count=32
32+0 records in
32+0 records out
33554432 bytes transferred in 3.231259 secs (10384322 bytes/sec)
----------------------------------------------------------------------------------------


You can get the pre-build image from my archives:

http://www.peach.ne.jp/archives/rpi/
(At this time, freebsd-pi-clang-20130101.img.gz is the latest version.)

Download and decompress it, then write it to SD. This image requires SD 4GB or more.
I'm using as headless server. So, you need a serial console for seeing full boot log.
If you want the video out, please remove the line of "setconsole=comconsole" in /boot/loader.rc.
If you need to change the value on it, please mount the second partition (e.g. /dev/da0s2a).

This version includes complete source tree of r244906.
But the patch is not applied. You must apply the patch manually.

Note: first time, it takes about 2 minutes for generating the SSH keys.

Using config is here:
http://www.peach.ne.jp/archives/rpi/config/RPI-B-test11

New kernel only is here:
http://www.peach.ne.jp/archives/rpi/kernel/

Source and pacth is here:
http://www.peach.ne.jp/archives/rpi/patch/


For more, please read this:
http://lists.freebsd.org/pipermail/freebsd-arm/2012-December/004421.html
http://lists.freebsd.org/pipermail/freebsd-arm/2012-December/004331.html
http://shell.peach.ne.jp/aoyama/

----------------------------------------------------------------------
Pre-configured for:

MEM 496MB/GPU 16MB/SWAP 512MB
I/O: multi-console (primary serial)
IP address: 192.168.1.240
Default router: 192.168.1.1
DNS: 192.168.1.1
sshd: enabled
ntpdate: enabled (0.freebsd.pool.ntp.org)

User: pi
Password: raspberry
Password(root): raspberry
----------------------------------------------------------------------
First, you may need to edit pre-configured files:

/boot/loader.rc
/etc/fstab
/etc/rc.conf
/etc/hosts
/etc/resolv.conf
/etc/master.passwd
/etc/group
----------------------------------------------------------------------

example /etc/make.conf:
----------------------------------------------------------------------
WITHOUT_X11=yes
WITH_CLANG=yes
WITH_CLANG_IS_CC=yes

# For clang
NO_WERROR=
WERROR=

CFLAGS=-O2 -fno-strict-aliasing -pipe -march=armv6z -mtune=arm1176jzf-s -mfloat-abi=soft
COPTFLAGS=-O1 -fno-strict-aliasing -pipe -march=armv6z -mtune=arm1176jzf-s -mfloat-abi=soft
----------------------------------------------------------------------
How to build the kernel in RPI:

# fetch -o /usr http://www.peach.ne.jp/archives/rpi/patch/src-244906-20130101.patch.gz
# fetch -o /usr/src/sys/arm/conf http://www.peach.ne.jp/archives/rpi/config/RPI-B-test11
# cd /usr/src
# gzcat /usr/src-244906-20130101.patch.gz | patch
# make buildkernel KERNCONF=RPI-B-test11 WITH_FDT=yes

(wait about 50 minutes)

Don't forget to add NO_WERROR= and WERROR= to /etc/make.conf if you use clang.
If you already applied previous patch, you can remove it by like this:

# cd /usr/src
# gzcat /usr/src-XXXXXX-YYYYMMDD.patch.gz | patch -R

If you want re-compile without cleaning, you can try to use like this:

# make buildkernel KERNCONF=RPI-B-test11 WITH_FDT=yes -DNO_CLEAN -DNO_CLEANDIR
----------------------------------------------------------------------
How to use GPT USB stick in RPI:

(if you use something, delete/destory it before doing)
# gpart show
# gpart delete -i N da0 (where N is number of a partition)
# gpart destroy -F da0

(create new partition and format)
# gpart create -s gpt da0
# gpart add -t freebsd-ufs da0
# gpart show
# newfs -U -j /dev/da0p1

(mount it)
# mount /dev/da0p1 /mnt
----------------------------------------------------------------------
How to mount boot partition (MSDOS partition):

# mount -t msdosfs /dev/mmcsd0s1 /mnt

After this, you can edit the files such as config.txt in the boot partition.
----------------------------------------------------------------------

Enjoy clang world in Raspberry Pi!
Thank you.
-- 
Daisuke Aoyama 



More information about the freebsd-arm mailing list