FreeBSD on Zynq-7000 / Zedboard


I'm working on porting FreeBSD to the Zedboard and other Xilinx Zynq-7000 platforms. The Zynq-7000 is an interesting platform combing a Xilinx 7-series FPGA fabric with a dual-core ARM Cortex-A9 "Application Processor Unit" (System-on-a-Chip).

The Zedboard is an evaluation board for the Zynq-7000. It is manufactured by Digilent. More information on the Zedboard can be found at www.zedboard.org.

The information on this page is migrating to the FreeBSD wiki at http://wiki.freebsd.org/FreeBSD/arm/Zedboard.

MicroZed


The Zynq port is now running on the MicroZed board. It runs the same Zedboard SD card image with a few file changes in the boot partition. I describe below how to make the changes.

Parallella


The Zynq FreeBSD port is now running on Parallella! I describe below how to modify the Zedboard SD card image to boot on Parallela.

Pre-built SD card image

I am no longer building SD card images for the Zedboard because they are now available in FreeBSD's snapshot releases directory.

If you'd like to test-drive FreeBSD on a Zedboard, download the latest bzip2 compressed SD card image. Uncompress and copy the image to the SD card. On my machine, the SD card shows up as /dev/da0. Be sure that is the same on your machine before cut and pasting this.

# bunzip2 FreeBSD-11.0-CURRENT-arm-armv6-ZEDBOARD.img.bz2
# dd if=FreeBSD-11.0-CURRENT-arm-armv6-ZEDBOARD.img of=/dev/da0 bs=32768

Boot It

Power down the Zedboard. Insert the SD card in the SD slot and be sure the Zedboard's configuration mode jumpers are set for booting from SD card before powering up. (If you've already been booting the Linux image from the SD card shipped with the Zedboard, this shouldn't need to change.)

The USB-UART connected to connect J14 acts as the FreeBSD console (device uart1). This is the same console as the stock Linux image. The Zedboard should automatically boot U-boot and then the FreeBSD kernel.

The FreeBSD kernel has drivers for the UARTs, SDIO, Gig Ethernet, and a USB host driver for the USB OTG connected at J13. There is also a GPIO driver which allows reading of switches and buttons and controlling the LEDs.

Please send any feedback to me via E-mail

Other Zynq Boards:

MicroZed

To run this image on a MicroZed, you need to change a few files in the image. Download microzed_extrafiles.tgz and extract the files. Then mount the SD card partitions on your machine and copy the files over:
# mkdir /mnt/boot /mnt/armroot
# mount -t msdosfs /dev/da0s1 /mnt/boot
# mount /dev/da0s2a /mnt/armroot

# tar xzvf microzed_extrafiles.tgz
# cp microzed_extrafiles/{BOOT.BIN,uEnv.txt,microzed.dtb} /mnt/boot
# cp rc.conf /mnt/armroot/rc.conf

# umount /mnt/boot
# umount /mnt/armroot

Note: At boot-up, the USB-Host interface on MicroZed is held in reset by a Zynq GPIO signal (PS_MIO7). The quick-and-dirty way to release it from reset is as follows:

# gpioctl -c 7 OUT
# gpioctl 7 1
I'll try to come up with a start-up script for /etc/rc.d to automate this.

Parallella

To run this image on a Parallella, you need to replace all the files in the boot partition. Download parallella_freebsd.tgz. It contains the new boot files for FreeBSD on Parallella.

Mount the SD card boot partition on your machine:

# mkdir /mnt/boot
# mount -t msdosfs /dev/da0s1 /mnt/boot
Remove all the files in the boot partition:
# rm /mnt/boot/*
Copy your Parallella board's bitstream to the partition. There are several different bitstreams for the various board configurations. See section 3 of this guide to creating an SD card.
# cp parallella_????.bit.bin /mnt/boot/parallella.bit.bin
Extract the files from parallella_freebsd.tgz into the boot partition:
# tar xzvf parallella_freebsd.tgz -C /mnt/boot
Unmount the boot partition
# umount /mnt/boot

Note: Changing the hostname from zedboard to parallella is an exercise left to the reader. :-)

Source Code

Zynq/Zedboard support is now in the FreeBSD kernel source (base/head). Most of the relevant code is in sys/arm/xilinx and the GigEthernet driver is in sys/dev/cadence.


Building an SD Image

Note: Tim Kientzle's crochet-freebsd tool can now build ZedBoard images.

Here's how I create the SD image from the source.

Build world and kernel

From within the source directory:
make TARGET_ARCH=armv6 KERNCONF=ZEDBOARD buildworld buildkernel

Create SD card image

dd if=/dev/zero of=SDCARD.img count=1048576
mdconfig -f SDCARD.img -u 0

gpart create -s MBR md0
gpart add -s64m -t \!14 md0
gpart set -a active -i 1 md0
newfs_msdos -F 16 /dev/md0s1

gpart add -t freebsd md0
gpart create -s BSD md0s2
gpart add -t freebsd-ufs md0s2
newfs /dev/md0s2a
tunefs -n enable /dev/md0s2a

Mount filessystems

mkdir /mnt/boot /mnt/armroot
mount -t msdosfs /dev/md0s1 /mnt/boot
mount /dev/md0s2a /mnt/armroot

Populate root and boot partitions

From within the source directory:
make TARGET_ARCH=armv6 KERNCONF=ZEDBOARD DESTDIR=/mnt/armroot installworld distribution installkernel
Download and extract these files: zedboard_extrafiles.tgz. (microzed_extrafiles.tgz for the MicroZed.)

Copy these files to the boot partition:

cp BOOT.BIN ubldr zedboard.dtb uEnv.txt /mnt/boot

Final tweaks

Copy these files to the root partition (also in zedboard_extrafiles.tgz):
mkdir /mnt/armroot/boot/msdos
cp rc.conf fstab /mnt/armroot/etc

Unmount file systems

umount /mnt/boot
umount /mnt/armroot
mdconfig -d -u 0

Copy to an SD card

dd if=SDCARD.img of=/dev/da0 bs=32768

Building u-boot

I no longer use a modified u-boot for FreeBSD on Zynq. The stock u-boot from Xilinx can boot FreeBSD using the uEnv.txt file in zedboard_extrafiles.tgz.

The official repository for Xilinx port of u-boot is on github here. Follow the instructions to build the zynq_zed configuration of u-boot.


Thomas Skibo

E-mail Me