DMA hangs in attempt to make another xfOpenCV accel kernel


Based on the approach from PYNQ-Helloworld, I am trying to make another kernel to convert color space from BGR to YUYV. However, when I run the example, the DMA hangs with following messages:

KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-9-1f1665a48de6> in <module>
----> 1 run_kernel()
      2 yuyv_image = Image.fromarray(out_buffer)

<ipython-input-8-90325e168ee0> in run_kernel()
      3     dma.recvchannel.transfer(out_buffer)
      4     bgr2yuyv_converter.write(0x00,0x81) # start
----> 5     dma.sendchannel.wait()
      6     dma.recvchannel.wait()

/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/lib/ in wait(self)
    206         while True:
    207             error = + 4)
--> 208             if self.error:
    209                 if error & 0x10:
    210                     raise RuntimeError(

/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/lib/ in error(self)
    115         """True if DMA engine is in an error state
    116         """
--> 117         return + 4) & 0x70 != 0x0
    119     def start(self):

/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/ in read(self, offset, length, word_order)
    147         # Read data out
--> 148         lsb = int(self.array[idx])
    149         if length == 8:
    150             if word_order == 'little':


Here is my source code diff.

Other configuration are the same with resize example.

And this is my example notebook:


Hi @haipnh,

The constructor of the xf::cv::Mat expects the size to be passed from arguments rather than macros. This will also allow your kernel to be able to work on different image sizes.

Another thing is that you are changing the output type, I do not see the stream type changing neither the output data width converter.


1 Like

Thank you @marioruiz for your suggestions. I think the problem is how I handle the data stream. I am checking it now.

I do not see the stream type changing neither the output data width converter.

What does stream type mean?

This: void bgr2yuyv_accel(stream_t& src, stream_t& dst)

The dst stream does not match the data type you are using out of the xfMat2axis.

1 Like

Thank you, @marioruiz .

The problem with DMA was solved after applying these changes:

  • added arguments: int rows, int cols.
  • updated output data width from 24 to 48 and stream
    type for dst from
1 Like