User avatar
micksulley
Posts: 276
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Failed to reserve DRM plane

Sun Feb 11, 2024 4:09 pm

Pi5 running bookworm full desktop install, fully updated with Camera Module 3
I am trying to use this code which is based upon an example in the manual.

Code: Select all

#!/home/pi/.venv/bin/python
from picamera2 import Picamera2, Preview
import time
picam2 = Picamera2()
camera_config = picam2.create_preview_configuration()
picam2.configure(camera_config)
picam2.start_preview(Preview.DRM)
picam2.start()
time.sleep(2)
picam2.capture_file("test_headless.jpg")
If I boot up with a screen and keyboard connected and run the code from a terminal it works. If I boot up headless and connect via ssh from my desktop and run the code it fails with "Failed to reserve DRM plane". Here is the output -

Code: Select all

(.venv) pi@pi-porch-wi:~ $ ./test_headless.py 
[47:39:45.390878650] [22077]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
[47:39:45.399970862] [22080]  INFO RPI pisp.cpp:653 libpisp version v1.0.2 fa44a258644a 22-11-2023 (21:59:22)
[47:39:45.409863523] [22080]  INFO RPI pisp.cpp:1112 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx708@1a to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
[47:39:45.411382052] [22077]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
[47:39:45.420074252] [22083]  INFO RPI pisp.cpp:653 libpisp version v1.0.2 fa44a258644a 22-11-2023 (21:59:22)
[47:39:45.429983653] [22083]  INFO RPI pisp.cpp:1112 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx708@1a to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
[47:39:45.432144319] [22077]  WARN V4L2 v4l2_pixelformat.cpp:338 Unsupported V4L2 pixel format Y16 
[47:39:45.432173559] [22077]  WARN V4L2 v4l2_pixelformat.cpp:338 Unsupported V4L2 pixel format RGB6
[47:39:45.432179800] [22077]  WARN V4L2 v4l2_pixelformat.cpp:338 Unsupported V4L2 pixel format BGR6
[47:39:45.432186633] [22077]  WARN V4L2 v4l2_pixelformat.cpp:338 Unsupported V4L2 pixel format PC1M
[47:39:45.432834085] [22077]  INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-XBGR8888 (1) 1536x864-BGGR16_PISP_COMP1
[47:39:45.432930768] [22083]  INFO RPI pisp.cpp:1396 Sensor: /base/axi/pcie@120000/rp1/i2c@88000/imx708@1a - Selected sensor format: 1536x864-SBGGR10_1X10 - Selected CFE format: 1536x864-PC1B
Exception in thread Thread-2 (thread_func):
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/picamera2/previews/null_preview.py", line 29, in thread_func
    callback(picam2)
  File "/usr/lib/python3/dist-packages/picamera2/previews/drm_preview.py", line 75, in handle_request
    picam2.process_requests(self)
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1270, in process_requests
    display.render_request(display_request)
  File "/usr/lib/python3/dist-packages/picamera2/previews/drm_preview.py", line 66, in render_request
    self.render_drm(self.picam2, completed_request)
  File "/usr/lib/python3/dist-packages/picamera2/previews/drm_preview.py", line 145, in render_drm
    raise RuntimeError("Failed to reserve DRM plane")
RuntimeError: Failed to reserve DRM plane
How can I fix it?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15860
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Failed to reserve DRM plane

Sun Feb 11, 2024 4:50 pm

So you've asked it to run a preview on a DRM plane, but with no connected monitor. How do you expect that to work?

If you have no display, use

Code: Select all

picam2.start_preview(Preview.NULL)
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
micksulley
Posts: 276
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: Failed to reserve DRM plane

Sun Feb 11, 2024 4:56 pm

The example code in the manual for GUI users includes the line
picam2.start_preview(Preview.QTGL)
and says for non-GUI users change it to
picam2.start_preview(Preview.DRM)
which is what I did. Have I misunderstood that?

User avatar
micksulley
Posts: 276
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: Failed to reserve DRM plane

Sun Feb 11, 2024 5:00 pm

Just taken that line out and it works fine.
Thank you!

trejan
Posts: 7091
Joined: Tue Jul 02, 2019 2:28 pm

Re: Failed to reserve DRM plane

Sun Feb 11, 2024 5:07 pm

micksulley wrote:
Sun Feb 11, 2024 4:56 pm
and says for non-GUI users change it to
picam2.start_preview(Preview.DRM)
which is what I did. Have I misunderstood that?
Non-GUI not headless. Non-GUI would be the text console.

Return to “Graphics, sound and multimedia”