While following the provided tutorial from the official website of pynq, I have met a lot of errors and failed to build pynq image for zedboard. So, I would like to write down this for others as a guideline for newbie. To download those mentioned files, checkout the download links below.
I’m using WSL2 (Ubuntu 16.04.7 LTS) as the environment, petalinux-2018.3 and SDx-2018.3 from Xilinx to build the image. The petalinux and SDx are installed in the following path of my WSL:
/tools/Xilinx/
~/petalinux/2018.3
After you have installed petalinux and SDx, you need to source it:
source /tools/Xilinx/SDK/2018.3/settings64.sh
source /tools/Xilinx/SDx/2018.3/settings64.sh
source /tools/Xilinx/Vivado/2018.3/settings64.sh
source ~/petalinux/2018.3/settings.sh
petalinux-util --webtalk off
I’m using an older release of PYNQ to build the image, because I don’t want to download other version of Xilinx software (SDx file is really big and it takes a lot of time to install it). The following commands are to download the pynq-2.4 repository and the prebuild image Pynq-Z1 v2.4 from github and extract it.
cd ~/Documents
wget https://github.com/Xilinx/PYNQ/archive/refs/tags/v2.4.tar.gz
wget https://www.xilinx.com/member/forms/download/xef.html?filename=pynq_z1_v2.4.zip
tar -xf v2.4.tar.gz
unzip pynq_z1_v2.4.zip
cd ./PYNQ-2.4
Since line 57 in ~/PYNQ-2.4/sdbuild/Makefile will use git command and PYNQ-2.4 is extracted from a tar file, currently it is not a git repository. So, we need to initialize it as a local git repository. Otherwise, the error would occur during the runtimen.
cd ~/Documents/PYNQ-2.4
git init
git add .
git commit -m "init"
Before that, I was following the tutorial of official website to build pynq sd card for other board, and I get into a lot of error and trouble, then here comes to this tutorial in the forum of building the image for custom board from prebuilt image. However, I still get into the errors, and I think its because I’m using WSL2.
Well, you need to install the dependencies for pynq:
cd ~/Documents/PYNQ-2.4/sdbuild/script
sudo ./setup_host.sh
Then, create your board specification:
mkdir ~/Documents/boards
mkdir ~/Documents/boards/zedboard
touch ~/Documents/boards/zedboard/zedboard.spec
Copy and paste the following zedboard specification into the file “~/Documents/boards/zedboard/zedboard.spec”. Then, save and close it.
ARCH_zedboard = arm
BSP_zedboard = avnet-digilent-zedboard-v2018.3-final.bsp
STAGE4_PACKAGES_zedboard = boot_leds ethernet pynq jupyter pandas
Download zedboard-v2018.3 bsp and put it into the folder “~/Documents/boards/zedboard/”. Which the patch of the bsp file would look like this:
~/Documents/boards/zedboard/avnet-digilent-zedboard-v2018.3-final.bsp
Start to build your image:
cd ~/Documents/PYNQ-2.4/sdbuild
make BOARDDIR=~/Documents/boards PREBUILD=~/Documents/pynq_z1_v2.4.img
Wait until you get this kind of error then I ignore it :D. I didn’t research into /dev/mapper stuff.
+ sudo chroot / mkfs -t fat /dev/mapper/loop5p1
mkfs.fat 3.0.28 (2015-05-16)
/dev/mapper/loop5p1: No such file or directory
Makefile:299: recipe for target '/home/yang/Documents/PYNQ-2.4/sdbuild/build/bionic.arm.stage1.img' failed
make: *** [/home/yang/Documents/PYNQ-2.4/sdbuild/build/bionic.arm.stage1.img] Error 1
You might get this error as well :D (This is cause by the pynq makefile script doesn’t make the folder “proc”). Ignore it too :p
QEMU_EXE=/opt/qemu/bin/qemu-arm-static PYNQ_BOARDDIR=/tmp/tmp.iC2pP0Gx9E/zedboard PYNQ_BOARD=zedboard ARCH= PACKAGE_PATH=/tmp/tmp.iC2pP0Gx9E/zedboard/packages /home/yang/Documents/PYNQ-2.4/sdbuild/scripts/install_packages.sh /home/yang/Documents/PYNQ-2.4/sdbuild/build/bionic.zedboard
+ target=/home/yang/Documents/PYNQ-2.4/sdbuild/build/bionic.zedboard
+ shift
+ fss='proc run dev'
+ for fs in '$fss'
+ sudo mount -o bind /proc /home/yang/Documents/PYNQ-2.4/sdbuild/build/bionic.zedboard/proc
mount: mount point /home/yang/Documents/PYNQ-2.4/sdbuild/build/bionic.zedboard/proc does not exist
Makefile:298: recipe for target '/home/yang/Documents/PYNQ-2.4/sdbuild/output/zedboard-2.4.img' failed
make: *** [/home/yang/Documents/PYNQ-2.4/sdbuild/output/zedboard-2.4.img] Error 32
Make failed
Makesure the following files are existed, they are important. If no, please go to pynq forum to ask for help.
~/Documents/PYNQ-2.4/sdbuild/output/zedboard-2.4.img
~/Documents/PYNQ-2.4/sdbuild/output/boot/zedboard/BOOT.BIN
~/Documents/PYNQ-2.4/sdbuild/output/boot/zedboard/image.ub
I follow this [tutorial][https://pynq.readthedocs.io/en/latest/appendix.html#writing-the-sd-card] to write the SD card:
After burning it, your SD card will become like this:
However, you still need to replace the BOOT.BIN and image.ub files in the F:\ drive with the following files:
~/Documents/PYNQ-2.4/sdbuild/output/boot/zedboard/BOOT.BIN
~/Documents/PYNQ-2.4/sdbuild/output/boot/zedboard/image.ub
Here you go! Your PYNQ SD card for Zedboard is done.
26 May 2021 - Yang