Skip to content

Instantly share code, notes, and snippets.

@hemna
Created September 14, 2026 18:48
Show Gist options
  • Select an option

  • Save hemna/5bcdec987f91367a570d8a6c173e5bb1 to your computer and use it in GitHub Desktop.

Select an option

Save hemna/5bcdec987f91367a570d8a6c173e5bb1 to your computer and use it in GitHub Desktop.
direwatch.py Pi 5 pykms segfault fix
direwatch.py Pi 5 pykms segfault fix
The crash is reported at:
req.add_plane(plane, fb, crtc, None, (0, 0, mode.hdisplay, mode.vdisplay))
The framebuffer is created as XR24, but the plane is reserved for NV12:
fb = pykms.DumbFramebuffer(card, width, height, "XR24")
plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.NV12)
Reserve a plane compatible with XR24 instead. On pykms installations where
the enum is named XRGB8888, use this:
plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.XRGB8888)
Check the enum name on the Raspberry Pi:
python3 -c 'import pykms; print(dir(pykms.PixelFormat))'
Apply the same change in both the HDMI and DSI initialization branches.
The relevant corrected block is:
fb = pykms.DumbFramebuffer(card, width, height, "XR24")
crtc.set_mode(conn, fb, mode)
map = fb.map(0)
plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.XRGB8888)
Then test with Python fault handling enabled:
python3 -X faulthandler ./direwatch.py --display=hdmi --log=/run/direwolf.log
If the crash remains, collect these values from the Pi 5:
modetest -M vc4 -p
python3 -c 'import pykms; print(pykms.__file__)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment