From e6f4512554b7300eed60c1caf58267061eb4f0d9 Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Mon, 29 Jan 2024 15:28:17 +0800 Subject: [PATCH] add device-tree builder --- flake.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/flake.nix b/flake.nix index 30e876b..e11b5c1 100644 --- a/flake.nix +++ b/flake.nix @@ -189,6 +189,27 @@ dontFixup = true; }; + device-tree = { board ? "zc706" }: let + dts = ./fast-servo/device-tree; + in pkgs.runCommand "device-tree" + { + buildInputs = [ pkgs.gcc pkgs.dtc ]; + } + '' + mkdir -p $out + if [ "${board}" = "fast-servo" ]; then + gcc -I ${dts} -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o fast-servo.dts ${dts}/system-top.dts + dtc -I dts -O dtb -o fast-servo.dtb fast-servo.dts + chmod +x fast-servo.dtb + cp fast-servo.dtb $out + elif [ "${board}" = "zc706" ]; then + cp ${not-os-cfg.build.kernel}/dtbs/zynq-zc706.dtb $out + else + echo "Unsupported board type: ${board}" + exit 1 + fi + ''; + u-boot = { board ? "zc706" }: pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot { defconfig = "xilinx_zynq_virt_defconfig"; patches = [] ++ pkgs.lib.optional (board == "fast-servo") ./fast-servo/u-boot.patch; @@ -349,10 +370,12 @@ packages.armv7l-linux = { zc706-fsbl = fsbl { board = "zc706"; }; zc706-bootimage = bootimage { board = "zc706"; }; + zc706-dtb = device-tree { board = "zc706"; }; zc706-u-boot = u-boot { board = "zc706"; }; zc706-qemu = not-os-qemu { board = "zc706"; }; zc706-sd-image = sd-image { board = "zc706"; }; zc706-not-os = not-os-cfg.build.zynq_image; + fast-servo-dtb = device-tree { board = "fast-servo"; }; fast-servo-u-boot = u-boot { board = "fast-servo"; }; }; hydraJobs = packages.x86_64-linux // packages.armv7l-linux;