ryan4yin / nixos-rk3588

Minimal NixOS running on RK3588/RK3588s based SBC(Orange Pi 5 Plus, Orange Pi 5, Rock 5A, etc)
MIT License
152 stars 28 forks source link

OpenGL can't be installed due to panfork/mesa repository absence. #32

Open HeroBrine1st opened 7 months ago

HeroBrine1st commented 7 months ago

Hi

First, the actual issue:

This happens when you add hardware.opengl.enable = true to system configuration.

error: builder for '/nix/store/xy5dp5aggr6i803ib5z5vc2895hrwbj1-source.drv' failed with exit code 1;
       last 7 log lines:
       >
       > trying https://gitlab.com/api/v4/projects/panfork%2Fmesa/repository/archive.tar.gz?sha=120202c675749c5ef81ae4c8cdc30019b4de08f4
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       >   0    35    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > error: cannot download source from any mirror
       For full logs, run 'nix log /nix/store/xy5dp5aggr6i803ib5z5vc2895hrwbj1-source.drv'.
error: 1 dependencies of derivation '/nix/store/gvhj13xj5slchablw89y28gfmpbwzk3y-mesa-panfork-23.0.0-panfork.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2iilbimbzvnby4k82csvb73a7g4ibkxw-opengl-drivers.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mzy6qgbn8za6hjfbj4f8kzg0hjpzb9z7-nixos-tmpfiles.d.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wzpan2h56gnh04ppfcxg30zqqaf2rwlj-tmpfiles.d.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mzz37bhkxq7sds45r6gxp97z82b2l97r-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/l3d3mq3vfh2dk9ajad29phgvlg0ahs93-nixos-system-opi5-23.11.20240301.79baff8.drv' failed to build

Aforementioned file is required here:

https://github.com/ryan4yin/nixos-rk3588/blob/349f39dcaafeb41250544bcc066db8668a7762ce/modules/boards/base.nix#L70-L79

To be clear, I use this flake as input for my flake and installed NixOS directly on SSD.

I.e. I installed it like that ```nixos { description = "NixOS configuration"; inputs = { unstable.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-23.11"; nixos-rk3588.url = "github:ryan4yin/nixos-rk3588?rev=349f39dcaafeb41250544bcc066db8668a7762ce"; }; outputs = { nixpkgs, nixos-rk3588, ... }: let # using the same nixpkgs as nixos-rk3588 to utilize the cross-compilation cache. inherit (nixos-rk3588.inputs) nixpkgs; system = "aarch64-linux"; in { nixosConfigurations = { opi5 = nixpkgs.lib.nixosSystem { inherit system; specialArgs = { rk3588 = { inherit nixpkgs; pkgsKernel = import nixpkgs { inherit system; }; }; }; modules = [ nixos-rk3588.nixosModules.orangepi5.core # nixos-rk3588.nixosModules.orangepi5.sd-image ./system/configuration.nix ./system/hardware-configuration.nix ]; }; }; }; } ``` And configuration/hardware configuration is just like on flakeless system. (P.s. I'm new to NixOS, I have been installing this flake for 2 days (mostly due to 5 SD cards that have died in process) but it does work normally for my "home enterprise")

Second, my background research about this issue

Looks like panfork/mesa is gone without any information about that. After two days of searching I found this PR which explains almost everything.

Basically, panfork/mesa is gone due to personal nature of its maintainer. Also, AUR package mesa-panfork-git was available yesterday but is deleted today. Looks like panfork removal is just started so that I'm first to notice it.

There's also tsukumijima/libmali-rockchip that is mentioned in jellyfin PR. Some parts of it are probably needed for this flake to work with mainline Mesa, because Mesa probably already supports it. Again, probably - I'm a total noob in such hardware. I simply got excited that there's a working ffmpeg included in nightly jellyfin and now I'm frustrated.

And also there's a soft fork of panfork/mesa on github. I don't trust that and I'm honestly pretty suspicious of this fork, but seems like it is the same exact code and you can swap it clean and it'll work.

I leave this for other people's time sake for now.

HeroBrine1st commented 6 months ago

Mali G610 is just landed to Mesa 24.1. Probably we can go without panfork after nixpkgs have mesa 24.1.

If someone is less lazy than me to get their server Orange Pi from under the table or already have long enough HDMI cable, try hardware.opengl.package = lib.mkForce pkgs.mesa after Mesa 24.1 lands to nixpkgs. I'm going to test it too, but I probably will be postponing it until the sun dies.

This issue will be avoided (because panfork is not used), so you'll be sure that it uses mainstream mesa.

UPD: Actually, Mesa 24.1 is experimental, so we wait for 24.1.1 :-( Or override src and build locally

HeroBrine1st commented 5 months ago

Mesa 24.1.1 is just landed to unstable channel. I did no tests though.

HeroBrine1st commented 5 months ago

I did some tests. Using X11 forwarding, I got "Error: couldn't get an RGB, Double-buffered visual x11 forwarding" for glxgears.

Then I got OPi 5 on the table and did proper tests with proper configuraton. Got highly distorted image (green rectangle of 1/3 screen size on bottom, rendered picture stretched like on three monitors with single-pixel horizontal gaps filled with pixels from other regions and skipped pixels on vertical, making text highly distorted and unreadable), otherwise FPS was "ok". I took a screenshot, but it looks normal.

I did not see any hardware acceleration. There was no animations, and GNOME disables them when it falls back to software, so it obviously skipped it. I think the reason behind that is linux version requirement (6.6 minimum iirc), but I can't confirm that (no dmesg messages, nothing).

Could someone with panfork-mesa and hardware accelerated DE share their configuration? And it would be good if you confirm that x11 forwarding with glxgears works, because I'd rather not move my opi5 again.

I'll also probably keep and eye on armbian folks. Probably. I don't need OpenGL, so I did all that from pure curiosity.

I use UEFI btw, in device tree mode as said in UEFI.md.

UPD: A week passed, and I realized that the "proper configuration" used old mesa 24.0.7. I forgot about flake.lock. What a shame.

HeroBrine1st commented 4 months ago

I tested again:

{ pkgs, lib, ... }: {
  hardware.graphics.enable = true;
  hardware.graphics.package = lib.mkForce pkgs.mesa.drivers;
  environment.systemPackages = [
    pkgs.mesa-demos
  ];

  services.xserver.enable = true;
  services.xserver.videoDrivers = [ "panfrost" ];
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
}

This time mesa was 24.1.1 (I even ran nix flake update on target host to confirm that), and I also added panfrost driver (services.xserver.videoDrivers). Still stretched image, so I didn't even log in via gdm as it is obvious panfrost is not loaded. dmesg | grep panfrost still shows no output, even after modprobe panfrost.

Also nixpkgs deprecated hardware.opengl in favor of hardware.graphics, but this shouldn't be an issue.

UPD: Panthor driver is also required - we don't have it in our kernel.

phaitonican commented 1 month ago

Armbian Kernel does provide panthor. I enabled it with kernel config, but its a module so I think also modprobe just work if compiled as module. but hyprland somehow not start even with newest mesa (using unstable channel)

dmesg | grep drm

[    9.289319] OF: fdt: Reserved memory: failed to reserve memory for node 'drm-logo@0': base 0x0000000000000000, size 0 MiB
[    9.289347] OF: fdt: Reserved memory: failed to reserve memory for node 'drm-cubic-lut@0': base 0x0000000000000000, size 0 MiB
[   11.687639] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp0 assign plane mask: Cluster0 | Esmart0[0x5], primary plane phy id: Cluster0[0]
[   11.687684] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp1 assign plane mask: Cluster1 | Esmart1[0xa], primary plane phy id: Cluster1[1]
[   11.687717] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp2 assign plane mask: Cluster2 | Esmart2[0x140], primary plane phy id: Cluster2[6]
[   11.687749] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp3 assign plane mask: Cluster3 | Esmart3[0x280], primary plane phy id: Cluster3[7]
[   11.687989] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] Esmart0-win0 as cursor plane for vp0
[   11.688162] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] Esmart2-win0 as cursor plane for vp2
[   11.688219] [drm] failed to init overlay plane Cluster0-win1
[   11.688281] [drm] failed to init overlay plane Cluster1-win1
[   11.688299] [drm] failed to init overlay plane Cluster2-win1
[   11.688362] [drm] failed to init overlay plane Cluster3-win1
[   11.708230] rockchip-drm display-subsystem: bound fdd90000.vop (ops 0xffff80000954e770)
[   11.713345] rockchip-drm display-subsystem: bound fde80000.hdmi (ops 0xffff800009566c38)
[   11.714672] rockchip-drm display-subsystem: bound fde50000.dp (ops 0xffff80000956a068)
[   11.716211] rockchip-drm display-subsystem: failed to parse loader memory
[   11.721380] [drm] Initialized rockchip 4.0.0 20140818 for display-subsystem on minor 0
[   11.770560] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] Update mode to 1920x1080p60, type: 11(if:HDMI0, flag:0x0) for vp0 dclk: 148500000
[   11.771158] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] dclk_out0 div: 0 dclk_core0 div: 2
[   11.771752] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] set dclk_vop0 to 148500000, get 148500000
[   11.822133] rockchip-vop2 fdd90000.vop: [drm:vop2_wait_power_domain_off] *ERROR* wait pd0 off timeout power_ctrl: 0x0
[   11.915820] rockchip-drm display-subsystem: [drm] fb0: rockchipdrmfb frame buffer device
[   12.031698] [drm] Initialized rknpu 0.9.7 20240424 for fdab0000.npu on minor 1
[   15.555130] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_disable] Crtc atomic disable vp0
[   15.588654] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_disable] *ERROR* unexpected power on pd6
[   15.591076] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_disable] *ERROR* unexpected power on pd5
[   15.736273] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] Update mode to 1920x1080p60, type: 11(if:HDMI0, flag:0x0) for vp0 dclk: 148500000
[   15.750345] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] dclk_out0 div: 0 dclk_core0 div: 2
[   15.753088] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] set dclk_vop0 to 148500000, get 148500000
[   17.604265] systemd[1]: Starting Load Kernel Module drm...
[   17.651804] systemd[1]: modprobe@drm.service: Deactivated successfully.
[   17.652806] systemd[1]: Finished Load Kernel Module drm.
[   51.491821] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_disable] Crtc atomic disable vp0
[   51.522574] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_disable] *ERROR* unexpected power on pd6
[   51.522615] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_disable] *ERROR* unexpected power on pd5
[   53.331687] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] Update mode to 1920x1080p60, type: 11(if:HDMI0, flag:0x0) for vp0 dclk: 148500000
[   53.332265] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] dclk_out0 div: 0 dclk_core0 div: 2
[   53.332311] rockchip-vop2 fdd90000.vop: [drm:vop2_crtc_atomic_enable] set dclk_vop0 to 148500000, get 148500000

hyprland crash log:

...
[LOG] [AQ] drm: Mode 38: 640x480@59.94Hz
[LOG] [AQ] drm: Mode 39: 720x400@70.08Hz
[LOG] [AQ] drm: Physical size [Vector2D: x: 540, y: 300] (mm)
[LOG] [AQ] drm: Description AOC AG251FWG2 0x00000460 (HDMI-A-1)
[LOG] [AQ] drm: connector HDMI-A-1 crtc is incapable of vrr: props.vrr_capable -> 0, crtc->props.vrr_enabled -> 24
[LOG] [AQ] drm: Explicit sync unsupported
[LOG] [AQ] drm: Scanning connector id 223
[LOG] [AQ] drm: Connector id 223 already initialized
[LOG] [AQ] drm: Connector 223 connection state: 2
[LOG] [AQ] drm: gpu /dev/dri/card0 becomes primary drm
[LOG] [AQ] Starting the Aquamarine backend!
[LOG] [AQ] Starting the Wayland backend!
[ERR] [AQ] Wayland backend cannot start: wl_display_connect failed (is a wayland compositor running?)
[ERR] [AQ] Requested backend (wayland) could not start, enabling fallbacks
[ERR] [AQ] Implementation wayland failed, erasing.
[LOG] [AQ] Created a GBM allocator with drm fd 27
[LOG] [AQ] drm: Connectors size2 2
[LOG] [AQ] Created a GBM allocator with drm fd 30
[LOG] [AQ] CDRMRenderer: success
[LOG] [AQ] drm: onReady: connector 207
[LOG] [AQ] drm: onReady: connector 207 has output name HDMI-A-1
[LOG] [AQ] Swapchain: Clearing
[LOG] New aquamarine output with name HDMI-A-1
[LOG] [AQ] drm: onReady: connector 223
[LOG] [AQ] CDRMRenderer: success
[LOG] Running on DRMFD: 26
[LOG] wl_display_add_socket for wayland-1 succeeded with 0
[LOG] Creating the CHyprOpenGLImpl!
[LOG] Supported EGL extensions: (16) EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions>
[LOG] eglDeviceFromDRMFD: Using device /dev/dri/card0
[ERR] [EGL] Command eglInitialize errored out with EGL_NOT_INITIALIZED (0x12289): DRI2: failed to create screen
[ERR] [EGL] Command eglInitialize errored out with EGL_NOT_INITIALIZED (0x12289): DRI2: failed to create screen
[ERR] [EGL] Command eglInitialize errored out with EGL_NOT_INITIALIZED (0x12289): DRI2: failed to create screen
[ERR] [EGL] Command eglInitialize errored out with EGL_NOT_INITIALIZED (0x12289): eglInitialize
[CRITICAL]
==========================================================================================
ASSERTION FAILED!

EGL: failed to initialize a platform display

at: line 112 in OpenGL.cpp

what I do wrong?