Libcamera-still fails and camera cannot run on Raspberry Pi 4 with IMX477

Hi all, I’m stuck trying to get my camera working. libcamera-still keeps failing and I can’t get the camera to run with libcamera at all. I’ve tried a few things already but no luck. Hoping someone can point me in the right direction.

Sorry to hear that. To help, could you share a bit more about your setup? Which Pi model you’re using and what your config.txt looks like for the camera (camera_auto_detect and dtoverlay entries). Also, what commands have you tried so far?

I’m on a Raspberry Pi 4 Model B. In config.txt I’ve got:
camera_auto_detect = 0
dtoverlay=imx477
The commands I ran were vcgencmd get_camera and libcamera-still -t 0.

Thanks. Could you paste the full output from both commands? The errors at the end of libcamera-still are the important part, so include as much as you can.

Here’s what I got.

vcgencmd get_camera:
supported=0 detected=0, libcamera interfaces=0

And libcamera-still -t 0:
libEGL warning: DRI2: failed to authenticate
Made X/EGL preview window
[0:00:35.570427607] [1121] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+22-923f5d70
[0:00:35.643471200] [1134] INFO RPI raspberrypi.cpp:1476 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media0 and ISP device /dev/media2
[0:00:35.652908404] [1121] INFO Camera camera.cpp:1028 configuring streams: (0) 2028x1520-YUV420
[0:00:35.653335959] [1134] INFO RPI raspberrypi.cpp:851 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 2028x1520-SBGGR12_1X12 - Selected unicam format: 2028x1520-pBCC
terminate called after throwing an instance of ‘std::runtime_error’
what(): failed to import fd 20
Aborted

Thanks for the full log. A couple of things stand out. The camera itself is actually registering — you can see ‘Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a’ and the sensor format being selected. The failure happens later, when libcamera tries to set up the preview window. The ‘libEGL warning: DRI2: failed to authenticate’ followed by ‘failed to import fd 20’ points to the X/EGL preview rendering failing rather than a sensor detection problem.

Are you running this over SSH? If there’s no proper local display, the preview window can’t authenticate the DRI2 buffer import and the app aborts. If you can, connect the Pi to a monitor and run libcamera-still again. Or, if you’re on SSH and just want to capture an image, skip the preview entirely with:

libcamera-still -t 5000 -o -n test.jpg

The -o and -n flags write directly to a file and disable the preview, which avoids the X/EGL window path altogether.

I already set camera_auto_detect=0 and dtoverlay=imx477 as mentioned in the manual, so that part matches. But just to clarify — I’m actually connected to the Pi manually with a monitor, not over SSH. So it’s not an SSH/display issue in my case.

Ah, that changes things — my SSH assumption doesn’t match your setup, so the preview-window explanation probably isn’t the whole story. With the sensor registering in the logs but vcgencmd reporting supported=0 detected=0, the root cause isn’t conclusively determined yet. There’s a Raspberry Pi forum thread covering the libcamera/IMX477 issue that’s worth working through; it has more troubleshooting steps for this exact situation:

https://forums.raspberrypi.com/viewtopic.php?t=340101

To summarise where we are: the camera is detected by libcamera’s pipeline (the IMX477 registers fine), but capture still aborts on the preview/buffer import step. Since you’re connected locally to a monitor rather than over SSH, the SSH-only workarounds may not apply, so please check the thread above and post back with what you find.