64MP - Unable to capture still at full resolution for png encoding - failed to allocate buffer

Hi, @itsskin

Your problem also needs to set up a long timeout in the command.

Hello @yang
Thanks for reply. Unfortunately your suggestion doesn’t fix the problem and has no effect. I tried various timeouts from -t 10000 to -t 30000. I keep getting the same failure to allocate the memory. I’ve also tried different settings for the GPU memory from 32 through 76 with no change. There appears to be plenty of memory available:
/proc/meminfo says
CmaTotal: 524288 kB
CmaFree: 470684 kB
and dmesg:
[ 312.130289] cma: cma_alloc: linux,cma: alloc failed, req-size: 19422 pages, ret: -12
[ 312.130310] unicam fe801000.csi: dma_alloc_coherent of size 79552512 failed

I’ve also tried with no preview : -n
same result - failure to allocate buffer

I’m also seeing the random failures to capture a jpeg as @itsskin is seeing. Looks like the same thing is happening, but by repeatedly trying to capture, I eventually am able to capture a jpeg, including the dng, and yuv420. There just seems to a hangup preventing the buffer from being allocated even though the memory is available.

1 Like

Added timeouts, but still the same. Exactly the same behaviour.

1 Like

Hi, @JBG

You can try saving the image in jpg format.

Hello @yang
Thanks for response, but please see above: I can capture jpg (with random failures) .
However, I need a lossless encoding - png or bmp or rgb.
Capturing jpg doesn’t solve the issue.

1 Like

Hello, I am also experiencing the same problem. I can take jpg pictures fine at all resolutions but I cannot capture a png file at all.

1 Like

What’s being done to fix this?

1 Like

It’s impossible to use the product you sold. What’s the updates on this?

1 Like

@itsskin

For this issue, we are also currently communicating with the Raspberry Pi official.
https://forums.raspberrypi.com/viewtopic.php?t=339182

If you can, can you post your dmesg information as well.

What’s ETA? You said this a month ago.

@itsskin

Raspberry Pi official gave a very professional reply, you can refer to it. We will also test it in parallel.
https://forums.raspberrypi.com/viewtopic.php?t=339182

No practical solution there for me. Can you fix the bug with info they given you? What’s the ETA?

1 Like

Hi, I am also experiencing this problem. I would like to output images from the raw Bayer information but I am getting the same error messages related to memory and buffers on the Raspberry Pi 4GB. This is a big issue as it means the camera is not useable for the purpose I wish to use it for.

@itsskin @bigollie93

I’m sorry for your bad experience.

Have you tried this?

Adding "alloc_in_cma_threshold=16" in /boot/cmdline.txt seems to solve that,

We do not have a better solution to the cma problem for now.

We will try to solve it anyway. But there is no exact deadline for this.

1 Like

Hi there,
Thank you for this.

By adding the line stated above to the end of /boot/cmdline.txt I can now capture jpeg images with the raw flag to get a DNG image for the full sensor. This appears to be in 10bit format.

libcamera-still --width 9152 --height 6944 -r -o test.jpeg -q 100

Weirdly I can capture PNG images up to 9000x6000 pixels using the command below, but if I specify 9152x6144 I get the same error as before. This is on a 2GB pi 4 - I will test on a 4GB pi4 later on hopefully. This produces 9000x6000 png images - this seems to be in the full sensor format but I haven’t checked this fully.

libcamera-still --width 9000 --height 6000 -e png -o test.png

2 Likes

@bigollie93

It sounds like this does work, although not to your maximum expectations.

Hi there. Same problem on a 4GB RPI 4

After testing the new cmdline patch, the capture improves slighty and with simple commands.
Using other options such -k or -q=100, seems to leak memory never freed, although CMA reports on /proc/meminfo are fine.
Each time used, have to reduce capture resolution in order not to get “cannot allocate buffers”.
Setting resolution about 40Mp lets me get half dozen captures.

1 Like

@bigollie93

For saving png you can try my newly written example.

I took the data out and saved it with opencv and it did save it. And saving directly with picamera2 did not work for me.

1 Like

not sure if this is the exact right spot to share this, but i couldn’t save my images at full res, and sometimes id get the error that the camera wouldn’t start

and then

I Disabled touchscreen
(in /boot/config.txt add this line)
disable_touchscreen=1

and now it works for some reason?

1 Like

I can confirm that like @bigollie93 , i can only save PNGs from libcamera at 9000x6000