Two Hawkeyes on one Pi5, 4GB

I have two hawkeye 64MP cameras connected to a Pi5 with 4GB.

Both work fine in isolation, or together at 16MP, but when I run the two together at 64MP I get this error:

kernel: failed to map scatterlist
kernel: Error getting dmabuf scatterlist

I think this is just running out of CMA memory. I believe I’ve set this to its maximum - if I specify anymore it seems to default to a lower amount. So my /boot/firmware/config.txt looks like this:

[all]
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=arducam-64mp,cam0
dtoverlay=arducam-64mp,cam1
dtoverlay=arducam-64mp

The kernel confirms the CMA size on boot:

kernel: Memory: 3550064K/4190208K available (12352K kernel code, 2172K rwdata, 4076K rodata, 4288K init, 1083K bss, 115856K reserved, **524288K cma-reserved**)

So I’m wondering if there is anything else I can do to reduce memory usage/increase allocation without losing the 64MP resolution? I’ve already turned off the raw stream - using Picamera2, here’s my python code to configure the camera:

self.cam.start_preview(Preview.NULL)
config = self.cam.create_still_configuration(queue = False, buffer_count = 1, raw = None)

And here’s what the camera reports its full configuration as:

{'use_case': 'still',
 'transform': <libcamera.Transform 'identity'>,
 'colour_space': <libcamera.ColorSpace 'sYCC'>,
 'buffer_count': 1,
 'queue': False,
 'main': {'format': 'BGR888', 'size': (9152, 6944)},
 'lores': None,
 'raw': None,
 'controls': {'NoiseReductionMode': <NoiseReductionModeEnum.HighQuality: 2>,
              'FrameDurationLimits': (100, 1000000000)},
 'sensor': {},
 'display': None,
 'encode': None}

Note that I do later set the noise reduction to be ‘off’.

So I think I’m doing all I can to save memory. I’d be grateful for any other tips to enable taking two 64MP photos at the same time.

Cheers!

PI5 is using IOMMU not CMA as I have been told by @Dion. But im not 100% sure of it the IOMMU support might come with latest kernel upgrade that breaks arducam driver since kernel api changed. IOMMU can potientally map entire 4GB of your RAM. But there might be kernel limitation of 2GB - thats another rumor i have heard.

Nevertheless the issue you are facing is libcamera issue not PI5 or arducam issue. @Dion told me that they are working with libcamera people to resolve this. I was able to maximize CMA at ~906MB but i still wasnt able to capture two 64MP RGB888 images at the same time. Once i got to resolution 7445x6000 (thats around 48MP i think) it still worked but if i increased resolution to 7446x6000 the parallel capture didnt work anymore. Strangely the buffers at 7445x6000 res with RGB888 pixel format should total to 512MB.

https://forum.arducam.com/t/unable-to-request-2-buffers-cannot-allocate-memory-with-2-64mp-cameras/6143/15?u=henri)

Here is the ultimate guide to maximize CMA - make sure you follow each step meticilously.

https://forums.raspberrypi.com/viewtopic.php?p=2173125#p2173568 - how to maximize CMA on raspberry pi. since DMA_ZONE is limited to cpu+kernel+cma that can be max 1GiB but large resolution cameras need CMA memory.

Another solution for still capture at 64MP RGB888 is to give second camera delay ~1…1.5 seconds. its not exactly parallel but still faster then doing the pictures in series.

https://forum.arducam.com/t/unable-to-request-2-buffers-cannot-allocate-memory-with-2-64mp-cameras/6143/17?u=henri

U can also try setting pixel format to YUV420 - it takes less memory and then u can capture two 64MP (9152x6944) images at the same time.

1 Like

Thanks @henri - lots of interesting info!