FreeBSD on Zynq-7000 / Zybo / Zedboard


This page describes running FreeBSD on 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 based 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.

Pre-built SD card image

An SD card image for the Zedboard based upon FreeBSD 12.0-RELEASE is available here: FreeBSD-12.0-ZEDBOARD-341666.img.xz.

Note: These images were updated in early January 2019 to use efi booting instead of ubldr to be consistent with other arm boards.

SHA256 (FreeBSD-12.0-ZEDBOARD-341666.img) = 03c7aacfebdaff3968d3d2d6da439276fd2aaa6ac6e1e7e919cfced540f4ff8c
SHA256 (FreeBSD-12.0-ZEDBOARD-341666.img.xz) = 64826b0a1a566d8a50ea2c2997dbc6e0539997b4b4fb2c70a2c01e5ff86c21d5

If you'd like to test-drive FreeBSD on a Zedboard, download the xz 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.

xz --decompress FreeBSD-12.0-ZEDBOARD-341666.img.xz
dd if=FreeBSD-12.0-ZEDBOARD-341666.img of=/dev/da0 bs=1m

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 the SD card before powering up. (If you've already been booting the Linux image from the SD card shipped with the Zedboard, you shouldn't need to change anything.)

The USB-UART connected to connector 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, SDHCI, 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.

Note: Booting this pre-built image will not display "FreeBSD" on the OLED display as shown in the picture. It was a separate C program I wrote a while ago and now I can't find it!

Please send any feedback to me via E-mail


Zybo:

FreeBSD also runs on the Zybo. The Zybo from Digilent Inc. is a lower cost board than the Zedboard.

Here is a pre-built SD card image for Zybo based upon FreeBSD 12.0-RELEASE: FreeBSD-12.0-ZYBO-341666.img.xz.

SHA256 (FreeBSD-12.0-ZYBO-341666.img) = 5acc0b7448b429e6a60e271f381e9ea3098843a6821f743e536c8d5bc69de705
SHA256 (FreeBSD-12.0-ZYBO-341666.img.xz) = 3160dcfe08e4984e23101aaf3a0ee93a83e08f01272a8fa7e778f06d8cfdd380
Follow the instructions above in the Zedboard section to uncompress and copy the image to an SD card. To boot the image on Zybo, don't forget to set the mode jumper (JP5) to boot from SD.

Note: This image is for the original Zybo which has been retired and replaced by the Zybo Z7 board. This image will not work on the Zybo Z7.


Ultra96?

It's not well tested and there are lots of drivers missing but FreeBSD is booting on the Zynq Ultrascale+ based Ultra96 board. If you'd like to try it out, download the SD card image: FreeBSD-Ultra96.img.xz. Decompress the image and write it to an SD card as described above.


Building an SD Image

Build world and kernel

First, we need to build world for armv7 and a kernel for Zedboard:

From the source directory /usr/src:

make TARGET_ARCH=armv7 KERNCONF=ZEDBOARD buildworld buildkernel

Create an SD card image

The following creates SD card image with an msdos boot partition.
dd if=/dev/zero of=SDCARD.img bs=1m count=2000
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 SD card partitions

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

Copy boot files

The Zynq chip needs several files in an msdos boot partition to boot FreeBSD:
boot.bin
u-boot.img
EFI/BOOT/bootarm.efi
dtb/zedboard.dtb
uEnv.txt
The boot.bin and u-boot.img come from the u-boot-zedboard port in /usr/ports/sysutils/u-boot-zedboard.
cp /usr/local/share/u-boot/u-boot-zedboard/{boot.bin,u-boot.img} /mnt/boot
The efi boot loader is built by buildworld (see above). The binary is found in /usr/obj/usr/src/arm.armv7/stand/efi/boot1. Copy it over:
mkdir -p /mnt/boot/EFI/BOOT
cp /usr/obj/usr/src/arm.armv7/stand/efi/boot1/boot1.efi /mnt/boot/EFI/BOOT/bootarm.efi  
Last, we need the dtb file and uEnv.txt:
mkdir /mnt/boot/dtb  
dtc -I dts -O dtb /usr/src/sys/dts/arm/zedboard.dts > /mnt/boot/dtb/zedboard.dtb
echo fdtfile=zedboard.dtb > /mnt/boot/uEnv.txt

Populate root and boot partitions

From within the source directory:
make TARGET_ARCH=armv7 KERNCONF=ZEDBOARD DESTDIR=/mnt/armroot installworld distribution installkernel

Final tweaks

Copy a couple more files:
cp fstab rc.conf /mnt/armroot/etc

Create a mount point for the boot partition:

mkdir /mnt/armroot/boot/msdos

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=1m

Updated: Jan 2019


Thomas Skibo

E-mail Me