Problem with pynq.allocate()

Hello everyone,

For an FPGA project using the PYNQ-Z1, I would like to use the allocate module which allow us to allocate memory used by the PL. I am currently using the image_v3.0.1 of PYNQ that I found on GitHub.

I follow this tutorial : Allocate — Python productivity for Zynq (Pynq) However when I run this follow line:

from pynq import allocate ← I got : " cannot import name ‘allocate’ "

First of all, I tried to solve this problem by my own. I noticed that there is not any folder or .py file which is called allocate. So I deducted that I should import buffer instead of allocate.

from pynq import bufferSucceed
a = buffer.allocate(222) ← I got : " No module named ‘pl_server’ "

To try to understand why it does not work, I try to import pl_server in a cell:

from pynq import pl_server
← I got :

Now I’m stuck, I try to search on the GitHub in olders version of PYNQ, but I did not find the “pydantic” module.

Please can you explain we how I can properly use the pynq.allocate function and module ?
Thanks you for your answer.

1 Like

Hi Era,

Could you clarify how you’re running your code, what’s your setup? Are you running these commands from a jupyter lab notebook or as a script? This could happen if for whatever reason you’re not in the pynq-venv, for reference: OSError: Root permissions required - #2 by skalade

Thanks
Shawn

Hi Shawn, thanks for your answer !

I run this commands on Jupyter lab notebook.

Does just doing a import pynq work?

from pynq import allocate is the correct way to call it, you don’t need to import buffer.

Can you give more info on how you setup your board to reproduce this? Are you running from a fresh sd card image or installed/ran anything else?

Hi Shawn,

I decided to restart from the begining. So what I do :

→ Formate SD CARD
→ Put PYNQ-Z1 image PYNQ - Python productivity for Zynq - Board v3.0.1 on it
→ Use Win32 disk imager to put the image in the empty SD Card (32gb)
→ Started the board and open Jupyter Notebook on my browser (chrome)

So now when I try to import allocate it works. I think the problem came from the original image that I put in the SD card wich wasn’t the latest one, but also the differents things that I tried to solve directly in the PYNQ folder.

However, if I follow the original tutorial of pynq.allocate : Allocate — Python productivity for Zynq (Pynq) I still have an other issue :

What should I do to make it works ?
Thanks for your answer !

@Era
Hey!!!
try allocating memory after giving an overlay to it
(like, you need this memory to store information for some design on the PL right !!)

1 Like

@sharan @skalade
Hey ! :grin:
It finally works, thank for your answers !

But now I have others problem with it (I don’t know if it is better to start a new topic for this).
When I run this follow cells :

It works correctly , but if I want to use the freebuffer() function like this :

My kernel stop to work and restart :

Also, I don’t understand why if I try to read the value of input_buffer in an other cell like this, even if I run the other one before, I have this error :

I noticed that if I put input_buffer in an other variable like this :
a = input_buffer, then print in an other cell :
print(a) ; It works , but I would like to understand why (If you can shed any light on this problem)

Thanks for your answer !

Hey!!
since you are freeing the ‘input_buffer’(erasing it completely)…I think the print is unable to find an object named ‘input_buffer’.

just curious…
what is the output when you ask it to ‘print(a)’?:
image

and
i guess, you are assigning input_buffer to ‘a’ before the ‘input_buffer.freebuffer()’ command…
I think, that is why you are able to see the buffer copies again…

Hello @sharan ! :grin:
One more time, thanks for your explications it help me a lot ! I clearly understand better how the allocate works.
Also I understand that because of the print of the empty buffer, all of my notebook stopped to work properly and that’s why when I try to run this follow lines :

image

It works. So unfortunately I didn’t made a big discovery.