# Raspberry Pi Zero 2W and libcamera

**URL:** <https://forums.balena.io/t/raspberry-pi-zero-2w-and-libcamera/357455>\
**Category:** Show and Tell\
**Created:** [May 6, 2022, 1:41pm UTC](https://forums.balena.io/t/raspberry-pi-zero-2w-and-libcamera/357455 "2022-05-06T13:41:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jack\_s](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jack\_s](https://forums.balena.io/u/jack_s)\
**Post date:** [May 6, 2022, 1:41pm UTC](https://forums.balena.io/t/raspberry-pi-zero-2w-and-libcamera/357455/1 "2022-05-06T13:41:44Z")

</div>

Thanks to [the Balena team’s libcamera efforts](https://forums.balena.io/t/rpi3-bullseye-image-and-libcamera/352214/14) I am running a libcamera-based camera stack on the 64-bit balenaOS for Raspberry Pi Zero 2W. I do have to make some device configuration changes for each new device. I thought I would put those changes in a thread here for future reference.

Right now, the devices are running balenaOS 2.94.4 with supervisor \>= 13.0.0. In the fleet-wide configuration, I have to change the “Define DT Overlays” to `"vc4-fkms-v3d"` and add a custom configuration `BALENA_HOST_CONFIG_camera_auto_detect` set to 1. Also, this is unrelated to libcamera but I’ve noticed that setting custom configuration `RESIN_SUPERVISOR_UPDATE_STRATEGY` to `kill-then-download` fixes some issues I was having with release updates failing because of high cpu/mem usage.

Once I provision a new device, I have to go in to that device’s configuration and delete the “Define device GPU memory in megabytes” (`gpu_mem`) setting. For Zero 2W, this defaults to 16 when a device is provisioned, regardless of whether the configuration is set at the fleet level. As far as I (a person unaffiliated with Raspberry Pi and Balena) can tell, the `gpu_mem` variable is no longer used in the libcamera stack. In earlier versions of [Raspberry Pi libcamera documentation](https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-and-libcamera-apps) there was some mention of the `gpu_mem` variable and that it needed to be \>= 128MB. That was taken out of the documentation but I can’t find a version history of that page so I can’t show the change. I can link to a person who I think is an active developer for Raspberry Pi (the corporation) on libcamera and libcamera-adjacent projects. In [a Picamera2 issue comment](https://github.com/raspberrypi/picamera2/issues/67#issuecomment-1103828031), the Github user `davidplowman` (who is also the top contributor to that repository) says,

> …do you mean you’re setting gpu\_mem in your /boot/config.txt? We generally advise against that these days as not very many things use gpu\_mem any more. Some legacy software may still use it, but unless you know you’re doing that it’s probably worth seeing if you can remove it…

On the Zero 2W running BalenaOS 2.94.4 specifically, an OV5647 camera (Raspberry Pi camera v1.3) is not recognized on a newly-provisioned device. The command `libcamera-hello --list-cameras -n -v` returns “No cameras available!”. If the device’s `gpu_mem` configuration (which overrides the fleet-wide setting) is deleted, the camera is detected and that command returns the detailed information about the camera. This was observed with the configurations `dt_overlays` and `camera_auto_detect` set to `"vc4-fkms-v3d"` and `1`, respectively. I haven’t tested what changes when those configurations aren’t set.

I’ll try to keep this thread updated with my notes on libcamera in BalenaOS. Let me know if you have any. Thanks.
