Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Issues running in native mode with PLATFORM_DRM in Bullseye in RPI Zero W #2439

Closed
raysan5 opened this issue Apr 25, 2022 · 6 comments
Labels
platform: DRM/RPI DRM/Raspberry Pi platform

Comments

@raysan5
Copy link
Owner

raysan5 commented Apr 25, 2022

I'm trying to run raylib in native mode in RPI Zero W with latest RPI OS Bullseye and KMS driver. After installing required libraries (libgles2-dev, libgbm-dev, libdrm-dev), compilation works ok but program crashes on run:

pi@raspberrypi:~/raylib/examples $ ./core/core_basic_window
INFO: Initializing raylib 4.1-dev
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: No graphic card set, trying platform-gpu-card
INFO: DISPLAY: Failed to open platform-gpu-card, trying card1
INFO: DISPLAY: Failed to open graphic card1, trying card0
INFO: DISPLAY: Selected DRM connector mode 1280x720 (1280x720p@60)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1280 x 720
INFO:     > Screen size:  1280 x 720
INFO:     > Render size:  1280 x 720
INFO:     > Viewport offsets: 0, 0
INFO: GL: Supported extensions count: 52
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Broadcom
INFO:     > Renderer: VC4 V3D 2.1
INFO:     > Version:  OpenGL ES 2.0 Mesa 20.3.5
INFO:     > GLSL:     OpenGL ES GLSL ES 1.0.16
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: ETC1 compressed textures supported
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: RPI: Opening input device: /dev/input/event1 (mouse )
INFO: RPI: Opening keyboard device: /dev/input/event0
WARNING: RPI: Failed to open Gamepad device, no gamepad available
INFO: TIMER: Target time per frame: 16.667 milliseconds
ERROR: DISPLAY: Failed GBM to lock front buffer
Segmentation fault
pi@raspberrypi:~/raylib/examples $

The system is properly configured to run on native mode with Full KMS acceleration enabled:

sudo raspi-config > Advance Options > A2 GL Driver > G2 GL (Full KMS) OpenGL desktop driver with full KMS

Driver is properly enabled in /boot/config.txt

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers = 2
gpu_mem = 256

In case it is relevant, user permissions have been reviewed:

sudo usermod -a -G render pi

The output is the HDMI, it should be the default output and it seems to be detected correctly:

INFO: DISPLAY: No graphic card set, trying platform-gpu-card
INFO: DISPLAY: Failed to open platform-gpu-card, trying card1
INFO: DISPLAY: Failed to open graphic card1, trying card0
INFO: DISPLAY: Selected DRM connector mode 1280x720 (1280x720p@60)
INFO: DISPLAY: Device initialized successfully

The error is related to function gbm_surface_lock_front_buffer() -> ERROR: DISPLAY: Failed GBM to lock front buffer.

Any idea?

EDIT: useful info: https://symbolibre.org/graphics-acceleration-on-the-raspberry-pi-zero.html

@raysan5 raysan5 changed the title [core] Issues running in native mode with PLATFORM_KMS in Bullseye in RPI Zero W [core] Issues running in native mode with PLATFORM_DRM in Bullseye in RPI Zero W Apr 25, 2022
@raysan5 raysan5 added the platform: DRM/RPI DRM/Raspberry Pi platform label Apr 25, 2022
@gen2brain
Copy link
Contributor

Are you in GUI mode but switched to virtual terminal or plain console? You can try to switch boot mode from Desktop to CLI in raspi-config.

@raysan5
Copy link
Owner Author

raysan5 commented Apr 25, 2022

Additional info when trying to run glxinfo:

pi@raspberrypi:/dev/dri $ glxinfo
Error: unable to open display

@raysan5
Copy link
Owner Author

raysan5 commented Apr 25, 2022

@gen2brain No GUI mode, console only. I'm in RPI OS Lite with no desktop environment.

@gen2brain
Copy link
Contributor

gen2brain commented Apr 25, 2022

Ok, I don't think glxinfo is relevant here as there is no X.
Edit: you can install/compile https://github.com/kraxel/drminfo to get more info about drm.

@raysan5
Copy link
Owner Author

raysan5 commented Jul 10, 2022

It was reported by users it worked ok for them... but not for me. In any case, I'm closing the issue. Feel free to reopen if you find it and you face the same problem than me.

@raysan5 raysan5 closed this as completed Jul 10, 2022
@raysan5
Copy link
Owner Author

raysan5 commented Jul 10, 2022

After lot of investigation, one user in Discord found the solution to this issue!

In boot/config.txt, gpu_mem should be commented or set to a value lower than 256 (i.e 64 or 128)

In that case, it works as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: DRM/RPI DRM/Raspberry Pi platform
Projects
None yet
Development

No branches or pull requests

2 participants