Arducam 64mp random *** failed to allocate capture buffers *** with added cma-512

@AnotherDredd

I will try your image.

Any news? It’s need a week.

Hi guys, I have a similar problem too, where the 64MP camera randomly showing failed to allocate buffers error. I am running it on a Raspberry Pi 4 with 4 GB RAM btw.
From what I read on the previous reply it seems like maybe the Raspberry Pi is not powerful enough to run for the full 64 MP resolution.
So my questions,

  1. Is anybody running this on a Raspberry Pi with 8 GB RAM? Are there still random failed to allocate buffers error?
  2. Someone said lowering the resolution might work. Anybody here have a resolution suggestion that are highest but works stably?

Seems not related to RAM but GPU so the problem is the same whatever model you got (got a 2gb and 4gb)
That explains the lower resolution improves the capture. Try 1280x720

320x200 is your choice on 64mp camera

Hi, have you tested the image?

Thanks

Arducam have updated the release to 0.0.9, but following github for this is awkward because there’s one “release” and cannot get notified. Do you have another way to get your updates notified?

By the way, tested 0.0.9 and now it captures 16MP by default, so you have to force 64MP with width and height. Log says preview leaks are fixed, but the buffer issue persist.

1 Like

Just deleted the image after 3 weeks. :expressionless:

@AnotherDredd

Sorry, I fixed an 11-day long vacation before.
The image you gave me I tried before and it doesn’t seem to work properly, I’ll give you a mirror I made for you to try tomorrow.

1 Like

@AnotherDredd

I think the other option is absolutely clean.

Directly burn the latest image of 2022-09-22.

Without installing anything, configure the config.txt file by adding at the bottom

dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=arducam-64mp

Reboot and use the command to save the image.

I also need to explain that the libcamera update is not mandatory. For most people, this will not affect their usage. However, in some special cases, we will recommend them to upgrade.

I would also like to say that we would love to make it work for every user as well.
I hope you understand that this is not a problem with the camera itself, the problem is with the cma and I will keep an eye on it and find more solutions.

Directly burn the latest image of 2022-09-22.

Without installing anything, configure the config.txt file by adding at the bottom

dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=arducam-64mp

Reboot and use the command to save the image.

I also need to explain that the libcamera update is not mandatory. For most people, this will not affect >their usage. However, in some special cases, we will recommend them to upgrade.

Thanks, will do.

I would also like to say that we would love to make it work for every user as well.
I hope you understand that this is not a problem with the camera itself, the problem is with the cma and I will keep an eye on it and find more solutions.

That was clear.

But in any case, Q&A about “the product as advertised” (you know, with all the features that are stated in the brochure) is mandatory.

Thanks again.

@AnotherDredd

Thank you for your understanding.
Thank you also for the advice you provided.

Sorry to jump in thread, but since I’ve encountered the same kind of issue I’d rather share my experience.

I use a Raspberry Pi 4 Model B 2GB RAM, with the latest bullseye OS (based on Debian 11) installed with Raspbery Pi imager.
I followed the instructions from Arducam documentation.

In the first place, I’m pretty sure trying to capture a jpeg at 64 MP with libcamera-still was giving me a 16 MP image resolution. However navigating the forum and trying distinct content for /boot/config.txt, it seems to finally capture a 64 MP jpeg with the following /boot/config.txt content:

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1
dtoverlay=vc4-kms-v3d,cma-512

[all]
dtoverlay=arducam_64mp

And the following command:

libcamera-still -t 5000 --viewfinder-width 4576 --viewfinder-height 3472 --width 9152 --height 6944 --nopreview --denoise cdn_off -o test.jpg --autofocus

64 MP viewfinder frame (--viewfinder-width 9152 --viewfinder-height 6944) fails to allocate buffers with the following output:

$ libcamera-still -t 5000 --viewfinder-width 9152 --viewfinder-height 6944 --width 9152 --height 6944 --nopreview --denoise cdn_off -o test.jpg --autofocus
[0:31:02.660908408] [2841]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3896-6019b245
[0:31:02.714240680] [2843]  WARN CameraSensorProperties camera_sensor_properties.cpp:174 No static properties available for 'arducam_64mp'
[0:31:02.714298505] [2843]  WARN CameraSensorProperties camera_sensor_properties.cpp:176 Please consider updating the camera sensor properties database
[0:31:02.735071052] [2843]  WARN RPI raspberrypi.cpp:1280 Mismatch between Unicam and CamHelper for embedded data usage!
[0:31:02.736131444] [2843] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[0:31:02.736408123] [2843]  INFO RPI raspberrypi.cpp:1404 Registered camera /base/soc/i2c0mux/i2c@1/arducam_64mp@1a to Unicam device /dev/media4 and ISP device /dev/media0
[0:31:02.737262565] [2841]  INFO Camera camera.cpp:1035 configuring streams: (0) 9152x6944-YUV420
[0:31:02.737766265] [2843]  INFO RPI raspberrypi.cpp:765 Sensor: /base/soc/i2c0mux/i2c@1/arducam_64mp@1a - Selected sensor format: 9152x6944-SBGGR10_1X10 - Selected unicam format: 9152x6944-pBAA
[0:31:02.944423332] [2843] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 4 buffers: Cannot allocate memory
[0:31:02.944533389] [2843] ERROR RPI raspberrypi.cpp:1029 Failed to allocate buffers
ERROR: *** failed to start camera ***

And trying to output PNG (with 16 MP viewfinder frame) also fails to allocate buffers as well:

$ libcamera-still -t 5000 --viewfinder-width 4576 --viewfinder-height 3472 --width 9152 --height 6944 --nopreview --denoise cdn_off -e png -o test.png --autofocus
[0:34:55.114626972] [2960]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3896-6019b245
[0:34:55.176934723] [2962]  WARN CameraSensorProperties camera_sensor_properties.cpp:174 No static properties available for 'arducam_64mp'
[0:34:55.176992253] [2962]  WARN CameraSensorProperties camera_sensor_properties.cpp:176 Please consider updating the camera sensor properties database
[0:34:55.197377956] [2962]  WARN RPI raspberrypi.cpp:1280 Mismatch between Unicam and CamHelper for embedded data usage!
[0:34:55.198388070] [2962] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[0:34:55.198656199] [2962]  INFO RPI raspberrypi.cpp:1404 Registered camera /base/soc/i2c0mux/i2c@1/arducam_64mp@1a to Unicam device /dev/media4 and ISP device /dev/media0
[0:34:55.199411650] [2960]  INFO Camera camera.cpp:1035 configuring streams: (0) 4576x3472-YUV420
[0:34:55.199940980] [2962]  INFO RPI raspberrypi.cpp:765 Sensor: /base/soc/i2c0mux/i2c@1/arducam_64mp@1a - Selected sensor format: 4624x3472-SBGGR10_1X10 - Selected unicam format: 4624x3472-pBAA
[0:35:00.700270037] [2960]  INFO Camera camera.cpp:1035 configuring streams: (0) 9152x6944-BGR888 (1) 9152x6944-SBGGR10_CSI2P
[0:35:00.724261634] [2962]  INFO RPI raspberrypi.cpp:765 Sensor: /base/soc/i2c0mux/i2c@1/arducam_64mp@1a - Selected sensor format: 9152x6944-SBGGR10_1X10 - Selected unicam format: 9152x6944-pBAA
[0:35:01.118908858] [2962] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 1 buffers: Cannot allocate memory
[0:35:01.119047904] [2962] ERROR RPI raspberrypi.cpp:1029 Failed to allocate buffers
ERROR: *** failed to start camera ***

I tried the alloc_in_cma_threshold=16 in /boot/cmdline.txt and reboot but it does not fix the issue. However I think I obtained my first 64 MP resolution JPEG image after I added this option, but it still works although I removed it and reboot so…

Because it seems to work as I need I’ll not touch the config anymore. But I’ll have to setup 3 more Raspberry Pi 4 Model B 8GB RAM (with more RAM) with 3 others 64 MP arducam. So I’ll see how it goes and let you know.

@khlekun

If you can save a jpeg image, then you can try the way I saved the png.

I will keep an eye on this issue.

By the way, I mentioned before that sd cards can also solve this problem. I’m currently testing a lot of sd cards, including different brands, so if this is a possible solution, I’ll add it below.

1 Like

@Edward thanks, I didn’t try the python code snippet for capturing the PNG yet.

To give you more feedback, I did reset my Raspberry Pi OS SD CARD.
Then:

sudo apt update && sudo apt upgrade

Then followed the instructions from Arducam documentation.

And at this point capturing a 64 MP was failing with this command:

libcamera-still -t 5000 --viewfinder-width 4576 --viewfinder-height 3472 --width 9152 --height 6944 --nopreview --denoise cdn_off -o test.jpg --autofocus

And the following error:

[0:31:02.944423332] [2843] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 4 buffers: Cannot allocate memory
[0:31:02.944533389] [2843] ERROR RPI raspberrypi.cpp:1029 Failed to allocate buffers

So I added alloc_in_cma_threshold=16 to /boot/cmdline.txt and reboot, and now it works.
If I remove it and reboot, it still works…

@khlekun

First of all, I’m glad this method worked for you.

I don’t know enough about cma at the moment to be able to explain it.
I’ll look into it more specifically later.

I’m running Raspberry Pi 4B 8GB, and I keep getting “failed to allocate buffers” when calling

camera_config = picam2.create_preview_configuration(raw=picam2.sensor_modes[4])

I have set cma-512 and alloc_in_cma_threshold=16. I can run khlekun’s command, but I actually can’t get any of the sensor_modes to work in picamera2…

help

1 Like

I think the problem could also be the “crop limits.” I just want to grab and save the picture libcamera displays

Just upgrade to Pi5 8GB.

I just tested RPI5 8GB bookworm LITE with dual arducam-64mp hawkeyes. The capture speed with max res 9152x6944 using libcamera-jpeg is ~3 seconds vs 5-7 seconds on RPI4.

  • on RPI4 it was not possible to use two cameras on one device at max res due to some IO issue couldnt make some buffer so i had to have two RPI4 one for each camera. RPI5 doesent have such issue.

the commands i had to run first:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh 
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps
sudo apt -y update && sudo apt -y upgrade

added this to /boot/config.txt
[all]
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=arducam-64mp

sudo reboot

just fyi for dual cam:

sudo nano /boot/config.txt
add following: 
[all]
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=arducam-64mp,cam0
dtoverlay=arducam-64mp,cam1

sudo reboot

for testing: 
libcamera-still --list-cameras 
libcamera-still --camera 0 
libcamera-still --camera 1 

for capture: 
libcamera-jpeg --camera 0 --width 9152 --height 6944 -o test0.jpg -n -t 1
libcamera-jpeg --camera 1 --width 9152 --height 6944 -o test1.jpg -n -t 1

I am bumping this topic again.

I have all the CMA memory stuff upped and everything, but i cannot take a full resolution photo in picamera2 in python.

Has anyone solved this with a 64mp on a RPI4?