Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Linux device driver is located in the src/driver directory of the repository. The driver supports device tree and non-device tree initialization with device tree being the default. Non-device tree is somewhat legacy or advanced use cases not supported by device tree. The device driver source code requires two small changes to build in the newer 5.4 .0 rebase kernel for the 2020.1 release of PetaLinux.

...

A Vivado hardware build creates an XSA output file(bitstream packaged in XSA) which is then imported into PetaLinux project. After exporting the hardware from Vivado import the new Vivado system into PetaLinux as illustrated below.

Code Block
languagebash
$ petalinux-config --get-hw-description <relative path to xsa file>=<PATH-TO-XSA DIRECTORY>

Petalinux Kernel Module

Create a out-of-tree (or "external") Linux kernel module (LKM) to support the XilinxVirtualCable device driver.

Code Block
$ petalinux-create -t modules -n xvc-driver --enable
Note

The name of the driver must not include the "_" character such that the name of the driver was changed from xvc_driver to xvc-driver for PetaLinux.

Copy some The xvc-driver module recipe you created can be found in the <plnx-proj-root>/project-spec/meta-user/recipes-modules/xvc-driver directory, Copy some of the source code files from the XilinxVirtualCable repository, including the xvc_driver*.c, xvc_driver.h, xvc_user_config.h, and xvc_ioctl.h, into the recipe to build the kernel module in the PetaLinux project (<project>/projects<plnx-proj-root>/project-spec/meta-user/recipes-modules/xvc-driver/files.)

Info

Not all the source files are required.

  • The xvc_user_config_example.h supports the legacy method of configuring the driver without the use of device tree

  • The xvc_fragment.dts is a device tree fragment illustrating the changes required to the device tree.

  • The PetaLinux generated Makefile is used rather than the repository provided Makefile.

Alter the SRC_URI BitBake recipe vairable in the project at <project>/project-<plnx-proj-root>/project-spec/meta-user/recipes-modules/xvc-driver/xvs-driver.bb recipe file to copy include the required source files into the build area as illustrated below.

Code Block
SRC_URI = "file://Makefile \
           file://COPYING \
           file://xvc_driver_base.c \
           file://xvc_driver.c \
           file://xvc_driver.h \
           file://xvc_ioctl.h \
           file://xvc_user_config.h \
          "

...

Note

The device driver does not build with the newer kernel (5.4.5.0) such that two changes are required.

Alter the xvc_driver.h source file adding a line to cause LOG_PREFIX to be not used as illustrated in the folllowingfollowing.

Code Block
#define LOG_PREFIX

Alter the xvc_driver_base.c source file to add conditional code around the mmiowb() function which is not supported with the newer kernel.

Code Block
languagebash
 #include <linux/version.h>
Code Block
languagebash
#if KERNEL_VERSION(5, 14, 0) >= LINUX_VERSION_CODE
        mmiowb();
#endif

...

Create an application in PetaLinux.

Code Block
languagebash
$ petalinux-create -t apps -n xvcServer --enable

Copy xvcServer.c from the src/user directory of the The xvcServer apps recipe you created can be found in the <plnx-proj-root>/project-spec/meta-user/recipes-apps/xvcServer directory, Copy xvcServer.c from the src/user directory of the XilinxVirtualCable repository and xvc_ioctl.h from the src/driver directory of the XilinxVirtualCable repository into the BitBake recipe area directory of the PetaLinux project at <project><plnx-proj-root>/project-spec/meta-user/recipe-apps/xvcServer/files.

...

Alter the BitBake recipe of the application at <project-spec><plnx-proj-root>/project-spec/meta-user/recipes-apps/xvcServer/xvcServer.bb to copy the source files into the build area as illustrated below.

Code Block
SRC_URI = "file://xvcServer.c \ 
           file://xvc_ioctl.h \
           file://Makefile \
          "

PetaLinux Device Tree



DEPENDS = "\
    xvc-driver \
    "

PetaLinux Device Tree

The device tree node for the Xilinx Debug Bridge IP in the PetaLinux generated device tree (pl.dtsi) does not match the compatibility string for the device driver. Alter the system-user.dtsi device tree of the PetaLinux project in <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files to alter the compatible string to match that driver as illustrated below.

...

PetaLinux Image Build

Build the Linux image.ub in Petalinux PetaLinux System Images as illustrated below.

Code Block
petalinux-build

Build the boot.bin , When the build finishes, the generated images are stored in the <plnx-proj-root>/images/linux or /tftpboot directories.

Code Block
$ petalinux-build

Package the BOOT.BIN image with all the boot components including the FPGA bitstream. From the <project><plnx-proj-root>/images/linux directory the boot image is built as illustrated below.

...

the boot image is built as illustrated below.

Code Block
languagebash
$ petalinux-package --boot --format BIN --fsbl <plnx-proj-root>/images/linux/zynqmp_fsbl.elf --u-boot <plnx-proj-root>/images/linux/u-boot.elf --pmufw <plnx-proj-root>/images/linux/pmufw.elf --fpga <plnx-proj-root>/images/linux/system.bit --ubootforce

Running The Prototype

Starting The Software

The following steps assume Linux has booted on the embedded target and the network is functional with respect to a valid IP address and the host computer running Vivado is on the same network (subnet). From the running target the device driver should be started as illustrated below.

Code Block
root@xilinx-zcu102-2020_1:~# modprobe xvc-driver 

The following console output illustrates the expected output when the driver is working.

Code Block
root@xilinx-zcu102-2020_1:~# modprobe xvc-driver

...


[   21.370940] xvc_driver: loading out-of-tree module taints kernel.

...


[   21.377673] Starting...

...


[   21.380476] Created device xilinx_xvc_driver

From the running target the server application should be started as illustrated below.

Code Block
root@xilinx-zcu102-2020_1:~# xvcServer &

The following console output illustrates the expected output when the server is working and ready to use.

Code Block
root@xilinx-zcu102-2020_1:~# xvcServer &

...


INFO: XVC driver character file: /dev/xilinx_xvc_driver

...


INFO: debug_bridge base address: 0xA0000000

...


INFO: debug_bridge size: 0x10000

...


INFO: debug_bridge device tree compatibility string: xlnx,xvc

...


INFO: To connect to this xvcServer instance, use url: TCP:xilinx-zcu102-2020_1:2542
Info

Note the base address of the Debug Bridge in the output above could be at a different address depending on the connections in the IPI design of Vivado.

...

In the past there have been issues where the clock(s) to the PL could be shut off so that the ILA does not function. This can be prevented by adding a kernel parameter to the Linux boot arguments in the device tree. Edit the <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi file in the PetaLinux project and alter the boot arguments to add “cpuidle.stopoff=1” as illustrated below. For more details refer AR# 69143

Code Block
    chosen {
            bootargs = " earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/ram0 rw cpuidle.stopoff=1";
            stdout-path = "serial0:115200n8";
    };
Info

The boot arguments (bootargs) above may not exactly match your system and are only intended to show the addition of the “cpuidle.stop=1”. There is no way to add an argument without specifying all of the existing boot arguments. The bootargs for the PetaLinux system can be found in the system-conf.dtsi file of the build in the <project>the <plnx-proj-root>/components/plnx_workspace/device-tree/device-tree directory or from a running target using the command: cat /proc/cmdline.

...

If the output of the device driver does not include all the lines (as illustrated below) then the device tree for the Debug Bridge may not be up to date as specified in the steps. The driver can be inserted into the kernel but not find any compatible driver so that it is not functioning even though it is in the kernel.

Code Block
languagebash
root@xilinx-zcu102-2020_1:~# modprobe xvc-driver

...


[ 21.370940] xvc_driver: loading out-of-tree module taints kernel.

...


[ 21.377673] Starting...

...


[ 21.380476] Created device xilinx_xvc_driver

Hardware Manager And JTAG

Vivado hardware manager can be used to connect to the target using JTAG rather than the network connection such that the server may show an error when it is attempted as shown below.

Code Block
languagebash
root@xilinx-zcu102-2020_1:~#

...


connection accepted - fd 5

...


setting TCP_NODELAY to 1

...


invalid cmd 'E'

...


connection closed - fd 5

Conclusion

There are many ways to use the Xilinx Virtual Cable other than the method shown above and this page was only intended to show principles to help users understand how the system works.

...