[Feature request] GPU driver for Raspberry Pi 4
Enable v3d (or vc4?) driver support for Raspberry Pi 4 to provide /dev/dri access, required for graphical applications (e.g., Flutter apps via flutter-pi) running in containers with /dev/dri mapped as a volume.
Proposed Implementation:
- Customize the kernel with
CONFIG_DRM_V3D=min config-arm64. - Develop a module/extension here to implement the v3d driver.
Note: These are initial estimates with limited knowledge of this codebase and may require further investigation/validation.
That's a good plan, you can see recent PR to pkgs/extensions which add nfsd driver as an example.
Tried implementing it. It still needs testing. I'm currently trying to build a custom image for testing the v3d functionallity.
Relevant pkgs PR: https://github.com/siderolabs/pkgs/pull/1182 Relevant extensions PR: https://github.com/siderolabs/extensions/pull/643
I can't seem to get the GPU to work (getting /dev/dri to be available). There is probably and hopefully something small I'm looking over.
I enabled the usage of vc4 and v3d as a kernel module in the kernel in the pkgs repository:
Relevant pkgs fork: https://github.com/jvanthienen-gluo/pkgs
# kernel/build/config-arm64
CONFIG_DRM_V3D=m
CONFIG_DRM_VC4=m
CONFIG_DRM_VC4_HDMI_CEC=y
Secondly I created an extension that implements these 2 kernel modules:
Relevant extensions fork: https://github.com/jvanthienen-gluo/extensions
kernel/drivers/gpu/drm/v3d/v3d.ko
kernel/drivers/gpu/drm/vc4/vc4.ko
Then I looked into the sbc-raspberrypi overlay for overlaying the correct firmware files:
Relevant repository: https://github.com/siderolabs/sbc-raspberrypi
When enabling dtoverlay=vc4-kms-v3d, I can see that the output of the display has the correct colors, so this does something. But /dev/dri isn't available either.
There is one thing I noticed that may need further investigation: There are no vc4 or v3d kernel logs. Not even with a kernel with build-in vc4 and v3d.
if compiled as modules it needs to be loaded explicity via .machine.kernel.modules
Good point, I didn't do that yet. But that doesn't explain why running a kernel with build-in vc4 and v3d doesn't work either?
Build-in kernel config:
# kernel/build/config-arm64
CONFIG_DRM_V3D=y
CONFIG_DRM_VC4=y
CONFIG_DRM_VC4_HDMI_CEC=y
I’m working on this system extension for Talos Linux to add dtoverlay=vc4-kms-v3d to the Raspberry Pi’s config.txt file for GPU support. What’s the recommended approach for implementing this as an extension? Would it be best to include a script to modify the boot partition on first boot (I don't like this approach), or is there a more integrated method of overlaying/appending to the config.txt file? The boot partition is harder to modify I think from a System Extension standpoint? Any advice or examples would be greatly appreciated. Thanks!
config.txt is managed by https://github.com/siderolabs/sbc-raspberrypi, and it even supports customizing it on image build.
Yes that is correct, I currently do the following in the profile for the imager, and this works:
...
overlay:
name: rpi_generic
image:
imageRef: ghcr.io/siderolabs/sbc-raspberrypi:v0.1.3
options:
configTxtAppend: dtoverlay=vc4-kms-v3d
...
However, I don't see how I translate it to an system extension, to enable/disable this config line (as a system extension).
You can't do that as a system extension, only via the SBC repo. You might add a flag "gpu: true" or something more simple, but SBC doesn't know about system extensions and vice versa.
Ok I see, so it's on the image level only, no way around it? Maybe it's a better idea to create 2 targets for the raspberry pi 4 then? One without the GPU support and one with GPU support? So a user can select from within Sidero Labs Omni Raspberry Pi 4 Model B and Raspberry Pi 4 Model B GPU and can then enable/disable the system extension or have this be integrated by default on the GPU image? I'm just thinking off the top of my head.
Right now there's no such support. I think documentation might be a better way for now, later on we can think of making "packages" which bundle options and extensions, for example.
Alright, firmware wise this is indeed fine for now. Only issue is that a user cannot (conveniently) add the extra overlay options from within Omni and only via the Imager or Image Factory itself.
But a user can currently create a suitable image when copying the kernel parameters from Omni and using configTxtAppend: dtoverlay=vc4-kms-v3d in the Imager or Image Factory.
I will mention this in the description of the System Extension. Documentation will be added here as an extra example of a Pi 4 image with GPU + System Extension?
Probably here.
Update: Relevant pkgs PR: https://github.com/siderolabs/pkgs/pull/1196 Relevant extensions PR: https://github.com/siderolabs/extensions/pull/659
Relevant docs PR: https://github.com/siderolabs/talos/pull/10622