Hello,
I’m running balenaOS with kernel 6.12.61-v8-16k on a Raspberry Pi 5 with an IMX477 camera. I need to switch between picamera2 configurations at runtime (to change sensor mode/resolution). On RPi OS 6.6.74+rpt-rpi-v8 this works with a ~0.3s delay. On balenaOS it requires ~8 seconds, and anything shorter produces:
ERROR V4L2 v4l2_videodevice.cpp:1825 /dev/video12[23:cap]: Failed to queue buffer 0: Invalid argument
After investigation, the root cause appears to be a kernel driver issue. Running dmesg immediately after a config switch shows:
WARNING: CPU: 2 PID: 88153 at drivers/media/v4l2-core/v4l2-subdev.c:457 call_s_stream+0xe8/0x110 [videodev]
__vb2_queue_cancel+0x38/0x2e0 [videobuf2_common]
vb2_core_streamoff+0x2c/0xe0 [videobuf2_common]
This indicates vb2_queue_cancel is calling s_stream(0) on the IMX477 subdev while buffers are still in flight, leaving the sensor in an unknown state and forcing a full cold I2C reinit (~8s) on every restart.
Comparing the rp1_cfe driver between the two systems confirms they are built from different source:
-
balenaOS
6.12.61-v8-16k:srcversion: 585B4BF4EC144D534980F63 -
RPi OS
6.6.74+rpt-rpi-v8:srcversion: 0D2B276CED3198F6A45B339
The RPi OS kernel is built from the RPi foundation’s rpi-6.6.y branch which contains Pi-specific fixes for rp1_cfe teardown that were never upstreamed to mainline. BalenaOS’s 6.12.61 appears to be built from vanilla mainline and is missing these patches.
Could balenaOS switch to building from github.com/raspberrypi/linux rpi-6.12.y branch (which the RPi foundation actively maintains with these fixes) rather than vanilla mainline 6.12.y?