This commit is contained in:
Sebastien Bourdeauducq 2023-11-28 18:35:56 +08:00
parent ae4d4c97b6
commit ac4d1dfdce
2 changed files with 36 additions and 65 deletions

View File

@ -17,22 +17,6 @@
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1701053011,
"narHash": "sha256-8QQ7rFbKFqgKgLoaXVJRh7Ik5LtI3pyBBCfOnNOGkF0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5b528f99f73c4fad127118a8c1126b5e003b01a9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1700794826, "lastModified": 1700794826,
"narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=", "narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=",
@ -72,7 +56,6 @@
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"not-os": "not-os" "not-os": "not-os"
} }
} }

View File

@ -1,16 +1,13 @@
{ {
description = "Not-OS port to the Zynq-7000 platform"; description = "Firmware for Sinara Fast-Servo based on Not-OS and Linien";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05; inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.not-os.url = github:cleverca22/not-os; inputs.not-os.url = github:cleverca22/not-os;
inputs.not-os.inputs.nixpkgs.follows = "nixpkgs"; inputs.not-os.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nixpkgs-unstable, not-os }: outputs = { self, nixpkgs, not-os }:
let let
pkgs = import nixpkgs { system = "x86_64-linux"; }; pkgs = import nixpkgs { system = "x86_64-linux"; };
# To be used for building u-boot.
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
gnu-platform = "arm-none-eabi"; gnu-platform = "arm-none-eabi";
@ -178,63 +175,54 @@
dontFixup = true; dontFixup = true;
}; };
# U-boot needs the recent patch in master to fix cross-compile issues. u-boot = { board ? "zc706" }: pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
# See https://github.com/NixOS/nixpkgs/pull/265411.
u-boot = pkgs-unstable.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
defconfig = "xilinx_zynq_virt_defconfig"; defconfig = "xilinx_zynq_virt_defconfig";
preConfigure = '' preConfigure = ''
export DEVICE_TREE=zynq-zc706 export DEVICE_TREE=zynq-${board}
''; '';
extraMeta.platforms = ["armv7l-linux"]; extraMeta.platforms = ["armv7l-linux"];
filesToInstall = ["u-boot.elf"]; filesToInstall = ["u-boot.elf"];
}; };
build = { target ? "zc706" }: let bootimage = { board ? "zc706" }: pkgs.runCommand "${board}-bootimage"
fsblDrv = fsbl { board = "zc706"; }; {
u-bootDrv = u-boot; buildInputs = [ mkbootimage ];
}
bootimage = pkgs.runCommand "${target}-bootimage" ''
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
cat > boot.bif << EOF
the_ROM_image:
{ {
buildInputs = [ mkbootimage ]; [bootloader]fsbl.elf
u-boot.elf
} }
'' EOF
bifdir=`mktemp -d` mkdir $out $out/nix-support
cd $bifdir mkbootimage boot.bif $out/boot.bin
ln -s ${fsblDrv}/fsbl.elf fsbl.elf echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
ln -s ${u-bootDrv}/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}-bootimage" = bootimage;
};
in rec {
packages.x86_64-linux = {
inherit mkbootimage u-boot;
zc706-fsbl = fsbl { board = "zc706"; };
} // (build { target = "zc706"; });
packages.armv7l-linux = let not-os-configured = (import "${not-os}" {
platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms; inherit nixpkgs;
eval = (import "${not-os}" {
extraModules = [ extraModules = [
"${not-os}/zynq_image.nix" "${not-os}/zynq_image.nix"
]; ];
platform = system: platforms.armv7l-hf-multiplatform; platform = system: (import nixpkgs { config = {}; }).platforms.armv7l-hf-multiplatform;
system = "x86_64-linux"; system = "x86_64-linux";
crossSystem.system = "armv7l-linux"; crossSystem.system = "armv7l-linux";
inherit (not-os.inputs) nixpkgs;
}); });
in { in {
zynq_image = eval.config.system.build.zynq_image; packages.x86_64-linux = {
inherit mkbootimage;
};
packages.armv7l-linux = {
zc706-u-boot = u-boot { board = "zc706"; };
zc706-fsbl = fsbl { board = "zc706"; };
zc706-bootimage = bootimage { board = "zc706"; };
zc706-not-os = not-os-configured.config.system.build.zynq_image;
}; };
}; };
} }