From 03eaa5b0c404201fb0f573835230313f6e76a8e0 Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Fri, 24 Nov 2023 10:08:12 +0800 Subject: [PATCH] flake: add u-boot and fsbl --- flake.nix | 77 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index 8b343d6..272ffa0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,22 +1,69 @@ { 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.zynq-rs.url = git+https://git.m-labs.hk/m-labs/zynq-rs; - outputs = { self, not-os }: { - packages.armv7l-linux = let - platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms; - eval = (import "${not-os}" { - extraModules = [ - ./zynq_image.nix - ]; - platform = system: platforms.armv7l-hf-multiplatform; - system = "x86_64-linux"; - crossSystem.system = "armv7l-linux"; - inherit (not-os.inputs) nixpkgs; - }); - in { - zynq_image = eval.config.system.build.zynq_image; + 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"; }); + + packages.armv7l-linux = let + platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms; + eval = (import "${not-os}" { + extraModules = [ + ./zynq_image.nix + ]; + platform = system: platforms.armv7l-hf-multiplatform; + system = "x86_64-linux"; + crossSystem.system = "armv7l-linux"; + inherit (not-os.inputs) nixpkgs; + }); + in { + zynq_image = eval.config.system.build.zynq_image; + }; }; - }; } \ No newline at end of file