0
\$\begingroup\$

Situation

I'm running a driver code driver.cc on the FPGA board (PYNQ-Z1) but it gives an error in the middle of the code where the code calls to cma_alloc(size, cached) function, which returns a NULL pointer after a few runs. I believe this is because the board doesn't have enough memory because the board has only 512 MB of DDR3.

To be more specific about the environment:

  • The driver.cc is running on the processing system (PS) of the board, which is an ARM Cortex-A9 processor.
  • The OS Linux is booted from a microSD card (8 GB) loaded with image from this GitHub repository.

Question

What are some possible ways to solve this problem, or to increase the memory?


Note: I have read a similar question before but the answers weren't quite clear to me. Also, to be more specific and to answer duskwuff's comment in the previous question, I have includeed information about the PS/PL and the OS setup environment.

\$\endgroup\$
  • 1
    \$\begingroup\$ Could you use the RAM more efficiently? For example, the program might be using 4 bytes for some value where 1 byte would be enough. Or perhaps there are some memory deallocations missing. \$\endgroup\$ – Andrew Morton Feb 11 at 21:03
  • 1
    \$\begingroup\$ How much memory are you trying to allocate? \$\endgroup\$ – duskwuff Feb 11 at 21:04
  • \$\begingroup\$ Back in the olden days, you could sometimes see something like this. I suppose doing that with the kind of packages used now is a little impractical, though. \$\endgroup\$ – Hearth Feb 11 at 21:24
  • \$\begingroup\$ How much memory are you trying to allocate, in total (Not just this call)? \$\endgroup\$ – immibis Feb 11 at 21:31
  • 2
    \$\begingroup\$ 512MB with embedded Linux is pretty good, really. I would recommend you first look for memory leaks, but your main problem is you are trying to get cma memory repeatedly - hard to do over time. I recommend if you really want to use CMA, do it once and reuse, or use the device tree to reserve a block of memory out of the kernel - a so-called memory hole. especially if you HAVE to try and get coherent memory more than once. If you really want cma, do it once as soon as possible. But safest is memory hole, in my opinion. wrote a dma driver yesterday using this method \$\endgroup\$ – johnnymopo Feb 11 at 21:36
0
\$\begingroup\$

The ram on the PYNQ-Z1 is a 256x16 module DDR3. They do make a 512x16 module in the same package. I haven't torn through the datasheet to see if they are directly compatible, but it looks close at first glance. If the chips are indeed compatible, you would need to find a BGA rework place to do the work of replacement.

enter image description here

PYNQ-Z1 DDR3 Schematic enter image description here

It would be much easier to adjust your algorithm to use less memory, if you can store data (with slower access times) then store it on the SD card.

Another avenue would be to use a slower serial RAM with the GPIO pins. But also not recommended, as you would have to find a compatible RAM (Arduino shields may be compatible with the PYNQ just by glancing at it and they do have serial RAM shields) You would have to install the shield and write a hardware driver for it, then map it into your program memory.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.