2023-04-23 16:11:02 +00:00
|
|
|
{ callPackage, pkgsBuildHost, runCommand, writeText, stdenv, dtc }:
|
2023-04-16 20:43:32 +00:00
|
|
|
let
|
|
|
|
uboot = callPackage ./uboot.nix { };
|
|
|
|
opensbi = callPackage ./opensbi.nix {
|
|
|
|
withPayload = "${uboot}/u-boot.bin";
|
|
|
|
withFDT = "${uboot}/starfive_visionfive2.dtb";
|
|
|
|
};
|
2023-04-23 16:11:02 +00:00
|
|
|
spl-tool = pkgsBuildHost.callPackage ./spl-tool.nix { };
|
2023-04-16 20:43:32 +00:00
|
|
|
its-file = writeText "visionfive2-uboot-fit-image.its" ''
|
|
|
|
/dts-v1/;
|
|
|
|
|
|
|
|
/ {
|
|
|
|
description = "U-boot-spl FIT image for JH7110 VisionFive2";
|
|
|
|
#address-cells = <2>;
|
|
|
|
|
|
|
|
images {
|
|
|
|
firmware {
|
|
|
|
description = "u-boot";
|
|
|
|
data = /incbin/("${opensbi}/share/opensbi/lp64/generic/firmware/fw_payload.bin");
|
|
|
|
type = "firmware";
|
|
|
|
arch = "riscv";
|
|
|
|
os = "u-boot";
|
|
|
|
load = <0x0 0x40000000>;
|
|
|
|
entry = <0x0 0x40000000>;
|
|
|
|
compression = "none";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
default = "config-1";
|
|
|
|
|
|
|
|
config-1 {
|
|
|
|
description = "U-boot-spl FIT config for JH7110 VisionFive2";
|
|
|
|
firmware = "firmware";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
inherit opensbi uboot;
|
2023-04-23 16:11:02 +00:00
|
|
|
spl = stdenv.mkDerivation {
|
|
|
|
name = "starfive-visionfive2-spl";
|
|
|
|
depsBuildBuild = [ spl-tool ];
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/starfive-visionfive2/
|
|
|
|
ln -s ${uboot}/u-boot-spl.bin .
|
|
|
|
spl_tool -c -f ./u-boot-spl.bin
|
|
|
|
cp u-boot-spl.bin.normal.out $out/share/starfive-visionfive2/spl.bin
|
|
|
|
'';
|
|
|
|
};
|
2023-04-16 20:43:32 +00:00
|
|
|
uboot-fit-image = stdenv.mkDerivation {
|
|
|
|
name = "starfive-visionfive2-uboot-fit-image";
|
|
|
|
nativeBuildInputs = [ dtc ];
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/starfive-visionfive2/
|
|
|
|
${uboot}/mkimage -f ${its-file} -A riscv -O u-boot -T firmware $out/share/starfive-visionfive2/visionfive2_fw_payload.img
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|