PYNQ: PYTHON PRODUCTIVITY FOR ZYNQ

Import pynq package on non-pynq image

I’m running a non-Pynq image (xilinx 2019.1 kernel with Ubuntu rootfs for the ZCU111), and I’m trying to install the pynq python package (e.g. import pynq in python3) to leverage the xrfdc drivers that “pynq” provides. With that, I started at the Xilinx/PYNQ git page and tried to start installing via:

[1] sudo pip3 install --upgrade git+https://github.com/Xilinx/PYNQ.git

I’ve encountered errors along the way and resolved them by installing many dependencies, packages, etc. But, now I’m at an error (not able to find libxlnk_cma.h) when trying to install as shown in [1]. The error appears to be referencing a libxhdmi.so library I don’t have.

While I continue looking into this library, I’m curious (since I can’t find this answer anywhere else, yet) what are your thoughts on installing the python pynq package on a non-pynq image? I’m digging through Makefiles and cmake files and other files while trying to be efficient with my time, that is it’s taking longer than I thought :smile:

Any thoughts are appreciated. Thanks!

[EDIT/AFTERTHOUGHT]: I guess it seems like, perhaps I’m reinventing the wheel here, so to speak. I say that not being the most familiar with Pynq and all that it allows. My thought was the the pynq package that I can import is only a piece of what a pynq image provides. Meaning, perhaps what I’m doing isn’t much different than what the ZCU111 pynq image provides?

We are retiring that pip install from github. The best thing that you can try, is to install from the sdist.

python3 -m pip install <pynq_sdist>.tar.gz --upgrade --no-deps

where you can download pynq_sdist from https://github.com/Xilinx/PYNQ/releases/download/v2.5/pynq-2.5.tar.gz

This flow has not been tested on other rootfs so proceed with your own risk.

Thanks! It said it installed, but upon opening python3 and executing import pynq:

>>> import pynq
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/pynq/__init__.py", line 33, in <module>
    from .pl import PL
  File "/usr/local/lib/python3.6/dist-packages/pynq/pl.py", line 39, in <module>
    from .ps import CPU_ARCH_IS_SUPPORTED, CPU_ARCH, ZYNQ_ARCH, ZU_ARCH
  File "/usr/local/lib/python3.6/dist-packages/pynq/ps.py", line 322, in <module>
    class _ClocksUltrascale(_ClocksMeta):
  File "/usr/local/lib/python3.6/dist-packages/pynq/ps.py", line 382, in _ClocksUltrascale
    IOPLL_CTRL = Register(CRL_APB_ADDRESS + IOPLL_CTRL_OFFSET)
  File "/usr/local/lib/python3.6/dist-packages/pynq/registers.py", line 115, in __init__
    array = MMIO(address, np.dtype(register_type).itemsize).array
  File "/usr/local/lib/python3.6/dist-packages/pynq/mmio.py", line 82, in __init__
    device = Device.active_device
  File "/usr/local/lib/python3.6/dist-packages/pynq/pl_server/device.py", line 91, in active_device
    raise RuntimeError("No Devices Found")
RuntimeError: No Devices Found
>>>

Devices? *digging into the code … *

Is there a reason you don’t want to use the pre-compiled ZCU111 PYNQ image?

Available here:

Cathal

I may consider that in the future, but at the moment I’m mostly curious about accessing a bitstream via a python package, and I came across Pynq :slight_smile:

It might be related to the fpga manager. Do you have fpga manager framework enabled on your rootfs? PYNQ users that framework to manage bitstreams.

Yes. I even tried loading the bistream first before importing pynq:

cp <bistream>.bit /lib/firmware
echo 0 > /sys/class/fpga_manager/fpga0/flags
echo <bitstream>.bit > /sys/class/fpga_manager/fpga0/firmware
(shows that it's writing, lasts for about 10-20 seconds)
cat /sys/class/fpga_manager/fpga0/state
(shows operating)

After this, I tried importing pynq and get the same “No devices found” error :confused:

In my device tree, I have:

fpga-full {
                compatible = "fpga-region";
                fpga-mgr = <0x0000000b>;
                #address-cells = <0x00000002>;
                #size-cells = <0x00000002>;
        };

… but nothing else seems related to the fpga_manager.

:thinking:

1 Like