Hi,
I have a problem with Dynamic Function eXchange on PYNQ.
PYNQ Version – 2.7.0
Vitis_HLS/Vivado Version – 2023.1
Board: Zynq® UltraScale + ™ RFSoC ZCU216
below is my code:
from pynq import Overlay, Bitstream, allocate, GPIO, MMIO
import pynq.lib.dma
from pynq.lib.dma import *
import numpy as np
DATA_OFFSET = 0x0000
overlay = Overlay("dpr.bit")
decouple = MMIO(0xA000_0000, 0x1000)
decouple_status = MMIO(0xA001_0000, 0x1000)
dma_in1 = overlay.dma_in1
dma_in2 = overlay.dma_in2
dma_out = overlay.dma_out
decouple.write(DATA_OFFSET, 0x0000_0001)
add_pb = Bitstream("add_pblock_partial.bit", None, True)
# print(repr(add_pb.binfile_name))
add_pb.download()
decouple.write(DATA_OFFSET, 0x0000_0000)
in1_data = allocate(shape=(4,), dtype=np.uint32)
in2_data = allocate(shape=(4,), dtype=np.uint32)
out_data = allocate(shape=(4,), dtype=np.uint32)
in1_data[:] = np.array([2, 4, 6, 100], dtype=np.uint32)
in2_data[:] = np.array([1, 2, 3, 70], dtype=np.uint32)
dma_in1.sendchannel.transfer(in1_data)
dma_in2.sendchannel.transfer(in2_data)
dma_in1.sendchannel.wait()
dma_in2.sendchannel.wait()
dma_out.recvchannel.transfer(out_data)
dma_out.recvchannel.wait()
print(out_data)
and it shows following error:
ValueError Traceback (most recent call last)
<ipython-input-12-8496ce35de51> in <module>
18 add_pb = Bitstream("add_pblock_partial.bit", None, True)
19 # print(repr(add_pb.binfile_name))
---> 20 add_pb.download()
21 decouple.write(DATA_OFFSET, 0x0000_0000)
22
/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/bitstream.py in download(self, parser)
185
186 """
--> 187 self.device.download(self, parser)
188
189 def remove_dtbo(self):
/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/pl_server/embedded_device.py in download(self, bitstream, parser)
576 if parser is None:
577 from .xclbin_parser import XclBin
--> 578 parser = XclBin(DEFAULT_XCLBIN)
579
580 if not bitstream.binfile_name:
/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/pl_server/xclbin_parser.py in __init__(self, filename, xclbin_data)
369 def __init__(self, filename="", xclbin_data=None):
370 self.ip_dict, self.mem_dict, self.clock_dict = \
--> 371 _xclbin_to_dicts(filename, xclbin_data)
372 self.gpio_dict = {}
373 self.interrupt_controllers = {}
/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/pl_server/xclbin_parser.py in _xclbin_to_dicts(filename, xclbin_data)
276 def _xclbin_to_dicts(filename, xclbin_data=None):
277 if xclbin_data is None:
--> 278 with open(filename, 'rb') as f:
279 xclbin_data = bytearray(f.read())
280 sections, xclbin_uuid = parse_xclbin_header(xclbin_data)
ValueError: embedded null byte
I’m pretty sure there’s no “null” in my filename:
print(repr("add_pblock_partial.bit"))
‘add_pblock_partial.bit’
And this Dynamic Function eXchange implementation is successfully on my PYNQ-Z2. So the bitstream should be correct.
By the way, if I comment #add_pb.download(), the code work properly.
Please help me solve this problem. Thanks!