RISC-V-On-PYNQ icon indicating copy to clipboard operation
RISC-V-On-PYNQ copied to clipboard

MemoryError: Unaligned write: data length must be multiple of 4

Open Arunachalam96 opened this issue 1 year ago • 5 comments

#critical Hi,

We followed all the steps for RISC-V setup on PYNQ Z2 board. But during the last step, in packaging the overlay, when we tried to run this code

`import numpy as np arg1 = np.array([4,2,3], np.uint32)

retval = overlay.tutorialProcessor.run(test, arg1)

if(retval != arg1[2]): print("Test failed!") else: print("Test passed!")`

it keeps throwing the following error:

MemoryError Traceback (most recent call last) ipython-input-6-2a0df1984344> in () 2 arg1 = np.array([4,2,3], np.uint32) 3 ----> 4 retval = overlay.tutorialProcessor.run(test, arg1) 5 6 if(retval != arg1[2]):

/home/xilinx/RISC-V-On-PYNQ/riscvonpynq/Processor.py in run(self, prog, *args) 209 210 """ --> 211 self.launch(prog, *args) 212 self.irq.wait() 213 return self.land()

/home/xilinx/RISC-V-On-PYNQ/riscvonpynq/Processor.py in launch(self, prog, *args) 228 """ 229 path = prog.build(self) --> 230 self._load(path, *args) 231 self._nreset() 232

/home/xilinx/RISC-V-On-PYNQ/riscvonpynq/Processor.py in _load(self, bin_path, *args) 247 raise RuntimeError('Processor already loaded!') 248 --> 249 pynq.PL.load_ip_data(self._memstr, bin_path) 250 251 binname = np.fromstring(bin_path + '\0', np.int8)

/usr/local/lib/python3.6/dist-packages/pynq/pl.py in load_ip_data(cls, ip_name, data, zero) 1549 mmio = MMIO(cls._ip_dict[ip_name]['phys_addr'], target_size) 1550 buf = bin_file.read(size) -> 1551 mmio.write(0, buf) 1552 if zero and size < target_size: 1553 mmio.write(size, b'\x00' * (target_size - size))

/usr/local/lib/python3.6/dist-packages/pynq/mmio.py in write(self, offset, data) 173 if length % 4: 174 raise MemoryError( --> 175 'Unaligned write: data length must be multiple of 4.') 176 buf = np.frombuffer(data, np.uint32, num_words, 0) 177 for i in range(len(buf)):

MemoryError: Unaligned write: data length must be multiple of 4.

How to solve this memory error?

Arunachalam96 avatar Jun 24 '23 17:06 Arunachalam96

were you able to solve the error @Arunachalam96? thanks.

thetushargoyal avatar Mar 11 '24 07:03 thetushargoyal

were you able to solve the error @Arunachalam96? thanks.

Hi,

Yes, I was able to solve the error. Referred this link for solution https://blog.csdn.net/qq_39229006/article/details/98598315

Kind regards, Arun.

Arunachalam96 avatar Mar 11 '24 13:03 Arunachalam96

Thanks for the reference @Arunachalam96. What version of Vivado were you using and whether on Windows or Linux? Also I'm stuck at compiling riscv-gnu-toolchain on PYNQ-Z2 Board.

thetushargoyal avatar Mar 11 '24 18:03 thetushargoyal

Thanks for the reference @Arunachalam96. What version of Vivado were you using and whether on Windows or Linux? Also I'm stuck at compiling riscv-gnu-toolchain on PYNQ-Z2 Board.

Vivado 2022.1 on Windows. What is the error that you are facing?

Arunachalam96 avatar Mar 11 '24 21:03 Arunachalam96

What is the error that you are facing? @Arunachalam96

I have successfully downloaded the latest riscv-gnu-toolchain on my PYNQ but since hours I have been stuck on a single line of output from make command inside it. How long did it take to build for you?

What's the version of your PYNQ vX.X img?

Also The tutorial notebooks layout some make commands to run after you have setup the project in Vivado.

make -C <Path-To-RISC-V-On-PYNQ>/riscvonpynq/picorv32/tut/ synth

How are you able to run make on Windows? I have installed make using Chocolatey on Windows, but when I run the make it gives me an error that 'PATH' command doesn't exist.

What's the work around?

thetushargoyal avatar Mar 12 '24 03:03 thetushargoyal