commit 60f66c35d21185acec7df631025dee294ea6c8cd (tree)
parent e702cdfb18793bc5c709f340ae62553867291485
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date: Tue, 27 Feb 2024 22:56:47 +0200
Merge branch 'orangepi5plus'
Diffstat:
5 files changed, 215 insertions(+), 0 deletions(-)
diff --git a/flake.nix b/flake.nix
@@ -54,6 +54,11 @@
};
};
+ #linux-rockchip-collabora = {
+ # url = "git+https://git.jakstys.lt/motiejus/linux?ref=rk3588";
+ # flake = false;
+ #};
+
e11sync = {
url = "git+https://git.jakstys.lt/motiejus/e11sync";
inputs = {
@@ -125,6 +130,15 @@
specialArgs = {inherit myData;} // inputs;
};
+ op5p = nixpkgs.lib.nixosSystem {
+ system = "aarch64-linux";
+ modules = [
+ {nixpkgs.overlays = overlays;}
+ ./hosts/op5p/configuration.nix
+ ];
+ specialArgs = {inherit myData;} // inputs;
+ };
+
vno1-oh2 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
diff --git a/hacks/orangepi5/uboot/default.nix b/hacks/orangepi5/uboot/default.nix
@@ -0,0 +1,56 @@
+{
+ fetchFromGitLab,
+ fetchFromGitHub,
+ buildArmTrustedFirmware,
+ buildUBoot,
+}: let
+ rkbin = fetchFromGitHub {
+ owner = "rockchip-linux";
+ repo = "rkbin";
+ rev = "b4558da0860ca48bf1a571dd33ccba580b9abe23";
+ hash = "sha256-KUZQaQ+IZ0OynawlYGW99QGAOmOrGt2CZidI3NTxFw8=";
+ };
+
+ tfa =
+ (buildArmTrustedFirmware rec {
+ extraMakeFlags = ["bl31"];
+ platform = "rk3588";
+ extraMeta.platforms = ["aarch64-linux"];
+ filesToInstall = ["build/${platform}/release/bl31/bl31.elf"];
+ })
+ .overrideAttrs (_: {
+ src = fetchFromGitLab {
+ domain = "gitlab.collabora.com";
+ owner = "hardware-enablement";
+ repo = "rockchip-3588/trusted-firmware-a";
+ rev = "002d8e85ce5f4f06ebc2c2c52b4923a514bfa701";
+ hash = "sha256-1XOG7ILIgWa3uXUmAh9WTfSGLD/76OsmWrUhIxm/zTg=";
+ };
+ });
+in
+ buildUBoot rec {
+ version = "2024.01";
+
+ src = fetchFromGitLab {
+ domain = "source.denx.de";
+ owner = "u-boot";
+ repo = "u-boot";
+ rev = "v${version}";
+ hash = "sha256-0Da7Czy9cpQ+D5EICc3/QSZhAdCBsmeMvBgykYhAQFw=";
+ };
+
+ defconfig = "orangepi-5-rk3588s_defconfig";
+ extraConfig = ''
+ CONFIG_ROCKCHIP_SPI_IMAGE=y
+ '';
+
+ ROCKCHIP_TPL = "${rkbin}/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.12.bin";
+ BL31 = "${tfa}/bl31.elf";
+
+ # FIXME: seems to not like nixpkgs dtc for some reason
+ extraMakeFlags = ["DTC=./scripts/dtc/dtc"];
+
+ filesToInstall = [".config" "u-boot.itb" "idbloader.img" "u-boot-rockchip.bin" "u-boot-rockchip-spi.bin"];
+
+ extraMeta.platforms = ["aarch64-linux"];
+ }
diff --git a/hacks/orangepi5/uboot/sata.patch b/hacks/orangepi5/uboot/sata.patch
@@ -0,0 +1,34 @@
+diff --git a/arch/arm/dts/rk3588s-orangepi-5.dts b/arch/arm/dts/rk3588s-orangepi-5.dts
+index 8f399c4317..3997984e42 100644
+--- a/arch/arm/dts/rk3588s-orangepi-5.dts
++++ b/arch/arm/dts/rk3588s-orangepi-5.dts
+@@ -238,7 +238,7 @@
+ &pcie2x1l2 {
+ reset-gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_HIGH>;
+ vpcie3v3-supply = <&vcc3v3_pcie20>;
+- status = "okay";
++ status = "disabled";
+ };
+
+ &pinctrl {
+@@ -660,3 +660,7 @@
+ &usb_host1_ohci {
+ status = "okay";
+ };
++
++&sata0 {
++ status = "okay";
++};
+diff --git a/arch/arm/dts/rk3588s.dtsi b/arch/arm/dts/rk3588s.dtsi
+index 61a9a11c3b..05028012ce 100644
+--- a/arch/arm/dts/rk3588s.dtsi
++++ b/arch/arm/dts/rk3588s.dtsi
+@@ -1390,6 +1390,8 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
++ phys = <&combphy0_ps PHY_TYPE_SATA>;
++ phy-names = "sata-phy";
+
+ sata-port@0 {
+ reg = <0>;
diff --git a/hosts/op5p/configuration.nix b/hosts/op5p/configuration.nix
@@ -0,0 +1,53 @@
+{
+ #self,
+ #lib,
+ #pkgs,
+ myData,
+ #config,
+ #modulesPath,
+ ...
+}: {
+ imports = [
+ ../../shared/platform/orangepi5.nix
+ ];
+
+ users.users = {
+ motiejus = {
+ isNormalUser = true;
+ extraGroups = ["wheel" "video"];
+ initialHashedPassword = "";
+ openssh.authorizedKeys.keys = [myData.people_pubkeys.motiejus];
+ };
+ root.initialHashedPassword = "";
+ };
+
+ security = {
+ pam.services.lightdm.text = ''
+ auth sufficient pam_succeed_if.so user ingroup wheel
+ '';
+ sudo = {
+ enable = true;
+ wheelNeedsPassword = false;
+ };
+ };
+
+ networking = {
+ hostName = "op5p";
+ domain = "jakstys.lt";
+ firewall.allowedTCPPorts = [22];
+ };
+
+ nix = {
+ extraOptions = ''
+ experimental-features = nix-command flakes
+ trusted-users = nixos
+ '';
+ settings = {
+ experimental-features = ["nix-command" "flakes"];
+ trusted-users = ["motiejus"];
+ };
+ };
+
+ time.timeZone = "UTC";
+ system.stateVersion = "23.11";
+}
diff --git a/shared/platform/orangepi5.nix b/shared/platform/orangepi5.nix
@@ -0,0 +1,58 @@
+{
+ config,
+ lib,
+ pkgs,
+ modulesPath,
+ ...
+}: let
+ crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
+in {
+ boot = {
+ kernelPackages = crossPkgs.linuxPackagesFor (crossPkgs.buildLinux {
+ version = "6.8.0-rc1";
+ modDirVersion = "6.8.0-rc1";
+
+ #src = linux-rockchip-collabora;
+ #src = builtins.fetchUrl {
+ # url = "https://git.jakstys.lt/motiejus/linux/archive/rk3588.tar.gz";
+ # sha256 = "869adb5236254e705b51f3bcd22c0ac2498ca661c44c5a25a737bb067bc5a635";
+ #};
+ src = builtins.fetchGit {
+ url = "https://git.jakstys.lt/motiejus/linux";
+ rev = "eadcef24731e0f1ddb86dc7c9c859387b5b029a2";
+ ref = "rk3588";
+ shallow = true;
+ };
+ kernelPatches = [];
+
+ extraMeta.branch = "6.8";
+ });
+
+ loader = {
+ grub.enable = false;
+ generic-extlinux-compatible.enable = true;
+ };
+
+ initrd.kernelModules = ["ahci_dwc" "phy_rockchip_naneng_combphy"];
+ consoleLogLevel = 7;
+ };
+
+ hardware.deviceTree.name = "rockchip/rk3588s-orangepi-5.dtb";
+
+ fileSystems = {
+ "/" = {
+ device = "/dev/disk/by-label/nixos";
+ fsType = "ext4";
+ options = ["noatime"];
+ };
+ };
+
+ system.build = {
+ sdImage = import "${modulesPath}/../lib/make-disk-image.nix" {
+ name = "orangepi5-sd-image";
+ copyChannel = false;
+ inherit config lib pkgs;
+ };
+ uboot = crossPkgs.callPackage ../../hacks/orangepi5/uboot {};
+ };
+}