Issue №3168 opened by project-owner at 2022-05-06 05:35:46
Hi,
The platform is Raspberry Pi 4B with Raspberry Pi OS Lite (Bullseye).
Here is the system configuration:
pygame 2.1.2 (SDL 2.0.14, Python 3.9.2)
Pygame 2 was installed this way:
sudo apt install libsdl2-2.0-0 libsdl2-ttf-2.0-0 libsdl2-image-2.0-0 libsdl2-mixer-2.0-0
pip3 install pygame
Then I ran the following commands in Python interpreter:
>>> import os
>>> import pygame
pygame 2.1.2 (SDL 2.0.14, Python 3.9.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> os.environ["SDL_VIDEODRIVER"] = "rpi"
>>> pygame.display.init()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pygame.error: rpi not available
>>> os.environ["SDL_VIDEODRIVER"] = "directfb"
>>> pygame.display.init()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pygame.error: directfb not available
>>> os.environ["SDL_VIDEODRIVER"] = "dummy"
>>> pygame.display.init()
>>> os.environ["SDL_VIDEODRIVER"] = "x11"
>>> pygame.display.init()
>>>
So the only drivers which I can use are 'dummy' and 'x11'. But 'dummy' cannot work with touchscreens and 'x11' cannot be used as this is OS Lite (without X11). I need to work with framebuffer but there is no video driver for that.
What should I do? Should I recompile SDL2 or Pygame? Where can I find the instructions for doing that - which flags to set to get the framebuffer functionality?
I didn't have this issue with Pygame 1.9.6 which was installed by apt-get. Now I install Pygame 2 using pip3 and it looks like everyone will face this issue.
Why do you feel the need to explicitly set a video driver?
The list of video drivers on the pygame website is not necessarily complete, see this list: https://wiki.libsdl.org/FAQUsingSDL# how_do_i_choose_a_specific_video_driver
pi@raspberrypi:~ $ python
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 2.1.2 (SDL 2.0.14, Python 3.9.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> pygame.display.init()
MESA-LOADER: failed to open vc4: /usr/lib/dri/vc4_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
failed to load driver: vc4
MESA-LOADER: failed to open kms_swrast: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
failed to load swrast driver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pygame.error: displayIndex must be in the range 0 - -1
Wait, which one is bullseye? The latest one? I think this is the same BS as on my Pi 3B+, where buster worked with rpi backend, but the one after doesn't. Your best bet would be to compile the latest SDL2 from source with proper KMSDRM support, (but rpi is deprecated in the latest SDL2 >= 2.0.20) or to downgrade to buster. There is not really anything PyGame can do here, this is about the way videocore works on pre-pi4 devices and the cluster**** that is dispmanx. You could blame the debian/raspbian people, or the wonky Pi HW architecture (this could all just work with Panfrost on a Mali GPU, but hindsight is 2020), or the SDL people for deprecating the rpi backend in favour of KMS DRM (can't blame them).
Raspberry Pi OS Lite
Release date: April 4th 2022
System: 32-bit
Kernel version: 5.15
Debian version: 11 (bullseye)
I've built SDL2 manually with directfb and kmsdrm video drivers:
./configure --enable-video-directfb --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-pulseaudio --disable-esd --disable-video-wayland
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic hidapi sensor power filesystem threads timers file misc locale loadso cpuinfo assembly
Assembly Math :
Audio drivers : disk dummy oss alsa(dynamic) sndio(dynamic)
Video drivers : dummy directfb(dynamic) kmsdrm(dynamic) opengl_es1 opengl_es2 vulkan
Input drivers : linuxev linuxkd
Enable virtual joystick APIs : YES
Using libsamplerate : YES
Using libudev : YES
Using dbus : YES
Using ime : YES
Using ibus : YES
Using fcitx : YES
Then I installed Pygame 2. I also attached the Waveshare 3.5" touchscreen and installed driver for that display. After the driver installation two framebuffer devices appeared: /dev/fb0 and /dev/fb1. I still cannot initialize the display:
>>> pygame.display.init()
commandline read: python
(*) Direct/Thread: Started 'SigHandler' (3835) [CRITICAL - OTHER/0] <8388608>...
~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.7.7 |~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) 2012-2015 DirectFB integrated media GmbH
(c) 2001-2015 The world wide DirectFB Open Source Community
(c) 2000-2004 Convergence (integrated media) GmbH
----------------------------------------------------------------
(*) DirectFB/Core: Single Application Core.
(*) Direct/Memcpy: Using libc memcpy()
(*) Direct/Thread: Started 'Fusion Dispatch' (3839) [MESSAGING - OTHER/0] <8388608>...
(!) DirectFB/fbdev/vt: K_MEDIUMRAW failed!
--> Operation not permitted
(!) DirectFB/Core: Could not initialize 'system_core' core!
--> A general initialization error occured
(!!!) *** UNIMPLEMENTED [fusion_dispatch] *** [fusion.c:3937]
^C(!) [SigHandler 845.329,702] ( 3835) Direct/Signals: --> Caught signal 2 (sent by the kernel) <--
(!) [SigHandler 845.329,874] ( 3835) Direct/Signals: --> -1
Segmentation fault
What happens if you force kmsdrm rendering path instead? Is your display not recognised again? If so, there is nothing we can really do from the pygame side, or the SDL side.
As for directFB, looks like a permisson error. Does it work when you run it as root? (Usual caveats apply, I know this is not a long-term solution).
I give up. I'll wait until major touchscreen makers (Waveshare, Adafruit etc) will make their displays working with the Raspberry Pi OS Lite (Bullseye) and Pygame 2. That will probably take another year. For now I rollback to the previous OS (Buster) and Pygame (1.9.2)
Issue №3168 opened by project-owner at 2022-05-06 05:35:46
Hi,
The platform is Raspberry Pi 4B with Raspberry Pi OS Lite (Bullseye). Here is the system configuration: pygame 2.1.2 (SDL 2.0.14, Python 3.9.2)
Pygame 2 was installed this way: sudo apt install libsdl2-2.0-0 libsdl2-ttf-2.0-0 libsdl2-image-2.0-0 libsdl2-mixer-2.0-0 pip3 install pygame
Then I ran the following commands in Python interpreter:
So the only drivers which I can use are 'dummy' and 'x11'. But 'dummy' cannot work with touchscreens and 'x11' cannot be used as this is OS Lite (without X11). I need to work with framebuffer but there is no video driver for that.
What should I do? Should I recompile SDL2 or Pygame? Where can I find the instructions for doing that - which flags to set to get the framebuffer functionality?
I didn't have this issue with Pygame 1.9.6 which was installed by apt-get. Now I install Pygame 2 using pip3 and it looks like everyone will face this issue.
Thanks!
Comments
*Starbuck5 commented at 2022-05-06 06:14:41*
Why do you feel the need to explicitly set a video driver?
The list of video drivers on the pygame website is not necessarily complete, see this list: https://wiki.libsdl.org/FAQUsingSDL# how_do_i_choose_a_specific_video_driver
kmsdrm may be what you want.
*project-owner commented at 2022-05-06 07:52:20*
Here is what happens if I don't specify a driver:
*project-owner commented at 2022-05-06 07:54:17*
*robertpfeiffer commented at 2022-05-07 13:44:04*
Wait, which one is bullseye? The latest one? I think this is the same BS as on my Pi 3B+, where buster worked with rpi backend, but the one after doesn't. Your best bet would be to compile the latest SDL2 from source with proper KMSDRM support, (but rpi is deprecated in the latest SDL2 >= 2.0.20) or to downgrade to buster. There is not really anything PyGame can do here, this is about the way videocore works on pre-pi4 devices and the cluster**** that is dispmanx. You could blame the debian/raspbian people, or the wonky Pi HW architecture (this could all just work with Panfrost on a Mali GPU, but hindsight is 2020), or the SDL people for deprecating the rpi backend in favour of KMS DRM (can't blame them).
*project-owner commented at 2022-05-07 19:29:39*
Bullseye is the latest OS version:
I've built SDL2 manually with directfb and kmsdrm video drivers: ./configure --enable-video-directfb --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-pulseaudio --disable-esd --disable-video-wayland
Then I installed Pygame 2. I also attached the Waveshare 3.5" touchscreen and installed driver for that display. After the driver installation two framebuffer devices appeared: /dev/fb0 and /dev/fb1. I still cannot initialize the display:
*robertpfeiffer commented at 2022-05-10 06:30:48*
What happens if you force kmsdrm rendering path instead? Is your display not recognised again? If so, there is nothing we can really do from the pygame side, or the SDL side.
As for directFB, looks like a permisson error. Does it work when you run it as root? (Usual caveats apply, I know this is not a long-term solution).
*project-owner commented at 2022-05-11 06:20:29*
I give up. I'll wait until major touchscreen makers (Waveshare, Adafruit etc) will make their displays working with the Raspberry Pi OS Lite (Bullseye) and Pygame 2. That will probably take another year. For now I rollback to the previous OS (Buster) and Pygame (1.9.2)