rockchip: support generic firmware installation

This commit is contained in:
ZHANG Yuntian
2025-02-07 14:28:18 +08:00
committed by mergify[bot]
parent ab84bd93a3
commit 0b2e2fe9b3
5 changed files with 24 additions and 43 deletions

View File

@@ -74,8 +74,8 @@ Below is an annoated flake example to create the initial boot image.
# Override the default bootloader with a cross built one.
# Use this if you do not have binfmt configured on your system.
# For NixOS, please add `boot.binfmt.emulatedSystems = [ "aarch64-linux" ];` to your system configuration.
# Update the system and the firmware package according to your device.
# hardware.radxa.rock-4c-plus.platformFirmware = nixpkgs-unfree.legacyPackages.x86_64-linux.pkgsCross.aarch64-multiplatform.ubootRock4CPlus;
# Read the device module to see how it was configured.
# hardware.rockchip.platformFirmware = nixpkgs-unfree.legacyPackages.x86_64-linux.pkgsCross.aarch64-multiplatform.ubootRock4CPlus;
users.users.radxa = {
isNormalUser = true;

View File

@@ -2,29 +2,18 @@
, pkgs
, config
, ...
}:
let
cfg = config.hardware.radxa.rock-4c-plus;
rkCfg = config.hardware.rockchip;
in {
}: {
imports = [
../.
../../rockchip
];
options.hardware.radxa.rock-4c-plus = {
platformFirmware = lib.mkPackageOption pkgs "ubootRock4CPlus" { };
};
config = {
hardware = {
radxa.enable = true;
rockchip = {
rk3399.enable = true;
diskoExtraPostVM = ''
dd conv=notrunc,fsync if=${cfg.platformFirmware}/idbloader.img of=$out/${rkCfg.diskoImageName} bs=512 seek=64
dd conv=notrunc,fsync if=${cfg.platformFirmware}/u-boot.itb of=$out/${rkCfg.diskoImageName} bs=512 seek=16384
'';
platformFirmware = pkgs.ubootRock4CPlus;
};
};
};

View File

@@ -2,29 +2,18 @@
, pkgs
, config
, ...
}:
let
cfg = config.hardware.radxa.rock-5b;
rkCfg = config.hardware.rockchip;
in {
}: {
imports = [
../.
../../rockchip
];
options.hardware.radxa.rock-5b = {
platformFirmware = lib.mkPackageOption pkgs "ubootRock5ModelB" { };
};
config = {
hardware = {
radxa.enable = true;
rockchip = {
rk3588.enable = true;
diskoExtraPostVM = ''
dd conv=notrunc,fsync if=${cfg.platformFirmware}/idbloader.img of=$out/${rkCfg.diskoImageName} bs=512 seek=64
dd conv=notrunc,fsync if=${cfg.platformFirmware}/u-boot.itb of=$out/${rkCfg.diskoImageName} bs=512 seek=16384
'';
platformFirmware = pkgs.ubootRock5ModelB;
};
};
};

View File

@@ -2,29 +2,18 @@
, pkgs
, config
, ...
}:
let
cfg = config.hardware.radxa.rock-pi-4;
rkCfg = config.hardware.rockchip;
in {
}: {
imports = [
../.
../../rockchip
];
options.hardware.radxa.rock-pi-4 = {
platformFirmware = lib.mkPackageOption pkgs "ubootRockPi4" { };
};
config = {
hardware = {
radxa.enable = true;
rockchip = {
rk3399.enable = true;
diskoExtraPostVM = ''
dd conv=notrunc,fsync if=${cfg.platformFirmware}/idbloader.img of=$out/${rkCfg.diskoImageName} bs=512 seek=64
dd conv=notrunc,fsync if=${cfg.platformFirmware}/u-boot.itb of=$out/${rkCfg.diskoImageName} bs=512 seek=16384
'';
platformFirmware = pkgs.ubootRockPi4;
};
};
};

View File

@@ -17,12 +17,26 @@ in {
type = lib.types.str;
default = "main.raw";
description = ''
The output image name for Disko.
Can be used by diskoExtraPostVM.
The output image name of Disko.
You need to match this value with the real image name. Setting it alone
won't change the output image name, as it is controlled by Disko module.
Can be used in diskoExtraPostVM.
'';
};
platformFirmware = lib.mkPackageOption pkgs "platform firmware" {
default = null;
};
diskoExtraPostVM = lib.mkOption {
type = lib.types.str;
default = ''
${lib.getExe' pkgs.coreutils "dd"} conv=notrunc,fsync if=${config.hardware.rockchip.platformFirmware}/idbloader.img of=$out/${config.hardware.rockchip.diskoImageName} bs=512 seek=64
${lib.getExe' pkgs.coreutils "dd"} conv=notrunc,fsync if=${config.hardware.rockchip.platformFirmware}/u-boot.itb of=$out/${config.hardware.rockchip.diskoImageName} bs=512 seek=16384
'';
defaultText = lib.literalExpression ''
${lib.getExe' pkgs.coreutils "dd"} conv=notrunc,fsync if=${config.hardware.rockchip.platformFirmware}/idbloader.img of=$out/${config.hardware.rockchip.diskoImageName} bs=512 seek=64
${lib.getExe' pkgs.coreutils "dd"} conv=notrunc,fsync if=${config.hardware.rockchip.platformFirmware}/u-boot.itb of=$out/${config.hardware.rockchip.diskoImageName} bs=512 seek=16384
'';
description = ''
The post VM hook for Disko's Image Builder.
Can be used to install platform firmware like U-Boot.