flake: add u-boot and fsbl

This commit is contained in:
Florian Agbuya 2023-11-24 10:08:12 +08:00
parent abac1cc5b0
commit 03eaa5b0c4
1 changed files with 62 additions and 15 deletions

View File

@ -1,9 +1,56 @@
{ {
description = "Not-OS port to the Zynq-7000 platform"; description = "Not-OS port to the Zynq-7000 platform";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
inputs.not-os.url = github:cleverca22/not-os; inputs.not-os.url = github:cleverca22/not-os;
inputs.zynq-rs.url = git+https://git.m-labs.hk/m-labs/zynq-rs;
outputs = { self, nixpkgs, not-os, zynq-rs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
zynqpkgs = zynq-rs.packages.x86_64-linux;
build = { target ? "zc706" }: let
fsbl = zynqpkgs."${target}-fsbl";
u-boot = pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
defconfig = "xilinx_zynq_virt_defconfig";
preConfigure = ''
export DEVICE_TREE=zynq-zc706
'';
extraMeta.platforms = ["armv7l-linux"];
filesToInstall = ["u-boot.elf"];
};
fsbl-sd = pkgs.runCommand "${target}-fsbl-sd"
{
buildInputs = [ zynqpkgs.mkbootimage ];
}
''
bifdir=`mktemp -d`
cd $bifdir
ln -s ${fsbl}/fsbl.elf fsbl.elf
ln -s ${u-boot}/u-boot.elf u-boot.elf
cat > boot.bif << EOF
the_ROM_image:
{
[bootloader]fsbl.elf
u-boot.elf
}
EOF
mkdir $out $out/nix-support
mkbootimage boot.bif $out/boot.bin
echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
'';
in {
"${target}-fsbl-sd" = fsbl-sd;
};
in rec {
packages.x86_64-linux = {
zc706-fsbl = zynqpkgs.zc706-fsbl;
} // (build { target = "zc706"; });
outputs = { self, not-os }: {
packages.armv7l-linux = let packages.armv7l-linux = let
platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms; platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms;
eval = (import "${not-os}" { eval = (import "${not-os}" {