ERROR downloading bitstream PYNQ OS for ZCU102

Hello,

I’m trying to build a working pynq OS for ZCU102. I built an OS but get the following error when I try to program the FPGA (running as root):
[ 336.509329] fpga_manager fpga0: Error while writing image data to FPGA
[ 336.554434] fpga_manager fpga0: Error while writing image data to FPGA
OSError: [Errno 12] Cannot allocate memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “./driver/driver.py”, line 77, in
runtime_weight_dir = runtime_weight_dir
File “/home/xilinx/output_tfc-w1a1_ZCU102/driver/driver_base.py”, line 78, in init
super().init(bitfile_name, download=download, device=device)
File “/usr/local/lib/python3.6/dist-packages/pynq/overlay.py”, line 355, in init
self.download()
File “/usr/local/lib/python3.6/dist-packages/pynq/overlay.py”, line 419, in download
super().download(self.parser)
File “/usr/local/lib/python3.6/dist-packages/pynq/bitstream.py”, line 187, in download
self.device.download(self, parser)
File “/usr/local/lib/python3.6/dist-packages/pynq/pl_server/device.py”, line 770, in download
fd.write(bitstream.binfile_name)
OSError: [Errno 12] Cannot allocate memory

I can program the bitstream from the vivado hardware manager but not from the OS.
I’ve read many topics and try a lot a things without success.
Thanks for your help!

Nicolas

1 Like

Can you try adding the following into your device-tree? On boards with more than 2 GB of RAM it’s possible that the contiguous memory region occurs over the 2G boundary and then the PMU can’t access the bitstream.

	reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

		linux,cma {
			linux,cma-default;
			compatible = "shared-dma-pool";
			alloc-ranges = <0x0 0x0 0x0 0x7ff00000>;
			size = <0x0 0x20000000>;
			alignment = <0x0 0x2000>;
			reusable;
		};
	};
3 Likes

The line “alloc-ranges = <0x0 0x0 0x0 0x7ff00000>;” was missing in my device-tree.
It solve my problem!

Thanks you a lot!

Hello, i’m having the same problem that can you please tell me how to add the code to device-tree?

I’ve built PYNQ image v2.6.0 by

  1. copying board/ZCU104 to board/ZCU102, modified ZCU102.spec to point xilinx-zcu102-v2020.1-final.bsp
  2. Built PYNQ image with pre built bionic.aarch64.2.6.0.img
  3. succedded to boot
  4. download with overlay in PYNQ failed, OK with Vivado.

should i add “alloc-ranges = <0x0 0x0 0x0 0x7ff00000>;” in the path PYNQ/boards/ZCU102/petalinux-bsp/meta-user/recipes-bsp/device-tree/files/system-user.dtsi ??

or petalinux project created in the PYNQ/sdbuild/build/ZCU102/…/system-user.dtsi ??

The customs changes to the device tree are added here PYNQ/boards/ZCU102/petalinux-bsp/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

Mario

1 Like

Many thanks! :smiley:

finally, it works haha

1 Like

I have a similar issue where my bitstream can’t be written on the ZCU102.
I copied the petalinux-bsp/meta-user/recipes-bsp/device-tree/files/system-user.dtsi file from the ZCU104 folder as it already had the setting discussed here, but after remounting the new image I get the same error.
Do I need to do anything else apart from adding the file?

I generated the bitstream on my desktop and it clearly shows that it should fit the device.
Here’s my error code:

  File "/home/xilinx/zcu102/driver/driver_base.py", line 80, in __init__
    super().__init__(bitfile_name, download=download, device=device)
  File "/usr/local/lib/python3.6/dist-packages/pynq/overlay.py", line 355, in __init__
    self.download()
  File "/usr/local/lib/python3.6/dist-packages/pynq/overlay.py", line 419, in download
    super().download(self.parser)
  File "/usr/local/lib/python3.6/dist-packages/pynq/bitstream.py", line 187, in download
    self.device.download(self, parser)
  File "/usr/local/lib/python3.6/dist-packages/pynq/pl_server/device.py", line 770, in download
    fd.write(bitstream.binfile_name)
OSError: [Errno 12] Cannot allocate memory

Hi there,

You can check if that reserved_memory node got picked up by checking if it exists in the running devicetree

ls /sys/firmware/devicetree/base/reserved-memory/

I’d also recommend to only copy segments you want included from other device trees, rather than the whole thing as that might cause some unexpected issues. Not sure that’s what’s happening in this case.

Thanks
Shawn

1 Like

Thanks.
I’m not sure what I’m supposed to see here.
I can see linux,cma that was discussed in the added code along with #adress-cells, name, ranges, and #size-cells.

Unfortunately, even when only adding the needed file and lines the issue remains.

Thanks