Raspberry Pi Zero 2W and libcamera

Thanks to the Balena team’s libcamera efforts 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 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, 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.

3 Likes