Skip to content

en fpga zynq synth for linux

Ryota Shioya edited this page Mar 11, 2023 · 4 revisions

How to run RSD via Linux on a Xilinx Zynq board

0. Setup the required development environment and environment variables.

  1. See Development Environment and setup the development environment for Boot on Xilinx Zynq FPGA boards.
  2. See Environment Variables and setup the environment variables for Boot on Xilinx Zynq FPGA boards.
  3. (Optional, but recommended) Install Synplify.
    • You can choose either from synthesizing using Synplify netlist and synthesizing using Vivado only.
    • However, Synplify+Vivado provided better operating frequency compared to Vivado only in our evaluation.

1. Setup the environment variables of Vitis.

source /<path_of_Xilinx>/Vitis/2019.2/settings64.sh   

2. Specify the target Zynq board in Processor/Src/Makefiles/Vivado.inc.mk.

  • Modify the TARGET_BOARD variable.
  • Note: ZedBoard is considered in the following steps.

3. (Optional) Generate the netlist file (rsd.vm) of RSD using Synplify.

This procedure is unnecessary if you will synthesis RSD using Vivado only.

  1. Open Processor/Project/Synplify/ver2017-03.prj on Synplify.
  2. In Synplify, select "ZedBoard" in the opened project and click "Run".
    • If the synthesis ran successfully, rsd.vm is generated in Project/Synplify/ZedBoard/.

4. Download and build all the necessary files.

  • Go to $(RSD_ROOT)/Processor/Src and run either of below command.

    • For synthesizing using Vivado only,
      make -f Makefile.vivado.mk xilinx-arm-linux
      
    • For synthesizing using the netlist generated by Synplify,
      make -f Makefile.synplify.mk xilinx-arm-linux
      
    • Be sure to run vivado-clean if you switch synthesizers
      make -f Makefile.vivado.mk vivado-clean
      make -f Makefile.synplify.mk vivado-clean
  • This step may take minutes or hours, depending on your machine and network speed.

  • These commands generate the following files in $(RSD_ARM_LINUX)/boot.

    • ARM Linux kernel for Zynq PS (uImage)
    • Device tree for ARM Linux kernel (devicetree.dtb)
    • Boot image including the RSD bitstream file (boot.bin)
  • A Debian rootfs for Zynq PS (ROOTFS.tar.gz) is also downloaded in $(RSD_ARM_LINUX).

If you want to add your new source files into Vivado project, please refer "Add New Files into Project" in this page

5. Extract the Debian rootfs for Zynq PS (ROOTFS.tar.gz).

Note: root privileges are required.

tar -xf ROOTFS.tar.gz

6. Set an IP address in the Debian rootfs.

Edit $(RSD_ARM_LINUX)/ROOTFS/etc/network/interfaces using a text editor.
Note: root privileges are required.
Example (set the IP address statically to 192.168.1.83):

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.83
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.2

7. Send all the necessary files to an SD card.

Note: a high-speed 16GB>= SD card is recommended.
Note: root privileges are required.

  1. Check the device name of the SD card in /dev/.
    lsblk       
    
    Note: /dev/sdd is considered in the following steps.
  2. Create partitions in the SD card.
    # The following operations in the fdisk command are separated by ";" and are executed one by one.
    sudo fdisk /dev/sdd
    d        # Delete all the partitions in the SD card
    n; p; 1; Enter; +1024M; # Create the 1st partition
    n; p; 2; Enter; Enter;  # Create the 2nd partition
    t; 1; b; # Change the partition type of the 1st partition to FAT32(Win95)
    a; 1;    # Add a bootable flag to the 1st partition
    w        # Apply all the changes to the SD card
  3. Format the SD card.
    sudo mkfs.msdos -n BOOT /dev/sdd1
    sudo mkfs.ext4 -L ROOTFS /dev/sdd2      
  4. Copy all files to the SD card.
    mkdir BOOT_MNT
    mkdir ROOTFS_MNT
    sudo mount /dev/sdd1 BOOT_MNT
    sudo mount /dev/sdd2 ROOTFS_MNT
    sudo cp -R $(RSD_ARM_LINUX)/ROOTFS/* ROOTFS_MNT
    sudo cp $(RSD_ARM_LINUX)/boot/devicetree.dtb BOOT_MNT
    sudo cp $(RSD_ARM_LINUX)/boot/uImage BOOT_MNT
    sudo cp $(RSD_ARM_LINUX)/boot/boot.bin BOOT_MNT
    # You must unmount these directories!
    sudo umount BOOT_MNT
    sudo umount ROOTFS_MNT

8. Insert the SD card into ZedBoard and boot.

  • Login via SSH.
    User name : root
    Password  : rsd
    
  • Please check the boot log via the USB-UART port if SSH connection is not established.

9. Send and compile the RSD program loader.

  1. Send $(RSD_ROOT)/Processor/Project/Vivado/ARM_Linux/ProgramLoader/loader.c to ZedBoard via SCP.
  2. Compile loader.c on ZedBoard.

10. Run your program on RSD on ZedBoard.

  1. Send your program code.hex via SCP.
    • See this page to learn how to make your program code.hex.
  2. Run your program using the program loader.
    # "byte size of code.hex" is the size in binary, which matches the size of code.bin
    # Currently 98304
    ./loader <path of code.hex> <byte size of code.hex>

11. How to execute when re-synthesizing

  1. Regenerate boot image (boot.bin) containing RSD bitstream file in your local machine
    make -f Makefile.(synplify|vivado).mk xilinx-arm-linux
  2. Mount the BOOT partition in Zynq
    mkdir boot
    mount /dev/mmcblk0p1 boot
  3. Transfer boot.bin to Zynq
    • Overwrite the boot.bin in the "boot" that you just mounted.
    • boot.bin is generated at ${RSD_ARM_LINUX}/boot/boot.bin/boot.bin.
  4. Reboot
    shutdown -r now

Related documents

Clone this wiki locally