This is a simple manual on how to prepare the linux environment that can be deployed on the board.
Install the latest vmware player
download Ubuntu 18 LTS desktop iso
Create an VM Machine with the minimum specs
300Gib of hdd
8 CPU Cores
16 Gib ram
If you want to use “Host ↔︎ Guest” File sharing
After installing ubuntu make sure the host tools are also installed
mount C:\Program Files (x86)\VMware\VMware Player\linux.iso
manually install these tools on ubuntu
Create the sharing point on VMWare settings
> Options
> Shared Folders
Mount the sharing on linux side
sudo vmhgfs-fuse .host:/ /mnt/hgfs/ -o allow_other -o uid=1000 |
Make sure to download petalinux beforehand, it takes 2 hours to download
Download petalinux petalinux-v2019.2-final-installer.run
make bash the default shell
sudo dpkg-reconfigure dash |
install dependencies:
sudo apt-get install -y python gawk gcc git make net-tools libncurses5-dev tftpd zlib1g:i386 libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev screen pax gzip |
install petalinux:
mkdir -p /home/ryven/petalinux20192 ./petalinux-v2019.2-final-installer.run /home/ryven/petalinux20192 |
everytime you need to work with petalinux you need to setup the env
source /home/ryven/petalinux20192/settings.sh |
if you use a share folder, mount it
sudo vmhgfs-fuse .host:/ /mnt/hgfs/ -o allow_other -o uid=1000 |
These are board steps to build a sample, specific demos need the proper options picked on rootfs and kernel
Create the petalinux project
petalinux-create -t project --template zynq --name ZPFC_Petalinux cd ZPFC_Petalinux/ |
Configure the hardware. The hdf file should be copied to petalinux directory before this command
petalinux-config --get-hw-description=../ |
Configure the rootfs
cp ../system-user.dtsi project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi petalinux-config -c rootfs |
Enable i2c-tools (Filesystem Packages ---> base ---> i2c-tools)
Enable usbutils (Filesystem Packages ---> base ---> usbutils)
Enable libusb1 (Filesystem Packages ---> libs --> libusb-compat ---> libusb-compat )
Enable peekpoke (apps ---> peekpoke )
Enable gpio-demo (apps ---> gpio-demo)
Configure the kernel
petalinux-config -c kernel |
Enable DP83867_PHY (Device Drivers -> Network device support -> PHY Device support and infrastructure -> Texas Instruments DP83867 Gigabit PHY)
Enable CONFIG_USB_ULPI_BUS (Device Drivers -> USB support -> USB ULPI PHY interface support)
Enable CONFIG_XILINX_PHY (Device Drivers -> Network device support -> PHY Device support and infrastructure -> Drivers for xilinx PHYs)
Enable CONFIG_FB_SIMPLE (Device Drivers -> Graphics support -> Frame buffer Devices -> Simple framebuffer support)
Enable CONFIG_LOGO (Device Drivers -> Graphics support -> Bootup logo)
Build linux
petalinux-build |
Generate the bootable image for sd card
TODO: we need the bit file produced by the xilinx vivado petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot petalinux-package --prebuilt --fpga images/linux/system.bit |
At this point you should have a file structure like this
This files can now be copied to an sd card formated with FAT32
Mount the SD card on your host machine.
Copy the following files from <plnx-proj-root>/pre-built/linux/images/ into the
root directory of the first partition which is in FAT32 format in the SD card:
BOOT.BIN
image.ub
Connect an Usb cable from the computed to the usb-uart plug
Open a console on the workstation and start the putty communication program. (serial, 115200)
Set the boot mode of the board to SD boot using the dip switch S7
set it to 11, both switches on
Connect a 12V power supply to the main power plug
Power on the board.
Watch the serial console
To build the petalinux image you should follow the general steps described above. Make sure you pick the proper kernel and rootfs options, they are listed here
After building the petalinux image one needs to build the boot.bin
on vivado, a prebuilt version of boot.bin
is available here. copy that file to the sd card.
To run the pcie demo you only need the boot.bin file from the prebuild folder on the samples repo. petalinux image is not needed. Place boot.bin on the sdcard and plug the sdcard on the board.
Please set VCCADJ (VCCO for bank 34) to 3.3V, changing the DIP S2 to 0001
Connect the board on the PCIe slot of the host computer. make sure you don’t have the external power plugged in the board.
Power the computer.
Install ubuntu 18.04. (last tested with 18.04.03)
To use a custom (unsigned) driver with new Linux systems you need to disable "Secure Boot" option in BIOS. It prevents "permission failed" errors while insmod/modprobe commands.
Install packages used for kernel build
sudo apt-get install build-essential checkinstall sudo apt-get install linux-headers-$(uname -r) sudo apt-get install libaio1 libaio-dev sudo apt-get install git |
Checkout the linux driver code (https://www.xilinx.com/support/answers/65444.html and https://xilinx.github.io/dma_ip_drivers/)
git clone https://github.com/Xilinx/dma_ip_drivers.git |
Build driver
git clone https://github.com/Xilinx/dma_ip_drivers.git cd dma_ip_drivers/XDMA/linux-kernel/xdma/ make |
if you are kernel 5 you might get some compiling errors, and you will need to patch your code
1) The interface of linux/swait.h changed from the previous versions of the kernel.. Inside libxdma.c replace - swait_event_interruptible_timeout + swait_event_interruptible_timeout_exclusive and - swake_up + swake_up_one 2) The 5.0 kernel dropped the type argument to access_ok() Inside cdev_ctrl.c replace - result = !access_ok(VERIFY_WRITE, (void __user *)arg, + result = !access_ok((void __user *)arg, and - result = !access_ok(VERIFY_READ, (void __user *)arg, + result = !access_ok( (void __user *)arg, |
Build tests
cd ../tools make |
Load driver
cd ../tests chmod +x *.sh sudo ./load_driver.sh |
Run tests
sudo ./run_test.sh |
Registers access - Read/Write AXI GPIO core connected to DIP Switches and PL LEDS
cd ../tools #Set LEDS sudo ./reg_rw /dev/xdma0_user 0x00000000 32 1 #Read DIP Switches sudo ./reg_rw /dev/xdma0_user 0x00000000 |
https://www.xilinx.com/Attachment/Xilinx_Answer_65444_Linux.pdf
https://www.xilinx.com/Attachment/Xilinx_Answer_71435_XDMA_Debug_Guide.pdf
https://www.xilinx.com/support/documentation/ip_documentation/xdma/v4_1/pg195-pcie-dma.pdf
Old linux kernel driver code from 65444. Just for reference