forked from M-Labs/nix-servo
refactor build script for better board management
This commit is contained in:
parent
073f1c9bbd
commit
25ef8fa486
74
flake.nix
74
flake.nix
@ -169,7 +169,17 @@
|
||||
hardeningDisable = [ "fortify" ];
|
||||
};
|
||||
|
||||
fsbl = { board ? "zc706" }: pkgs.stdenv.mkDerivation {
|
||||
# Pinned qemu version due to networking errors in recent version 8.2.0
|
||||
qemu = pkgs.qemu.overrideAttrs (oldAttrs: rec {
|
||||
version = "8.1.3";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://download.qemu.org/qemu-${version}.tar.xz";
|
||||
hash = "sha256-Q8wXaAQQVYb3T5A5jzTp+FeH3/QA07ZA2B93efviZbs=";
|
||||
};
|
||||
});
|
||||
|
||||
board-package-set = { board }: let
|
||||
fsbl = pkgs.stdenv.mkDerivation {
|
||||
name = "${board}-fsbl";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Xilinx";
|
||||
@ -204,7 +214,7 @@
|
||||
dontFixup = true;
|
||||
};
|
||||
|
||||
u-boot = { board ? "zc706" }: (pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
|
||||
u-boot = (pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
|
||||
defconfig = "xilinx_zynq_virt_defconfig";
|
||||
patches = [] ++ pkgs.lib.optional (board == "fast-servo") ./fast-servo/u-boot.patch;
|
||||
preConfigure = ''
|
||||
@ -237,15 +247,15 @@
|
||||
'';
|
||||
});
|
||||
|
||||
bootimage = { board ? "zc706" }: pkgs.runCommand "${board}-bootimage"
|
||||
bootimage = pkgs.runCommand "${board}-bootimage"
|
||||
{
|
||||
buildInputs = [ mkbootimage ];
|
||||
}
|
||||
''
|
||||
bifdir=`mktemp -d`
|
||||
cd $bifdir
|
||||
ln -s ${fsbl { inherit board; }}/fsbl.elf fsbl.elf
|
||||
ln -s ${u-boot { inherit board; }}/u-boot.elf u-boot.elf
|
||||
ln -s ${fsbl}/fsbl.elf fsbl.elf
|
||||
ln -s ${u-boot}/u-boot.elf u-boot.elf
|
||||
cat > boot.bif << EOF
|
||||
the_ROM_image:
|
||||
{
|
||||
@ -258,7 +268,7 @@
|
||||
echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
dtb = { board ? "zc706" }: pkgs.runCommand "dtb"
|
||||
dtb = pkgs.runCommand "dtb"
|
||||
{
|
||||
buildInputs = [ pkgs.gcc pkgs.dtc ];
|
||||
}
|
||||
@ -266,11 +276,11 @@
|
||||
mkdir -p $out
|
||||
DTSDIR=$(mktemp -d /tmp/dts-XXXXXX)
|
||||
cd $DTSDIR
|
||||
cp ${u-boot { inherit board; }}/dts/zynq-${board}.dts .
|
||||
cp ${u-boot}/dts/zynq-${board}.dts .
|
||||
|
||||
if [ ${board} == "zc706" ]; then
|
||||
mv zynq-${board}.dts zynq-${board}-top.dts
|
||||
cp ${u-boot { inherit board; }}/dts/zynq-7000.dtsi .
|
||||
cp ${u-boot}/dts/zynq-7000.dtsi .
|
||||
gcc -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o zynq-${board}.dts zynq-${board}-top.dts
|
||||
fi
|
||||
|
||||
@ -279,7 +289,7 @@
|
||||
rm -rf $DTSDIR
|
||||
'';
|
||||
|
||||
sd-image = { board ? "zc706" }: let
|
||||
sd-image = let
|
||||
rootfsImage = pkgs.callPackage (pkgs.path + "/nixos/lib/make-ext4-fs.nix") {
|
||||
storePaths = [ not-os-cfg.build.toplevel ];
|
||||
volumeLabel = "ROOT";
|
||||
@ -320,8 +330,8 @@
|
||||
faketime "1970-01-01 00:00:00" mkfs.vfat -n BOOT firmware_part.img
|
||||
|
||||
mkdir firmware
|
||||
cp ${bootimage { inherit board; }}/boot.bin firmware/
|
||||
cp ${dtb { inherit board; }}/${board}.dtb firmware/
|
||||
cp ${bootimage}/boot.bin firmware/
|
||||
cp ${dtb}/${board}.dtb firmware/
|
||||
cp ${not-os-cfg.build.kernel}/uImage firmware/
|
||||
cp ${not-os-cfg.build.uRamdisk}/initrd firmware/uRamdisk.image.gz
|
||||
|
||||
@ -330,16 +340,7 @@
|
||||
'';
|
||||
};
|
||||
|
||||
# Pinned qemu version due to networking errors in recent version 8.2.0
|
||||
qemu = pkgs.qemu.overrideAttrs (oldAttrs: rec {
|
||||
version = "8.1.3";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://download.qemu.org/qemu-${version}.tar.xz";
|
||||
hash = "sha256-Q8wXaAQQVYb3T5A5jzTp+FeH3/QA07ZA2B93efviZbs=";
|
||||
};
|
||||
});
|
||||
|
||||
not-os-qemu = { board ? "zc706" }: let
|
||||
not-os-qemu = let
|
||||
qemuScript = ''
|
||||
#!/bin/bash
|
||||
export PATH=${qemu}/bin:$PATH
|
||||
@ -368,31 +369,28 @@
|
||||
''
|
||||
mkdir $out
|
||||
cd $out
|
||||
cp -s ${u-boot { inherit board; }}/u-boot.elf .
|
||||
cp -s ${sd-image { inherit board; }}/sd-image/sd-image.img .
|
||||
cp -s ${u-boot}/u-boot.elf .
|
||||
cp -s ${sd-image}/sd-image/sd-image.img .
|
||||
cp $qemuScriptPath qemu-script
|
||||
chmod +x qemu-script
|
||||
patchShebangs qemu-script
|
||||
'';
|
||||
in {
|
||||
"${board}-fsbl" = fsbl;
|
||||
"${board}-u-boot" = u-boot;
|
||||
"${board}-bootimage" = bootimage;
|
||||
"${board}-dtb" = dtb;
|
||||
"${board}-sd-image" = sd-image;
|
||||
"${board}-qemu" = not-os-qemu;
|
||||
};
|
||||
in rec {
|
||||
packages.x86_64-linux = {
|
||||
inherit mkbootimage;
|
||||
};
|
||||
packages.armv7l-linux = {
|
||||
not-os = not-os-cfg.build.zynq_image;
|
||||
zc706-fsbl = fsbl { board = "zc706"; };
|
||||
zc706-u-boot = u-boot { board = "zc706"; };
|
||||
zc706-bootimage = bootimage { board = "zc706"; };
|
||||
zc706-dtb = dtb { board = "zc706"; };
|
||||
zc706-sd-image = sd-image { board = "zc706"; };
|
||||
zc706-qemu = not-os-qemu { board = "zc706"; };
|
||||
fast-servo-fsbl = fsbl { board = "fast-servo"; };
|
||||
fast-servo-u-boot = u-boot { board = "fast-servo"; };
|
||||
fast-servo-bootimage = bootimage { board = "fast-servo"; };
|
||||
fast-servo-dtb = dtb { board = "fast-servo"; };
|
||||
fast-servo-sd-image = sd-image { board = "fast-servo"; };
|
||||
fast-servo-qemu = not-os-qemu { board = "fast-servo"; };
|
||||
};
|
||||
packages.armv7l-linux =
|
||||
(board-package-set { board = "zc706"; }) //
|
||||
(board-package-set { board = "fast-servo"; });
|
||||
|
||||
hydraJobs = packages.x86_64-linux // packages.armv7l-linux;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user