Skip to content

Commit

Permalink
fix: rock5a - uboot
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin committed Mar 25, 2024
1 parent 349f39d commit 7c7ff14
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 86 deletions.
2 changes: 1 addition & 1 deletion modules/boards/orangepi5.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in {
];

boot = {
kernelPackages = pkgsKernel.linuxPackagesFor (pkgsKernel.callPackage ../../pkgs/kernel/vendor.nix {});
kernelPackages = pkgsKernel.linuxPackagesFor (pkgsKernel.callPackage ../../pkgs/kernel/orangepi.nix {});

# kernelParams copy from Armbian's /boot/armbianEnv.txt & /boot/boot.cmd
kernelParams = [
Expand Down
2 changes: 1 addition & 1 deletion modules/boards/orangepi5plus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in {
];

boot = {
kernelPackages = pkgsKernel.linuxPackagesFor (pkgsKernel.callPackage ../../pkgs/kernel/vendor.nix {});
kernelPackages = pkgsKernel.linuxPackagesFor (pkgsKernel.callPackage ../../pkgs/kernel/orangepi.nix {});

# kernelParams copy from Armbian's /boot/armbianEnv.txt & /boot/boot.cmd
kernelParams = [
Expand Down
2 changes: 1 addition & 1 deletion modules/boards/rock5a.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ in {
];

boot = {
kernelPackages = pkgsKernel.linuxPackagesFor (pkgsKernel.callPackage ../../pkgs/kernel/vendor.nix {});
kernelPackages = pkgsKernel.linuxPackagesFor (pkgsKernel.callPackage ../../pkgs/kernel/radxa.nix {});

# kernelParams copy from rock5a's official debian image's /boot/extlinux/extlinux.conf
# https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
Expand Down
6 changes: 4 additions & 2 deletions modules/sd-image/rock5a.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
inherit (rk3588) nixpkgs;

rootPartitionUUID = "14e19a7b-0ae0-484d-9d54-43bd6fdc20c7";
# rkbin-rk3588 = pkgs.callPackage ../../pkgs/rkbin-rk3588 {};
uboot = pkgs.callPackage ../../pkgs/u-boot-radxa/prebuilt.nix {};
uboot = pkgs.callPackage ../../pkgs/u-boot {
# https://github.com/u-boot/u-boot/blob/v2024.01/configs/rock5a-rk3588s_defconfig
defconfig = "rock5a-rk3588s_defconfig";
};
in {
imports = [
./sd-image-rock5a.nix
Expand Down
2 changes: 1 addition & 1 deletion pkgs/kernel/vendor.nix → pkgs/kernel/orangepi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# 5. Then use `make menuconfig` in kernel's root directory to view and customize the kernel(like enable/disable rknpu, rkflash, ACPI(for UEFI) etc).
# 6. copy the generated .config to ./pkgs/kernel/rk35xx_vendor_config and commit it.
#
configfile = ./rk35xx_vendor_config;
configfile = ./rk35xx_orangepi_config;
allowImportFromDerivation = true;
})
.overrideAttrs (old: {
Expand Down
44 changes: 44 additions & 0 deletions pkgs/kernel/radxa.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# args of buildLinux:
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os-specific/linux/kernel/generic.nix
# Note that this method will use the deconfig in source tree,
# commbined the common configuration defined in pkgs/os-specific/linux/kernel/common-config.nix, which is suitable for a NixOS system.
# but it't not suitable for embedded systems, so we comment it out.
# ================================================================
# If you already have a generated configuration file, you can build a kernel that uses it with pkgs.linuxManualConfig
# The difference between deconfig and the generated configuration file is that the generated configuration file is more complete,
#
{
fetchFromGitHub,
linuxManualConfig,
ubootTools,
...
}:
(linuxManualConfig rec {
modDirVersion = "6.1.43";
version = "${modDirVersion}-radxa-rk3588";
extraMeta.branch = "6.1";

# https://github.com/radxa/kernel/tree/linux-6.1-stan-rkr1
# build script:
# https://github.com/radxa/build/blob/debian/board_configs.sh
src = fetchFromGitHub {
owner = "radxa";
repo = "kernel";
rev = "7fe0e59bb81b910d0aa815217bfa5f162702cf26";
hash = "";
};

# Steps to the generated kernel config file
# 1. git clone --depth 1 https://github.com/radxa/kernel.git -b linux-6.1-stan-rkr1
# 3. run `nix develop .#fhsEnv` in this project to enter the fhs test environment defined here.
# 4. `cd linux-rockchip` and `make rockchip_linux_defconfig` to configure the kernel.
# 5. Then use `make menuconfig` in kernel's root directory to view and customize the kernel(like enable/disable rknpu, rkflash, ACPI(for UEFI) etc).
# 6. copy the generated .config to ./pkgs/kernel/rk35xx_radxa_config and commit it.
#
configfile = ./rk35xx_radxa_config;
allowImportFromDerivation = true;
})
.overrideAttrs (old: {
name = "k"; # dodge uboot length limits
nativeBuildInputs = old.nativeBuildInputs ++ [ubootTools];
})
File renamed without changes.
20 changes: 0 additions & 20 deletions pkgs/rkbin-rk3588/default.nix

This file was deleted.

44 changes: 0 additions & 44 deletions pkgs/u-boot-radxa/build-from-source.nix

This file was deleted.

Binary file not shown.
Binary file not shown.
16 changes: 0 additions & 16 deletions pkgs/u-boot-radxa/prebuilt.nix

This file was deleted.

37 changes: 37 additions & 0 deletions pkgs/u-boot/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
fetchFromGitHub,
buildUBoot,
defconfig,
...
}: let
rkbin = fetchFromGitHub {
owner = "rockchip-linux";
repo = "rkbin";
rev = "a2a0b89b6c8c612dca5ed9ed8a68db8a07f68bc0";
hash = "sha256-U/jeUsV7bhqMw3BljmO6SI07NCDAd/+sEp3dZnyXeeA=";
};
in
buildUBoot rec {
version = "2024.01";
src = fetchFromGitHub {
owner = "u-boot";
repo = "u-boot";
rev = "v${version}";
hash = "sha256-0Da7Czy9cpQ+D5EICc3/QSZhAdCBsmeMvBgykYhAQFw=";
};
inherit defconfig;
patches = [];
# https://github.com/armbian/build/blob/main/config/boards/rock-5a.csc
# Configuring normal/SPI uboot target map
extraMakeFlags = [
"BL31=${rkbin}/bin/rk35/rk3588_bl31_v1.45.elf rock-5a-spi-rk3588s_defconfig spl/u-boot-spl.bin u-boot.dtb u-boot.itb;;rkspi_loader.img"
"BL31=${rkbin}/bin/rk35/rk3588_bl31_v1.45.elf rock-5a-rk3588s_defconfig spl/u-boot-spl.bin u-boot.dtb u-boot.itb;;idbloader.img u-boot.itb"
];
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = [
"spl/u-boot-spl.bin"

"u-boot.itb"
"idbloader.img"
];
}

0 comments on commit 7c7ff14

Please sign in to comment.