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

@AnotherDredd

This is a state of affairs that is very complex, and we have no better solution for the time being. For this, I am sorry.

We will look at ways to address this issue, but there is no exact deadline.

So you sold us faulty product. Can i have a refund?

@itsskin

I’m sorry, The camera is not defective. It works very stable on usb3.0 + windows.

But on the Raspberry Pi, there are still some limitations.
We can guarantee that the camera has the possibility of large resolution, but this still needs to be explored by the developers.

if you feel dissatisfied, you can contact [email protected].

Sorry, but disagree.

The crowdfunding directly states that is for RPI.
Indeed even has some features publicized that depends directly on the libcamera implementation.
Using an USB3 testing platform as Q&A of a RPI product is somewhat wrong.

Have had asked just for a kind of solution like you said before.

Should need at least tested solutions to use the camera outside RPI enviroment, like an USB or PCI adapter **that supports the 64MP/108MP+ **, has full control, and lossless compression.

But seems you missed that part of the message :expressionless:

1 Like

“Just like these flagship phones, your Raspberry Pi now has an ultra high-res camera too. And just like them, your Pi can take still images at a breathtaking resolution (9152 x 6944) as well! Pi Hawk-eye is ready to make millions proud.”

What you are even taking about? What USB3 and windows has to do with it?

Not working RAW should have been mentioned in documentation. Did you even try to test the product? This error is caught after 5 mins real world use.

Nice, Sales Department referred to this thread without reading our inquiries.

@AnotherDredd @itsskin

I’m sorry, I think we’ve had some misunderstandings. I would like to reorganize my thinking.

I gave the windows + USB example as inappropriate, I changed the verification, turned off the media controller, and used v4l2-ctl to fetch raw data from video0 instead.

time v4l2-ctl --set-fmt-video=width=9152,height=6944,pixelformat=RG10 --stream-mmap --stream-count=-1

I took 10 minutes of raw data at the maximum resolution to verify that the camera is stable enough. The result is very stable, of course, you can test for longer periods of time.
6

Since the 64MP resolution is too large, the Raspberry Pi may not have been designed with such a large resolution in mind, which leads to some memory shortages when running such a large resolution on the Raspberry Pi (currently CMA can only be set to 512MB max).

We have minimized buffer usage in libcamera, but still, occasionally encounter memory allocation problems.

Through our guesses and tests by Raspberry Pi engineers, we found that this is due to CMA memory fragmentation, a problem currently officially recommended by Raspberry Pi as “Adding “alloc_in_cma_threshold=16” in /boot/cmdline.txt”. After our testing, it does solve the problem, but it is not a perfect solution, and there are still user reactions that cause problems.

I already tested alloc_in_cma_threshold=16 a week ago (64MP - Unable to capture still at full resolution for png encoding - failed to allocate buffer - #20 by AnotherDredd)

There’s a leak that drives to fail after half a dozen captures. I can test again and send you logs and video.
So, not stable enough.

Thanks for your clarification, thought.

adding the line does not solve the problem

Hi,

Have you made further testing?

alloc_in_cma_threshold=16

does not solve the problem. Keeps crashing after half a dozen captures.

@AnotherDredd

I tested without problems.

I did do a lot of testing before the product was released, on different versions of multiple devices, and found no such issues. This is a fairly unique situation and I am currently doing my best to do some testing. What I can confirm right now is that this phenomenon follows the SD card and replacing the SD may also solve the issue.

I am currently actively doing some debugging to see if I can fix some of the issues.

So far I have found a way to save the png format and I will sort it all out later.

I’ll also be starting a new thread later for all the methods, so hopefully we’ll be in active communication by then.

Hi,

Thanks, will prepare a brand new 32Gb SD and follow all the steps.

Would be useful if you could make an .img (.xz) (with DD or so) of your installation so We can test together over the same base, and then discard software (leaving only hardware revisions to evaluate)

@AnotherDredd

Installing the camera driver.

cd ~
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
./install_pivariety_pkgs.sh -d

Then set the cma-512.

Using the camera after reboot.

This is the only thing I did on my new system.

The offer to make a mirror is also a good one, but I have a lot of high priority work lately and I will make an updated mirror with all the camera environments in my free time.

Hi again.
Bought new SD Card (Sandisk Ultra 32Gb class 10), installed latest bullseye distro.
Applied cma-512 and alloc patch

RPI4b 4gb.

cat /proc/meminfo:

MemTotal:        3930668 kB
MemFree:         1849992 kB
MemAvailable:    3359072 kB
Buffers:           30184 kB
Cached:          1676932 kB
SwapCached:            0 kB
Active:           130460 kB
Inactive:        1702212 kB
Active(anon):       1356 kB
Inactive(anon):   222676 kB
Active(file):     129104 kB
Inactive(file):  1479536 kB
Unevictable:       84440 kB
Mlocked:              16 kB
HighTotal:       3264512 kB
HighFree:        1344844 kB
LowTotal:         666156 kB
LowFree:          505148 kB
SwapTotal:        102396 kB
SwapFree:         102396 kB
Dirty:               832 kB
Writeback:             0 kB
AnonPages:        210024 kB
Mapped:           276688 kB
Shmem:             98476 kB
KReclaimable:      39232 kB
Slab:              63076 kB
SReclaimable:      39232 kB
SUnreclaim:        23844 kB
KernelStack:        2800 kB
PageTables:        10300 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2067728 kB
Committed_AS:    2177440 kB
VmallocTotal:     245760 kB
VmallocUsed:        6140 kB
VmallocChunk:          0 kB
Percpu:              448 kB
CmaTotal:         524288 kB
CmaFree:          467728 kB

cat /boot/config.txt

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Disable compensation for displays with overscan
disable_overscan=1

[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

[all]
dtparam=i2c_vc=on
dtparam=i2c_arm=on
dtoverlay=arducam_64mp
dtoverlay=vc4-kms-v3d,cma-512

cat /boot/cmdline.txt

console=serial0,115200 console=tty1 root=PARTUUID=e46ea0e2-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles alloc_in_cma_threshold=16

Current resolution: 1920x1080
** Unable to capture anything on upper screen resolutions **

Loop script loopcapture.sh

#!/bin/bash

for ((i=1; i<100; i++));
do
libcamera-still -t 5000 -n -o ~/loopcapture/test_$i.jpg 2>&1 | tee -a loopcapture.log
done

First batch log (351kb): ERRORS: 53%
Second batch log (177kb): ERRORS: 33%

[1:08:34.633838535] [3110] e[1;32m INFO e[1;37mCamera e[1;34mcamera_manager.cpp:293 e[0mlibcamera v0.0.0+3730-67300b62
[1:08:34.699354326] [3115] e[1;33m WARN e[1;37mCameraSensorProperties e[1;34mcamera_sensor_properties.cpp:174 e[0mNo static properties available for 'arducam_64mp'
[1:08:34.699399417] [3115] e[1;33m WARN e[1;37mCameraSensorProperties e[1;34mcamera_sensor_properties.cpp:176 e[0mPlease consider updating the camera sensor properties database
[1:08:34.736366326] [3115] e[1;33m WARN e[1;37mRPI e[1;34mraspberrypi.cpp:1274 e[0mMismatch between Unicam and CamHelper for embedded data usage!
[1:08:34.736953615] [3115] e[1;31mERROR e[1;37mDelayedControls e[1;34mdelayed_controls.cpp:87 e[0mDelay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[1:08:34.737147255] [3115] e[1;32m INFO e[1;37mRPI e[1;34mraspberrypi.cpp:1398 e[0mRegistered camera /base/soc/i2c0mux/i2c@1/arducam_64mp@1a to Unicam device /dev/media0 and ISP device /dev/media3
[1:08:34.737934925] [3110] e[1;32m INFO e[1;37mCamera e[1;34mcamera.cpp:1029 e[0mconfiguring streams: (0) 4624x3472-YUV420
[1:08:34.738690652] [3115] e[1;32m INFO e[1;37mRPI e[1;34mraspberrypi.cpp:763 e[0mSensor: /base/soc/i2c0mux/i2c@1/arducam_64mp@1a - Selected sensor format: 4624x3472-SBGGR10_1X10 - Selected unicam format: 4624x3472-pBAA
[1:08:40.244254981] [3110] e[1;32m INFO e[1;37mCamera e[1;34mcamera.cpp:1029 e[0mconfiguring streams: (0) 9152x6944-YUV420 (1) 9152x6944-SBGGR10_CSI2P
[1:08:40.246186010] [3115] e[1;32m INFO e[1;37mRPI e[1;34mraspberrypi.cpp:763 e[0mSensor: /base/soc/i2c0mux/i2c@1/arducam_64mp@1a - Selected sensor format: 9152x6944-SBGGR10_1X10 - Selected unicam format: 9152x6944-pBAA
[1:08:40.646306134] [3115] e[1;31mERROR e[1;37mV4L2 e[1;34mv4l2_videodevice.cpp:1211 e[0;32m/dev/video0[14:cap]: e[0mUnable to request 1 buffers: Cannot allocate memory
[1:08:40.646449980] [3115] e[1;31mERROR e[1;37mRPI e[1;34mraspberrypi.cpp:1023 e[0mFailed to allocate buffers
ERROR: *** failed to start camera ***
...

Attached 7z’d img https://disk.yandex.com/d/EctPvn2Wh18AoA

@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