Contiguous memory

I’m running 3.0.1 on a 4x2 board. I issue the linux command

!cat /proc/meminfo | grep -I cms

from the jupyter notebook and it comes back with

CmaTotal:   131072 kB
CmaFree:     69596 kB

I read a previous post on this in this forum (Pynq & maximum allocatable memory (CMA)) which has to do with how to rebuild linux for more contiguous space. But I couldn’t resist asking claude.ai what it thinks, and here’s what it returned (see below). Seems quite a bit easier than rebuilding linux! Has anyone tried this, could it work? I can easily try it but thought I would ask if there’s any experience out there first. Thanks in advance!

Method 1: Edit the boot arguments directly

  1. Mount the boot partition (if not already mounted):

bash

   sudo mount /dev/mmcblk0p1 /mnt
  1. Edit the boot.py or uEnv.txt file (depending on your PYNQ setup):

bash

   sudo nano /mnt/uEnv.txt

Or look for boot configuration files in /boot/

  1. Add or modify the CMA parameter in the kernel command line:
   cma=256M

You can set this to whatever size you need (e.g., 256M, 512M, etc.). Common values are powers of 2.

Method 2: Modify extlinux.conf (more common on PYNQ)

  1. Edit the extlinux configuration:

bash

   sudo nano /boot/extlinux/extlinux.conf
  1. Add cma=XXXm to the APPEND line:
   APPEND root=/dev/mmcblk0p2 rw rootwait cma=256M

Method 3: Device Tree modification

For PYNQ systems, you might need to modify the device tree:

  1. Check your current device tree:

bash

   ls /boot/devicetree/
  1. You can either modify the bootargs in the device tree source or use the methods above.

Important Considerations:

  • Total RAM: Make sure you don’t allocate too much to CMA, as this reduces available system memory
  • Backup: Always backup your boot configuration before modifying
  • Reboot required: Changes take effect after rebooting
  • Verification: After reboot, check with cat /proc/meminfo | grep Cma to verify the change

The exact location and method depends on your specific PYNQ image, but the cma= kernel parameter is the standard way to control CMA size across all these approaches.

Hi @drewphysics

I remember trying this a while back, but couldn’t get it to work by changing the boot arguments in u-boot.

I didn’t try any other methods mentioned in your post though, so if you do find one that works, then please report back.