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

Board request: NanoPc CM3588 NAS #142

Open
NomisIV opened this issue Jun 6, 2024 · 86 comments
Open

Board request: NanoPc CM3588 NAS #142

NomisIV opened this issue Jun 6, 2024 · 86 comments

Comments

@NomisIV
Copy link

NomisIV commented Jun 6, 2024

What would be required to add support for the FriendlyElec CM3588 NAS kit board? I have very little experience in this area, but I am motivated to get this implemented. I do own this board myself, so I would be able to perform testing on it.

What I've figured out myself is that the device tree (dts) file needs to be included here. The proper device tree for this board is probably this one.

Are there any more files that need to be included for proper support?

Looking forward for input!

@jjpe
Copy link

jjpe commented Jun 13, 2024

I too would like to know how support for the CM3588 would be added.

@mariobalanica
Copy link
Collaborator

You can use one of the existing platforms as a template.
They're all fairly similar, with notable differences being power enable GPIOs (e.g. for USB) and I2C peripheral locations. These details can be found in the device tree and board schematics.

Board-specific code resides in the .DSC file and RockchipPlatformLib.

The DTB should indeed be imported from Armbian's rk 6.1 branch. Right now it's only used for booting Linux, UEFI itself does not care about it.

By the way, the PCIe code does not currently support bifurcation (which the CM3588 appears to be using), so things like NVME drives won't be usable in UEFI.

@jjpe
Copy link

jjpe commented Jun 25, 2024

Thank you for the response.

By the way, the PCIe code does not currently support bifurcation (which the CM3588 appears to be using), so things like NVME drives won't be usable in UEFI.

What exactly would be needed for PCIe bifurcation support? I ask because my primary use case for the board is as a NAS, with... you guessed it, NVMe drives.

EDIT: OTOH, if it's only in UEFI where bifurcation doesn't work then perhaps it's not that much of a problem for the use case of a NAS?

@mariobalanica
Copy link
Collaborator

Bifurcation missing in UEFI means you can't boot from NVME. Maybe one of the slots would work at x1 link depending on how things are wired, but I don't know for sure.

It shouldn't be difficult to implement. It mostly needs changes to the PCIe 3 PHY driver and some nice user-configurable settings for lane mapping. I haven't had the hardware to test this and hence no interest really, but I'm going to accept pull requests if anyone's interested in taking on this task.

If your use-case is booting Linux with a device tree off SD/eMMC/USB, then you probably don't care about any of the above.

@navarro967
Copy link
Contributor

I have begun simple work to get it ported to the device here.

The fork/branch produces a bootable build of EDK2. This device is almost identical to the T6 which I used as the base. I don't particularly require NVMe boot however the first NVMe device did show as a boot option.

I'm relatively new to the ARM scene and not very adept at reading device schematics however if I can reverse engineer the values from the T6 to understand how this is mapped I should be able to clean this up and submit a PR. @mariobalanica Maybe you can give me a simple example of how this mapping done?

Otherwise, if anyone want's to take a crack at it you can build from my fork

@NomisIV
Copy link
Author

NomisIV commented Jul 11, 2024

I tried your fork @navarro967, but my keyboard wouldn't get detected. If I was lucky I could get into the boot options by pressing Escape, but once I got in I couldn't navigate anything.

Were you able to get this working on your board, or are you experiencing the same issue?

@jjpe
Copy link

jjpe commented Jul 12, 2024

I just got my hardware.
I'm not familiar with the intricate parts of bootloading etc, so what can I do to help, short of bricking the device?

@Rippanda12
Copy link

short of bricking the device?

@jjpe
These devices aren't "brickable" since you have access to flashing modes etc which aren't really present on phones so don't worry about something happening to your device

@jjpe
Copy link

jjpe commented Jul 13, 2024

These devices aren't "brickable"

Not even if a wrong image is flashed, which at least in theory, could cause electrical damage by driving e.g. some I/O ports incorrectly? If that's true, then that is very useful to know indeed.

@Rippanda12
Copy link

These devices aren't "brickable"

Not even if a wrong image is flashed, which at least in theory, could cause electrical damage by driving e.g. some I/O ports incorrectly? If that's true, then that is very useful to know indeed.

Software wise they can't be bricked just like a regular pc, ofc physical damage can be done i.e plugging stuff where they don't belong but that rarely happens

@navarro967
Copy link
Contributor

I tried your fork @navarro967, but my keyboard wouldn't get detected. If I was lucky I could get into the boot options by pressing Escape, but once I got in I couldn't navigate anything.

Were you able to get this working on your board, or are you experiencing the same issue?

I was able to, I plugged my Keychron K10 into a USB A port and was able to enter the BIOS and make changes.

@Jeidnx
Copy link

Jeidnx commented Jul 23, 2024

I have tried 5 different Keyboards, and the only one that worked was a Microsoft Sculpt (notably, the only one which uses a wireless dongle). Every one of them worked, once booted into the OS. I couldn't find any error messages, the only thing i noticed was that all keyboards get power when plugged in, but only for a second before turning off again.

@jneem
Copy link
Contributor

jneem commented Aug 27, 2024

Thanks for kicking this off @navarro967! I rebased your fork on the latest master to bring in the PCIe bifurcation support, and I can confirm that the firmware loads and sees my NVMe drive.

I haven't actually managed to boot into an OS yet. I have a working Ubuntu installation on the eMMC -- I know it's working because if I remove the sd card with edk2 then it boots -- but selecting it in the boot configuration menu just flashes the screen black and brings me back to edk2. If anyone has suggestions about how to debug it, I'd be grateful. Otherwise, I'm going to poke around with GPIO settings.

@serpent213
Copy link

serpent213 commented Sep 4, 2024

Got my NAS board today and tried @navarro967's fork, flashed to eMMC via the FriendlyWrt web flasher. Console is serial, connected to the three pin header.

Looks pretty good, menu works fine, I switched from ACPI to DT and it boots into Grub from USB or microSD. I used a NixOS ISO (nixos-minimal-24.05.4469.6e99f2a27d60-aarch64-linux.iso).

After selecting the serial console in Grub and progressing to the kernel it gets stuck, though:

EFI stub: Booting Linux Kernel...
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...

Also tried an ISO from another distro with very similar results.

Did not get any output on HDMI, but I didn't try very hard.

Any idea on how to move on?

@serpent213
Copy link

I built the NixOS image from @ryan4yin: https://github.com/ryan4yin/nixos-rk3588/tree/main, the rock5a variant, needed a small patch:

diff --git a/flake.nix b/flake.nix
index 5102bbc..ecffe1a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,7 +31,7 @@
     ...
   }: let
     # Local system's architecture, the host you are running this flake on.
-    localSystem = "x86_64-linux";
+    localSystem = "aarch64-linux";
     pkgsLocal = import nixpkgs {system = localSystem;};
     # The native system of the target SBC.
     aarch64System = "aarch64-linux";
diff --git a/pkgs/mali-firmware/default.nix b/pkgs/mali-firmware/default.nix
index f2bb1c0..bc48e64 100644
--- a/pkgs/mali-firmware/default.nix
+++ b/pkgs/mali-firmware/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
   version = "g21p0-01eac0";
 
   src = fetchurl {
-    url = "https://github.com/JeffyCN/mirrors/raw/e08ced3e0235b25a7ba2a3aeefd0e2fcbd434b68/firmware/g610/mali_csffw.bin";
+    url = "https://github.com/JeffyCN/mirrors/raw/libmali/firmware/g610/mali_csffw.bin";
     hash = "sha256-jnyCGlXKHDRcx59hJDYW3SX8NbgfCQlG8wKIbWdxLfU=";
   };
 

Copied to SD; throws errors due to hardware mismatch but boots fully with network working (on serial console, did not try HDMI).

@NomisIV
Copy link
Author

NomisIV commented Sep 17, 2024

I built the NixOS image from @ryan4yin: https://github.com/ryan4yin/nixos-rk3588/tree/main, the rock5a variant, needed a small patch:

diff --git a/flake.nix b/flake.nix
index 5102bbc..ecffe1a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,7 +31,7 @@
     ...
   }: let
     # Local system's architecture, the host you are running this flake on.
-    localSystem = "x86_64-linux";
+    localSystem = "aarch64-linux";
     pkgsLocal = import nixpkgs {system = localSystem;};
     # The native system of the target SBC.
     aarch64System = "aarch64-linux";
diff --git a/pkgs/mali-firmware/default.nix b/pkgs/mali-firmware/default.nix
index f2bb1c0..bc48e64 100644
--- a/pkgs/mali-firmware/default.nix
+++ b/pkgs/mali-firmware/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
   version = "g21p0-01eac0";
 
   src = fetchurl {
-    url = "https://github.com/JeffyCN/mirrors/raw/e08ced3e0235b25a7ba2a3aeefd0e2fcbd434b68/firmware/g610/mali_csffw.bin";
+    url = "https://github.com/JeffyCN/mirrors/raw/libmali/firmware/g610/mali_csffw.bin";
     hash = "sha256-jnyCGlXKHDRcx59hJDYW3SX8NbgfCQlG8wKIbWdxLfU=";
   };
 

Copied to SD; throws errors due to hardware mismatch but boots fully with network working (on serial console, did not try HDMI).

Could you elaborate on the steps you took to get this working? I am unable to reproduce. The rawEfiImage fails to build, and the sdImage seems to have a broken partition table (I cannot mount the second partition, and the first one is empty)

@jneem
Copy link
Contributor

jneem commented Sep 18, 2024

My local system isn't an aarch64-linux, so I only changed the mali firmware url. (But it doesn't look like it matters; localSystem is only used in the cross-compiling targets.) I'm on an x86-64 system with boot.binfmt.emulatedSystems = [ "aarch64-linux" ] in my nixos configuration (otherwise it will probably fail with an error about needing to build on an aarch64 system).

Then I run nix build .#rawEfiImage-rock5a, dd the result to an sdcard, and plugging it into my cm3588 with edk2 already installed just works.

(I've been struggling with updating to a more recent kernel, but that's another story...)

@zatevakhin
Copy link

@jneem What kernel versions worked for you?

@jneem
Copy link
Contributor

jneem commented Sep 19, 2024

  • the 6.1.43 kernel from orangepi (the one that's currently used in nixos-rk3588) boots and has ethernet
  • I tried updating to the armbian/linux-rockchip kernel version 6.1.75. It boots but doesn't have ethernet (the r8169 module is available, it just doesn't get loaded)
  • I tried updating to mainline 6.10.9 with config from armbian, but it doesn't boot at all. I get nonsense like this on the serial console:
EFI stub: Booting Linux Kernel...
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...
I nCiagI dPwi alt
                 I dPilg/SaUwnnld
/eaUinnld
I dC ag/SaPsi aro
                 I nCianISdPsioaro
                                  I dCiagISdPsioaro
                                                   I dCianISdPsioaro
                                                                    [    0.702728] rtc-hym8563 6-0051: hctosys: unable to read the hardware clock
[    0.705401] rockchip-thermal fec00000.tsadc: failed to register sensor 0: -19
[    0.706080] rockchip-thermal fec00000.tsadc: error -ENODEV: failed to register sensor[0].
ISaUwn ldt
          I nCilgI dPwi alt
/SaUwnnldt                 I dPil
          I dPilgISaUwn ldt
                           I dCiag/SaPwi alt
                                            I dCiag/SdPwiomro
                                                             I nC anI dCshtmob
                                                                              I dPilgISaPwi llt
                                                                                               I dCilgISdPwi alt
                                                                                                                I dCilgISaPwi alt
                                                                                                                                 I dCilgISaPwi alo
                                                                                                                                                  I dCianI nC htmoo
                                                                                                                                                                   I nC inI n  c ow
I nC anISdPshtmo

I tried booting the second two options (armbian/linux-rockchip and mainline 6.10) using armbian (instead of nixos) to build an sdcard image. The bootable armbian sdcards skip edk2 and they boot with working ethernet.

@jneem
Copy link
Contributor

jneem commented Sep 19, 2024

Btw, I have an updated branch here. Compared to @navarro967 's branch, it's based on a more recent master and it comes with some updates to the pin definitions (but I didn't actually observe any differences caused by these changes)

@Jeidnx
Copy link

Jeidnx commented Sep 19, 2024

Thanks for your work @jneem! Did you use mainline with just the armbian config or did you also apply their kernel patches? I have tried to build the 6.10.{5,9} Kernels with the armbian patches and a modified version of their config (with compressed firmware loading enabled), but haven't been able to successfully build it yet. I am pretty sure it is an issue with my build process though. I have also tried the armbian 6.1.75 and the friendlyarm 6.1.57 kernels, both boot but no Ethernet. The chip doesn't show in lspci, i haven't done more digging yet. Curiously the friendlyarm kernel with almost the same config (i had to enable efi and dmiid) and the same dts has working ethernet when used in the vendor debian 12 image.

I have made a flake to test nixos on the cm3588 a while ago, but just now gotten around to cleaning it up. Here is a link for anyone that's interested.

@jneem
Copy link
Contributor

jneem commented Sep 19, 2024

I've been trying without the armbian patches so far, but maybe I should give them a try. Btw, 6.11 now has mainline support for the cm3588! I'm building that now.

Working ethernet is a priority for me, but I was hoping to get a new kernel booting before digging into the ethernet issue...

@jneem
Copy link
Contributor

jneem commented Sep 19, 2024

but haven't been able to successfully build it yet

If it's the same issue I had, it's because you need to set CONFIG_CRYPTO_AEGIS128_SIMD=n, because the assembler nix is using to build the kernel thinks that the rk3588 doesn't support some instructions. I don't know how armbian gets away with this setting; maybe their assembler thinks differently...

@NomisIV
Copy link
Author

NomisIV commented Sep 19, 2024

I got 6.11 working (with ethernet, but no HDMI for some reason) on my cm3588. Here is the minimal config needed:

  boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest;
  hardware = {
    enableRedistributableFirmware = true;
    deviceTree = {
      enable = true;
      name = "rockchip/rk3588-friendlyelec-cm3588-nas.dtb";
    };
  };

see the entire config here

@DualTachyon
Copy link

but haven't been able to successfully build it yet

If it's the same issue I had, it's because you need to set CONFIG_CRYPTO_AEGIS128_SIMD=n, because the assembler nix is using to build the kernel thinks that the rk3588 doesn't support some instructions. I don't know how armbian gets away with this setting; maybe their assembler thinks differently...

The Crypto instructions on RK3588 are disabled by default. Whether they are enabled in your environment depends on what build of BL31 is being used. See this patch for reference: https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/29363

@jneem
Copy link
Contributor

jneem commented Sep 20, 2024

boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest;

Amazing! All that fiddling with armbian forks and custom configs, and it turns out that latest mainline just works! (For anyone following along, it's important here to be using nixos-unstable or else linux_latest is too old.) Now I have edk2 on my eMMC, booting into nixos on an nvme drive.

@samyak-jain
Copy link

I am trying to flash the firmware from this branch (https://github.com/jneem/edk2-rk3588/tree/cm3588), however, I am unable to enter the boot options when pressing escape at the boot splash screen. I've tried 2 different keyboards. It boots into openmediavault by default no matter what I do. Any suggestions?

@jneem
Copy link
Contributor

jneem commented Sep 22, 2024

It looks like only one USB port was being powered up (the upper USB 3.0 port). The latest commit should enable them all.

@jjpe
Copy link

jjpe commented Sep 25, 2024

For the NixOS users here, how did you cross compile jneem's EDK2 branch?
I'd rather not have to muck about with Debian and the like.

@sanderhollaar
Copy link
Contributor

sanderhollaar commented Sep 25, 2024

@jneem Thanks a lot for your work! 🤗

For the NixOS users here, how did you cross compile jneem's EDK2 branch? I'd rather not have to muck about with Debian and the like.

Until someone actually answers your question ..

I did not want to trial and error the required tools and went the Debian route (on x68_64):

Enable podman with virtualisation.podman.enable = true;

Create /tmp/mnt/: mkdir /tmp/mnt/
Start Debian: podman run --rm -it --network=host --volume=/tmp/mnt:/root debian:trixie /bin/bash

In Debian:
apt update && apt upgrade -y
apt install -y git gcc g++ build-essential gcc-aarch64-linux-gnu acpica-tools python3-pyelftools uuid-dev python-is-python3 device-tree-compiler
cd ~
git clone --recursive https://github.com/jneem/edk2-rk3588.git
cd edk2-rk3588
git switch cm3588
./build.sh --device nanopc-cm3588-nas --release Release

Find RK3588_NOR_FLASH.img in /tmp/mnt/edk2-rk3588/

Have not tried the UEFI image yet.

I also have a NanoPi R6C running NixOS.

@jjpe
Copy link

jjpe commented Oct 15, 2024

This seems a successful boot. Can you try to logon?

When I try to log into the root account and then execute shutdown now, it actually takes effect, indicating success. So that's definitely progress.

However, after I log in, I execute ip a a 192.168.1.145/24 dev $(ip a s | grep -m1 MULTICAST | awk -F ':' '{print $2}'), but that doesn't seem to make any difference to my ability to ping the device (I ping the hostname as I have added a static route to my router for the device):

j@~❯ ping 192.168.1.145                                                                                            09:13:34.232301834
PING 192.168.1.145 (192.168.1.145) 56(84) bytes of data.
From 192.168.1.150 icmp_seq=1 Destination Host Unreachable
From 192.168.1.150 icmp_seq=2 Destination Host Unreachable
From 192.168.1.150 icmp_seq=3 Destination Host Unreachable
From 192.168.1.150 icmp_seq=4 Destination Host Unreachable
From 192.168.1.150 icmp_seq=5 Destination Host Unreachable
From 192.168.1.150 icmp_seq=6 Destination Host Unreachable
^C
--- 192.168.1.145 ping statistics ---
8 packets transmitted, 0 received, +6 errors, 100% packet loss, time 7201ms

So something is still off with the network config in particular.
I just had a thought: Since the eMMC device is (for some reason) consistently listed as /dev/mmcblk2, perhaps the network interface is enumerated differently too? The only problem with that is that IIUC the ip oneliner should automatically fetch the correct interface.

Could it be that your address is missing trailing /24 like address = [ "192.168.178.3/24" ]; ?

I tried adding the /24 subnet mask and reinstalling nixos, but that seems to make no difference in my ability to log into the device using ssh.

What I'll try next is adding the subnet mask to both the address and gateway attributes, see if that helps.

EDIT: I've finally managed to ssh into the device using my non-root account, so thank you for the help!
The only thing left to for now is configuring the network on the device such that I can always get in via ssh, for which I'm looking into ip route add (I have no prior experience with this particular cli command).

@sanderhollaar
Copy link
Contributor

EDIT: I've finally managed to ssh into the device using my non-root account, so thank you for the help! The only thing left to for now is configuring the network on the device such that I can always get in via ssh, for which I'm looking into ip route add (I have no prior experience with this particular cli command).

Glad you made it work!

I would not bother with ip to configure your network in a permanent way. Something like this should work:

    networking = {
        dhcpcd.enable    =  false;
        firewall.enable  =  false;
        useDHCP          =  false;
        useNetworkd      =  true;
    };

    systemd = {
        network = {
            enable               = true;
            networks = {
                enP4p65s0 = {
                    address      = [ "192.168.1.145/24" ];
                    matchConfig  = { Name = "enP4p65s0"; Type = "ether"; };
                    gateway      = [ "192.168.1.1" ];
                };
            };
        };
    };

@jjpe
Copy link

jjpe commented Oct 15, 2024

Turns out I already had those blocks in my config.
So I rebooted the CM3588, tried ssh'ing in, and... it works!

If I ever meet you in meatspace, I definitely owe you a beer :)

@jjpe
Copy link

jjpe commented Oct 16, 2024

There's 1 final issue I need to tackle: The nixos config provides LAN access to I can ssh into it, but no internet access, making updating the system a bit difficult.

So I create a default route using ip, which does work:

[j@hamster:~]$ ping google.com
ping: connect: Network is unreachable

[j@hamster:~]$ sudo ip route add default via 192.168.1.1 dev enP4p65s0
[sudo] password for j:

[j@hamster:~]$ ping google.com
PING google.com (172.217.23.206) 56(84) bytes of data.
64 bytes from prg03s05-in-f206.1e100.net (172.217.23.206): icmp_seq=1 ttl=56 time=3.25 ms
64 bytes from prg03s05-in-f206.1e100.net (172.217.23.206): icmp_seq=2 ttl=56 time=2.74 ms
64 bytes from prg03s05-in-f206.1e100.net (172.217.23.206): icmp_seq=3 ttl=56 time=2.73 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 2.725/2.904/3.254/0.247 ms

The only issue is, at the moment it's necessary that I execute it on every reboot, which is undesirable.
Ive tried adding networking.interfaces.enP4p65s0.ipv4.routes:

  networking = {
    dhcpcd.enable = false;
    firewall.enable = false;
    hostName = "cumulus";
    useDHCP = false;
    useNetworkd = true;
    interfaces.enP4p65s0.ipv4.routes = [{ # I was hoping this would do the trick
      address = "192.168.1.145/24";
      prefixLength = 24;
      via = "192.168.1.1/24";
    }];
  };

But that just borks the LAN connection, necessitating a reinstall from Armbian.

Any idea how I can "nixify" the ip command, i.e. any idea how I can capture that default route in my nixos config files?

EDIT: I also tried this, but without success:

  systemd.services.internetAccess = {
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];
      description = "Add internet access.";
      path = [pkgs.bash pkgs.iproute];
      script = ''
        ip route add default via 192.168.1.1 dev enP4p65s0
      '';
      serviceConfig = {
        Type= "oneshot";
        User = "root";
        Restart = "no";
      };
    };

@ryan4yin
Copy link

@jjpe you set networking.useNetworkd to true, which means that the content of networking.interfaces will be ignored, you need to set your interface's configuration via systemd.network.networks.xx. see #142 (comment) as an example.

@jjpe
Copy link

jjpe commented Oct 16, 2024

You need to set your interface's configuration via systemd.network.networks.xx

Everything I mentioned in my last post is with this block in the configuration:

  systemd = {
    network = {
      enable = true;
      networks = {
        enP4p65s0 = {
          address = [ "192.168.1.145/24" ];
          matchConfig = { Name = "enP4p65s0"; Type = "ether"; };
          gateway = [ "192.168.1.1/24" ];
        };
      };
    };
  };

And this does allow me to ssh in from another host on my LAN.

But it doesn't provide internet access for the CM3588, necessitating the manual execution after every boot of sudo ip route add default via 192.168.1.1 dev enP4p65s0 to bring up the internet connection.

That's a bit... suboptimal for a server, especially so since none of my other hosts need any manual network configuration at all.

@sanderhollaar
Copy link
Contributor

  systemd = {
    network = {
      enable = true;
      networks = {
        enP4p65s0 = {
          address = [ "192.168.1.145/24" ];
          matchConfig = { Name = "enP4p65s0"; Type = "ether"; };
          gateway = [ "192.168.1.1/24" ];
        };
      };
    };
  };

But it doesn't provide internet access for the CM3588, necessitating the manual execution after every boot of sudo ip route add default via 192.168.1.1 dev enP4p65s0 to bring up the internet connection.

The gateway must not have the /24 postfix.

@jjpe
Copy link

jjpe commented Oct 16, 2024

Removing the gateway subnet mask made the difference.
I think I put it in there when I was trying out different settings to see what works, and then forgot about it.

Thanks, now the real configuration can begin :)

@jjpe
Copy link

jjpe commented Oct 19, 2024

Somewhat related to this thread: does anyone happen to know if the same CM3588 firmware can be used for the CM3588 Plus?

Looking at the website, it looks exactly like the CM3588 except with more RAM and possibly higher capacity emmc. But I also know that looks can be deceiving when it comes to hardware, so I'm not making any assumptions.

@sanderhollaar
Copy link
Contributor

Somewhat related to this thread: does anyone happen to know if the same CM3588 firmware can be used for the CM3588 Plus?

Yes, mine is a CM3588 Plus, with 32GB memory and 256GB emmc.

@jjpe
Copy link

jjpe commented Oct 20, 2024

@sanderhollaar Thank you for this info, that helps a lot!

Aside from my CM3588 I also ordered a CM3588 Plus so that will be useful quite soon :)

@cite
Copy link

cite commented Oct 21, 2024

First of all, this is really great work. I'll get a CM3588 next week and am really looking forward to having an alternative to the Debian BSP. However, from the Collabora-Link, it looks like running this board in a mainline 6.11 kernel will not support any of the video de-/encoding features of the board, right?

I was hoping I could run Jellyfin there, because they support rkmpp natively. It looks like support for these functions is indicated by the presence of the following device files:

  • /dev/dri/
  • /dev/dma_heap
  • /dev/mali0
  • /dev/rga
  • /dev/mpp_service

Is it possible to boot the verndor's BSP Debian kernel as a workaround (if that's needed)?

@nyanmisaka
Copy link

First of all, this is really great work. I'll get a CM3588 next week and am really looking forward to having an alternative to the Debian BSP. However, from the Collabora-Link, it looks like running this board in a mainline 6.11 kernel will not support any of the video de-/encoding features of the board, right?

I was hoping I could run Jellyfin there, because they support rkmpp natively. It looks like support for these functions is indicated by the presence of the following device files:

  • /dev/dri/
  • /dev/dma_heap
  • /dev/mali0
  • /dev/rga
  • /dev/mpp_service

Is it possible to boot the verndor's BSP Debian kernel as a workaround (if that's needed)?

There won't be any mature replacement for RKMPP & RKRGA in the mainline anytime soon, so Jellyfin rewrote RKMPP support in FFmpeg from scratch. If you need normal transcoding functionality, please stay away from the mainline.

https://jellyfin.org/docs/general/administration/hardware-acceleration/rockchip

@jjpe
Copy link

jjpe commented Oct 21, 2024

There won't be any mature replacement for RKMPP & RKRGA in the mainline anytime soon

Do you happen to know the reason for this?

@nyanmisaka
Copy link

There won't be any mature replacement for RKMPP & RKRGA in the mainline anytime soon

Do you happen to know the reason for this?

Because third-party developers do not have enough resources and time to develop extremely complex VPU drivers in the mainline full-time, and because V4L2 cannot meet Rockchip's actual product needs, they will not spend any time in upstream V4L2.

Read through this ticket. jellyfin/jellyfin-ffmpeg#34

@NomisIV
Copy link
Author

NomisIV commented Oct 25, 2024

Not sure if this question belongs here, but has anyone gotten higher speeds than 100Mb/s on the NIC? I'm running nixos on the 6.11 kernel, and for whatever reason the NIC decides to run in 100Mb/s mode. The only thing I can think of is that it's some limitation of the DTS file in the 6.11 kernel, kind of like how HDMI isn't working either. If anyone has any info on this, please let me know! :)

EDIT: Today I Learned that I had a CAT5 cable in my home network setup......

@mariobalanica
Copy link
Collaborator

Hey,

Is anyone here able to confirm that all M.2 and USB3 ports work correctly in UEFI & mainline Linux (>=6.10), with latest firmware build from: https://github.com/edk2-porting/edk2-rk3588/actions/workflows/build.yml ?

@mariobalanica mariobalanica reopened this Dec 28, 2024
@Jeidnx
Copy link

Jeidnx commented Dec 29, 2024

Hey @mariobalanica
I just downloaded the latest release build and booted it from an sd card. It loaded nixos from the internal emmc, kernel version 6.12.5 without any special patches. All 3 usb ports and all four M.2 slots work as expected.

I have had some issues with one nvme not showing, but reseating the nvme and the board on the carrier solved them for me.

@mariobalanica
Copy link
Collaborator

mariobalanica commented Dec 29, 2024

What about inside UEFI?

I don't expect all M.2 slots to work with the v0.12 release because it's using a wrong bifurcation config, but they should with this build: https://github.com/edk2-porting/edk2-rk3588/actions/runs/12530647406

Also, one of the USB 3 ports was limited to 2.0 mode.

@samyak-jain
Copy link

First of all, this is really great work. I'll get a CM3588 next week and am really looking forward to having an alternative to the Debian BSP. However, from the Collabora-Link, it looks like running this board in a mainline 6.11 kernel will not support any of the video de-/encoding features of the board, right?

I was hoping I could run Jellyfin there, because they support rkmpp natively. It looks like support for these functions is indicated by the presence of the following device files:

  • /dev/dri/
  • /dev/dma_heap
  • /dev/mali0
  • /dev/rga
  • /dev/mpp_service

Is it possible to boot the verndor's BSP Debian kernel as a workaround (if that's needed)?

I have the same usecase. Any pointers on how I can setup the vendor bsp kernel with nixos?

@sanderhollaar
Copy link
Contributor

I have the same usecase. Any pointers on how I can setup the vendor bsp kernel with nixos?

There are several builtins functions that can be used to fetch a source: https://nix.dev/manual/nix/2.25/language/builtins.html

Do you have a pointer to the verndor BSP Debian kernel ?

@samyak-jain
Copy link

I have the same usecase. Any pointers on how I can setup the vendor bsp kernel with nixos?

There are several builtins functions that can be used to fetch a source: https://nix.dev/manual/nix/2.25/language/builtins.html

Do you have a pointer to the verndor BSP Debian kernel ?

Looking at the documentation here: https://wiki.friendlyelec.com/wiki/index.php/CM3588#Build_kernel_linux-v6.1.y, I suspect this is the repo: https://github.com/friendlyarm/kernel-rockchip.
I'm guessing that I will need to configure nixos to use a custom linux source like mentioned here: https://nixos.wiki/wiki/Linux_kernel#Booting_a_kernel_from_a_custom_source. I should then be able to generate an ISO by using something like nixos-generate --format iso --configuration ./myimage.nix -o result.

Am I on the right track here?

@sanderhollaar
Copy link
Contributor

Do you have a pointer to the verndor BSP Debian kernel ?

Looking at the documentation here: https://wiki.friendlyelec.com/wiki/index.php/CM3588#Build_kernel_linux-v6.1.y, I suspect this is the repo: https://github.com/friendlyarm/kernel-rockchip. I'm guessing that I will need to configure nixos to use a custom linux source like mentioned here: https://nixos.wiki/wiki/Linux_kernel#Booting_a_kernel_from_a_custom_source.

Something like this. Use git ls-remote https://github.com/friendlyarm/kernel-rockchip.git nanopi6-v6* to find the value for rev. That is a mighty old kernel btw.

boot = {
  kernelPackages =
    let
      kernel_pkg =
        { buildLinux, ... }@args:
        buildLinux (
          args
          // {
            version = "6.1.57";
            src = builtins.fetchGit {
              url = "https://github.com/friendlyarm/kernel-rockchip.git";
              ref = "nanopi6-v6.1.y";
              rev = "6bd846aff11336b7250bb638eb4097207543fc88";
            };
          }
          // (args.argsOverride or { })
        );
      kernel = pkgs.callPackage kernel_pkg { };
    in
    pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor kernel);
};

I should then be able to generate an ISO by using something like nixos-generate --format iso --configuration ./myimage.nix -o result.

Am I on the right track here?

Generating an iso I have no experience with. If you have NixOS installed it might be easier to replace the kernel source with (something like) the above, and keep both generations so you have a known working configuration to go back to.

@samyak-jain
Copy link

I'm trying to first setup nixos with the mainline kernel. I've changed the configuration to use device tree mode with mainline support.
I first tried the nixos from the official website but that wouldn't boot. I'm guessing it's because it is using an old version of the kernel.
I tried a few things after that, but all of them give me the following error when booting up: /dev/root "can't lookup blockdev".
I have tried:

  • using the iso shared by @picnoir
  • generating my own iso which uses v6.12

The way I am currently generating the ISO is by using the following nix config:

{ pkgs, modulesPath, lib, ... }: {
  imports = [
    "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
  ];

  # use the latest Linux kernel
  # boot.kernelPackages = pkgs.linuxPackages_latest;

      boot = {
        kernelPackages                =  pkgs.linuxPackages_latest;
        loader = {
            efi.canTouchEfiVariables  =  true;
            systemd-boot = {
                enable                =  true;
            };
        };
    };

    hardware = {
        deviceTree = {
            enable                    =  true;
            name                      = "rockchip/rk3588-friendlyelec-cm3588-nas.dtb";
        };
    };

  # Needed for https://github.com/NixOS/nixpkgs/issues/58959
  # boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
}

I then use the following command to generate the iso:
sudo nix-shell -p nixos-generators --run "nixos-generate --format iso -I nixpkgs=channel:nixos-unstable --system aarch64-linux --configuration ./myimage.nix -o result"

Any idea what I could be doing wrong?

@sanderhollaar
Copy link
Contributor

I'm trying to first setup nixos with the mainline kernel. I've changed the configuration to use device tree mode with mainline support. I first tried the nixos from the official website but that wouldn't boot. I'm guessing it's because it is using an old version of the kernel. I tried a few things after that, but all of them give me the following error when booting up: /dev/root "can't lookup blockdev". I have tried:

* using the iso shared by @picnoir
* generating my own iso which uses v6.12

Any idea what I could be doing wrong?

My guess would be missing kernel modules in the initrd. But it can be anything. Are you able to capture the boot output and post here?

You can also install NixOS from the Debian image as described in: #142 (comment)

@lepik1108
Copy link

lepik1108 commented Jan 12, 2025

I built the NixOS image from @ryan4yin: https://github.com/ryan4yin/nixos-rk3588/tree/main, the rock5a variant, needed a small patch:

diff --git a/flake.nix b/flake.nix
index 5102bbc..ecffe1a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,7 +31,7 @@
     ...
   }: let
     # Local system's architecture, the host you are running this flake on.
-    localSystem = "x86_64-linux";
+    localSystem = "aarch64-linux";
     pkgsLocal = import nixpkgs {system = localSystem;};
     # The native system of the target SBC.
     aarch64System = "aarch64-linux";
diff --git a/pkgs/mali-firmware/default.nix b/pkgs/mali-firmware/default.nix
index f2bb1c0..bc48e64 100644
--- a/pkgs/mali-firmware/default.nix
+++ b/pkgs/mali-firmware/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
   version = "g21p0-01eac0";
 
   src = fetchurl {
-    url = "https://github.com/JeffyCN/mirrors/raw/e08ced3e0235b25a7ba2a3aeefd0e2fcbd434b68/firmware/g610/mali_csffw.bin";
+    url = "https://github.com/JeffyCN/mirrors/raw/libmali/firmware/g610/mali_csffw.bin";
     hash = "sha256-jnyCGlXKHDRcx59hJDYW3SX8NbgfCQlG8wKIbWdxLfU=";
   };
 

Copied to SD; throws errors due to hardware mismatch but boots fully with network working (on serial console, did not try HDMI).

Could you elaborate on the steps you took to get this working? I am unable to reproduce. The rawEfiImage fails to build, and the sdImage seems to have a broken partition table (I cannot mount the second partition, and the first one is empty)

I've just reproduced and tested with HDMI, it works fine as well.
@serpent213 thanks for your comment. it saved my day.
@NomisIV, hope steps below might be uefull for you:

STR:

1.clone a repo

git clone https://github.com/ryan4yin/nixos-rk3588.git
  1. in case, your host platform is x86_64 as mine, there's is no need to apply patch for flake.nix. I'd only applied 2nd one, for pkgs/mali-firmware/default.nix
   src = fetchurl {
-    url = "https://github.com/JeffyCN/mirrors/raw/e08ced3e0235b25a7ba2a3aeefd0e2fcbd434b68/firmware/g610/mali_csffw.bin";
+    url = "https://github.com/JeffyCN/mirrors/raw/libmali/firmware/g610/mali_csffw.bin";
     hash = "sha256-jnyCGlXKHDRcx59hJDYW3SX8NbgfCQlG8wKIbWdxLfU=";
   };
  1. Install nix, in case you don't have it in your host system yet:
sh <(curl -L https://nixos.org/nix/install) --daemon

reopen shell after installation

  1. build sd-card image from your local files

recommend to read https://nixos-and-flakes.thiscute.world/development/cross-platform-compilation, before cross-compiling, as I did...

nix build .#sdImage-rock5a-cross --extra-experimental-features nix-command --extra-experimental-features flakes
  1. follow rock-5a instructions from here: https://github.com/ryan4yin/nixos-rk3588/blob/main/U-Boot.md:

just be carefull with loop0, keep in mind, it's just an example, on your host system it might be loopN.

zstd -d result/sd-image/rock5a-sd-image-*.img.zst -o rock5a.img

# increase img's file size
dd if=/dev/zero bs=1M count=16 >> rock5a.img

# check your loops devices before mounting image
ls /dev/loop*

# mount image to loopN
sudo losetup --find --partscan rock5a.img

# check your loops devices after mounting image
ls /dev/loop*
# find out new one, which has 2 partitions, replace loop0 within next commands with loopN you've found

nix shell nixpkgs#parted
## rock 5a's u-boot require to use gpt partition table, and the root partition must be the first partition!
## so we need to remove all the partitions on the sd card first
## and then recreate the root partition with the same start sector as the original partition 2
START=$(sudo fdisk -l /dev/loop0 | grep /dev/loop0p2 | awk '{print $2}')
sudo parted /dev/loop0 rm 1
sudo parted /dev/loop0 rm 2
sudo parted /dev/loop0 mkpart primary ext4 ${START}s 100%

# check rootfs's status, it's broken.
sudo fsck /dev/loop0p1

# umount the image file
sudo losetup -d /dev/loop0


# flash the image to the sd card
cat rock5a.img | sudo dd status=progress bs=8M of=/dev/sdX

Also tested that same image with nanopi-m6, with the only difference: it's u-boot partition is 8M long, instead of 16M for nanopc-CM3588-nas, and I've been writing u-boot part, copied from DietPi-NanoPi-M6

PS: for ppl, who doesn't wanna mess around with nix-os and just want a working rockchip-based SBC, I recommend this: https://dietpi.com. Their images are pretty lightweight and fast and as live-cd images for SD cards they just work perfectly without any additional complicated things required...

@jjpe
Copy link

jjpe commented Feb 3, 2025

@jjpe @Jeidnx There is unofficial support for linux 6.11 in zfs_unstable (link). I have successfully installed NixOS on ZFS on 4 SSDs. The package does complain that it is broken when trying to build, but as far as I can tell it is working anyway. Just give nix the NIXPKGS_ALLOW_BROKEN=1 flag, and it should work.

@NomisIV Would you mind posting the config?

I have NixOS working on eMMC, and I'm trying to get NixOS working on ZFS, and while my RAIDZ1 array itself works (also 4 SSDs, on NixOS-on-eMMC I can manually import my zpool and then use the datasets as normal, including the ones I want to use to re/install NixOS on), I haven't been able to come up with a working NixOS system config that allows booting from the ZFS array.

My hypothesis is that I have some small flaw in my config somewhere, and a point of reference there would be quite helpful.

@NomisIV
Copy link
Author

NomisIV commented Feb 6, 2025

@jjpe I think this is the only really relevant part: https://codeberg.org/NomisIV/dotfiles/src/branch/master/machines/flash.nix#L3-L9. Well, that and the filesystem block a bit further down. Something to note is that I have the /boot partition on the eMMC (in another partition after the 8M edk-rk3588 partition) and not the ZFS array. I hope this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests