Xilinx / XilinxVirtualCable

Xilinx Virtual Cable (XVC) is a TCP/IP-based protocol that acts like a JTAG cable and provides a means to access and debug your FPGA or SoC design without using a physical cable.
224 stars 80 forks source link

XVC driver for ZynqMP fails to compile with Petalinux 2021.2 #15

Closed frahacl closed 1 year ago

frahacl commented 2 years ago

Hello,

in our Petalinux 2020.2 based project for a Zynq MPSoC we successfully integrated the XVC driver as module. After upgrading to Petalinux 2021.2 the compilation of the driver module now fails.

The error is:

ERROR: xvc-driver-1.0-r0 do_compile: oe_runmake failed ERROR: xvc-driver-1.0-r0 do_compile: Execution of '/tmp/tmp_petalinux/work/zynqmp_generic-xilinx-linux/xvc-driver/1.0-r0/temp/run.do_compile.206518' failed with exit code 1: make -C /tmp/tmp_petalinux/work-shared/zynqmp-generic/kernel-source M=/tmp/tmp_petalinux/work/zynqmp_generic-xilinx-linux/xvc-driver/1.0-r0 make[1]: Entering directory '/tmp/tmp_petalinux/work-shared/zynqmp-generic/kernel-source' make[2]: Entering directory '/tmp/tmp_petalinux/work-shared/zynqmp-generic/kernel-build-artifacts' CC [M] /tmp/tmp_petalinux/work/zynqmp_generic-xilinx-linux/xvc-driver/1.0-r0/xvc_driver.o CC [M] /tmp/tmp_petalinux/work/zynqmp_generic-xilinx-linux/xvc-driver/1.0-r0/xvc_driver_base.o In file included from /tmp/tmp_petalinux/work/zynqmp_generic-xilinx-linux/xvc-driver/1.0-r0/xvc_driver.c:29: /tmp/tmp_petalinux/work-shared/zynqmp-generic/kernel-source/include/asm-generic/io.h: In function '__pci_ioport_unmap': /tmp/tmp_petalinux/work-shared/zynqmp-generic/kernel-source/include/asm-generic/io.h:1015:2: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration] 1015 | iounmap(p); | ^~~ | vunmap

According to the kernel source code the function 'iounmap' seems to be defined in 'include/asm-generic/iomap.h' which is only included if the kernel option CONFIG_GENERIC_IOMAP is defined. According to menuconfig this is not enabled in the default kernel configuration of Petalinux 2021.2 and cannot be directly changed.

mattypiper commented 2 years ago

I ran into this issue as well.

To fix it, I started by adding CONFIG_GENERIC_IOMAP to my kernel config. You can do that with petalinux-build -c kernel, or just edit project-spec/meta-user/recipes-kernel/linux/linux-xlnx/kernel.cfg and add CONFIG_GENERIC_IOMAP=y.

Then there is an issue with the deprecation of ioremap_nocache in favor of ioremap (see https://lkml.org/lkml/2019/12/9/434). For this, just replace the function call in xvc_driver_base.c.

--- a/zynqMP/src/driver/xvc_driver_base.c
+++ b/zynqMP/src/driver/xvc_driver_base.c
@@ -168 +168 @@ int probe(struct platform_device* pdev) {
-            db_ptrs[i] = ioremap_nocache(db_addr, db_size);
+            db_ptrs[i] = ioremap(db_addr, db_size);

Then update the include from #include <asm-generic/io.h> to #include <linux/io.h> in both xvc_driver.c and xvc_driver_base.c and you should be all set.

It's probably worth making a pull request with these updates since the changes are likely backwards compatible with nearly every version of petalinux.

prashant-mehta commented 1 year ago

@frahacl - Can you please re-test with https://github.com/Xilinx/XilinxVirtualCable/commit/0ec25101b47b2be5eb2083d1b099c45b76d2de8a commit included?

frahacl commented 1 year ago

I can confirm that compilation as well as the XVC server works now.