Skip to content

Commit

Permalink
feat: support orangepi 5b
Browse files Browse the repository at this point in the history
  • Loading branch information
phaitonican committed Oct 15, 2023
1 parent 50eda9b commit f62c94b
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
20 changes: 20 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@
];
};

# Orange Pi 5B SBC
orangepi5b = import "${nixpkgs}/nixos/lib/eval-config.nix" rec {
system = "x86_64-linux";
specialArgs = inputs;
modules =
[
{
networking.hostName = "orangepi5b";

nixpkgs.crossSystem = {
config = "aarch64-unknown-linux-gnu";
};
}

./modules/boards/orangepi5b.nix
./modules/user-group.nix
];
};

# Orange Pi 5 Plus SBC
# TODO not complete yet
orangepi5plus = import "${nixpkgs}/nixos/lib/eval-config.nix" rec {
Expand Down Expand Up @@ -89,6 +108,7 @@
packages.x86_64-linux = {
# sdImage
sdImage-opi5 = self.nixosConfigurations.orangepi5.config.system.build.sdImage;
sdImage-opi5b = self.nixosConfigurations.orangepi5b.config.system.build.sdImage;
sdImage-opi5plus = self.nixosConfigurations.orangepi5plus.config.system.build.sdImage;
sdImage-rock5a = self.nixosConfigurations.rock5a.config.system.build.sdImage;

Expand Down
97 changes: 97 additions & 0 deletions modules/boards/orangepi5b.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# =========================================================================
# Orange Pi 5B Specific Configuration
# =========================================================================
{
config,
pkgs,
nixpkgs,
...
}:

let
boardName = "orangepi5b";
rootPartitionUUID = "14e19a7b-0ae0-484d-9d54-43bd6fdc20c7";
in
{
imports = [
./base.nix
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
];

boot = {
kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ../../pkgs/kernel/legacy.nix {});

# kernelParams copy from Armbian's /boot/armbianEnv.txt & /boot/boot.cmd
kernelParams = [
"root=UUID=${rootPartitionUUID}"
"rootwait"
"rootfstype=ext4"

"earlycon" # enable early console, so we can see the boot messages via serial port / HDMI
"consoleblank=0" # disable console blanking(screen saver)
"console=ttyS2,1500000" # serial port
"console=tty1" # HDMI

# docker optimizations
"cgroup_enable=cpuset"
"cgroup_memory=1"
"cgroup_enable=memory"
"swapaccount=1"
];
};

# add some missing deviceTree in armbian/linux-rockchip:
# orange pi 5b's deviceTree in armbian/linux-rockchip:
# https://github.com/armbian/linux-rockchip/blob/rk-5.10-rkr4/arch/arm64/boot/dts/rockchip/rk3588s-orangepi-5b.dts
hardware = {
deviceTree = {
name = "rockchip/rk3588s-orangepi-5b.dtb";
overlays = [
{
# enable i2c1
name = "orangepi5-i2c-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "rockchip,rk3588s-orangepi-5";
fragment@0 {
target = <&i2c1>;
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&i2c1m2_xfer>;
};
};
};
'';
}
];
};

firmware = [
];
};

sdImage = {
inherit rootPartitionUUID;

imageBaseName = "${boardName}-sd-image";
compressImage = true;

# install firmware into a separate partition: /boot/firmware
populateFirmwareCommands = ''
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./firmware
'';
firmwarePartitionOffset = 32;
firmwarePartitionName = "BOOT";
firmwareSize = 200; # MiB

populateRootCommands = ''
mkdir -p ./files/boot
'';
};
}

0 comments on commit f62c94b

Please sign in to comment.