Compare commits

..

No commits in common. "4a93e91faeb562cc709761c0a0cf8576dbf61e1b" and "9bb6f1171ca4366b83c7bc71a765480c2c640d48" have entirely different histories.

4 changed files with 40 additions and 162 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
result result
tmp

View File

@ -16,39 +16,7 @@
"type": "github" "type": "github"
} }
}, },
"mozilla-overlay": {
"flake": false,
"locked": {
"lastModified": 1695805681,
"narHash": "sha256-1ElPLD8eFfnuIk0G52HGGpRtQZ4QPCjChRlEOfkZ5ro=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "6eabade97bc28d707a8b9d82ad13ef143836736e",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1700390070,
"narHash": "sha256-de9KYi8rSJpqvBfNwscWdalIJXPo8NjdIZcEJum1mH0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e4ad989506ec7d71f7302cc3067abd82730a4beb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1697730408, "lastModified": 1697730408,
"narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=", "narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=",
@ -62,26 +30,10 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1697655685,
"narHash": "sha256-79Kuv+QdgsVc+rkibuAgWHnh8IXrLBTOKg5nM0Qvux0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "80c1aab725151632ddc2a20caeb914e76dd0673c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"not-os": { "not-os": {
"inputs": { "inputs": {
"firmware": "firmware", "firmware": "firmware",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1699416673, "lastModified": 1699416673,
@ -99,28 +51,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "not-os": "not-os"
"not-os": "not-os",
"zynq-rs": "zynq-rs"
}
},
"zynq-rs": {
"inputs": {
"mozilla-overlay": "mozilla-overlay",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1700454627,
"narHash": "sha256-IWfZIlLHYdY6ockkP6QEDpOUU9wqdRXZ5cMqt8FnThU=",
"ref": "refs/heads/master",
"rev": "24c804e6f04256cbdd84b496f9022d36f8c5d613",
"revCount": 631,
"type": "git",
"url": "https://git.m-labs.hk/m-labs/zynq-rs"
},
"original": {
"type": "git",
"url": "https://git.m-labs.hk/m-labs/zynq-rs"
} }
} }
}, },

View File

@ -1,69 +1,22 @@
{ {
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 }: outputs = { self, not-os }: {
let packages.armv7l-linux = let
pkgs = import nixpkgs { system = "x86_64-linux"; }; platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms;
zynqpkgs = zynq-rs.packages.x86_64-linux; eval = (import "${not-os}" {
extraModules = [
build = { target ? "zc706" }: let ./zynq_image.nix
fsbl = zynqpkgs."${target}-fsbl"; ];
platform = system: platforms.armv7l-hf-multiplatform;
u-boot = pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot { system = "x86_64-linux";
defconfig = "xilinx_zynq_virt_defconfig"; crossSystem.system = "armv7l-linux";
preConfigure = '' inherit (not-os.inputs) nixpkgs;
export DEVICE_TREE=zynq-zc706 });
''; in {
extraMeta.platforms = ["armv7l-linux"]; zynq_image = eval.config.system.build.zynq_image;
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;
};
}; };
};
} }

View File

@ -5,13 +5,9 @@
let let
# dont use overlays for the qemu, it causes a lot of wasted time on recompiles # dont use overlays for the qemu, it causes a lot of wasted time on recompiles
x86pkgs = import pkgs.path { system = "x86_64-linux"; }; x86pkgs = import pkgs.path { system = "x86_64-linux"; };
build = config.system.build;
customKernel = pkgs.linux.override { customKernel = pkgs.linux.override {
extraConfig = '' extraConfig = ''
OVERLAY_FS y OVERLAY_FS y
CORESIGHT_LINKS_AND_SINKS m
CORESIGHT_SINK_TPIU m
CORESIGHT_SOURCE_ETM3X m
''; '';
}; };
customKernelPackages = pkgs.linuxPackagesFor customKernel; customKernelPackages = pkgs.linuxPackagesFor customKernel;
@ -19,27 +15,26 @@ in {
boot.kernelPackages = customKernelPackages; boot.kernelPackages = customKernelPackages;
nixpkgs.system = "armv7l-linux"; nixpkgs.system = "armv7l-linux";
system.build.zynq_image = let system.build.zynq_image = let
cmdline = "root=/dev/mmcblk0 console=ttyPS0,115200n8 systemConfig=${builtins.unsafeDiscardStringContext build.toplevel}"; cmdline = "root=/dev/mmcblk0 console=ttyPS0,115200n8 systemConfig=${builtins.unsafeDiscardStringContext config.system.build.toplevel}";
qemuScript = '' qemuScript = ''
#!/bin/bash -v #!/bin/bash -v
export PATH=${x86pkgs.qemu}/bin:$PATH export PATH=${x86pkgs.qemu}/bin:$PATH
set -x set -x
base=$(dirname $0) base=$(dirname $0)
mkdir ./tmp/ cp $base/root.squashfs /tmp/
cp $base/root.squashfs ./tmp/ chmod +w /tmp/root.squashfs
chmod +w ./tmp/root.squashfs truncate -s 64m /tmp/root.squashfs
truncate -s 64M ./tmp/root.squashfs
qemu-system-arm \ qemu-system-arm \
-M xilinx-zynq-a9 \ -M xilinx-zynq-a9 \
-serial /dev/null \ -serial /dev/null \
-serial stdio \ -serial stdio \
-display none \ -display none \
-dtb $base/zynq-zc706.dtb \ -dtb $base/zynq-zc702.dtb \
-kernel $base/zImage \ -kernel $base/zImage \
-initrd $base/initrd \ -initrd $base/initrd \
-drive file=./tmp/root.squashfs,if=sd,format=raw \ -drive file=/tmp/root.squashfs,if=sd,format=raw \
-append "${cmdline}" -append "${cmdline}"
''; '';
in pkgs.runCommand "zynq_image" { in pkgs.runCommand "zynq_image" {
@ -49,11 +44,11 @@ in {
} '' } ''
mkdir $out mkdir $out
cd $out cd $out
cp ${build.squashfs} root.squashfs cp -s ${config.system.build.squashfs} root.squashfs
cp ${build.kernel}/*zImage . cp -s ${config.system.build.kernel}/*zImage .
cp ${build.initialRamdisk}/initrd initrd cp -s ${config.system.build.initialRamdisk}/initrd initrd
cp ${build.kernel}/dtbs/zynq-zc706.dtb . cp -s ${config.system.build.kernel}/dtbs/zynq-zc702.dtb .
ln -sv ${build.toplevel} toplevel ln -sv ${config.system.build.toplevel} toplevel
cp $qemuScriptPath qemu-script cp $qemuScriptPath qemu-script
chmod +x qemu-script chmod +x qemu-script
patchShebangs qemu-script patchShebangs qemu-script
@ -61,33 +56,33 @@ in {
''; '';
system.build.rpi_image_tar = pkgs.runCommand "dist.tar" {} '' system.build.rpi_image_tar = pkgs.runCommand "dist.tar" {} ''
mkdir -p $out/nix-support mkdir -p $out/nix-support
tar -cvf $out/dist.tar ${build.rpi_image} tar -cvf $out/dist.tar ${config.system.build.rpi_image}
echo "file binary-dist $out/dist.tar" >> $out/nix-support/hydra-build-products echo "file binary-dist $out/dist.tar" >> $out/nix-support/hydra-build-products
''; '';
environment.systemPackages = [ pkgs.strace ]; environment.systemPackages = [ pkgs.strace ];
environment.etc."service/getty/run".source = pkgs.writeShellScript "getty" '' environment.etc."service/getty/run".source = pkgs.writeShellScript "getty" ''
bash </dev/ttyPS0 >/dev/ttyPS0 agetty ttyPS0 115200
''; '';
environment.etc."pam.d/other".text = ""; environment.etc."pam.d/other".text = "";
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { (self: super: {
# armv7l cross-compile fixes # armv7l cross-compile fixes
libuv = super.libuv.overrideAttrs (old: { doCheck = false;}); libuv = super.libuv.overrideAttrs (old: {
elfutils = super.elfutils.overrideAttrs (old: { doCheck = false; doInstallCheck = false;}); doCheck = false;
});
elfutils = super.elfutils.overrideAttrs (old: {
doCheck = false;
doInstallCheck = false;
});
systemd = super.systemd.override { withEfi = false; }; systemd = super.systemd.override { withEfi = false; };
procps = super.procps.override { withSystemd = false; }; procps = super.procps.override { withSystemd = false; };
nix = super.nix.override { enableDocumentation = false; }; nix = super.nix.override { enableDocumentation = false; };
# closure size fixes # closure size fixes
openssh = super.openssh.override { withFIDO = false; withKerberos = false; }; openssh = super.openssh.override { withFIDO = false; withKerberos = false; };
util-linux = super.util-linux.override { util-linux = super.util-linux.override { pamSupport=false; capabilitiesSupport=false; ncursesSupport=false; systemdSupport=false; nlsSupport=false; translateManpages=false; };
pamSupport=false;
capabilitiesSupport=false;
ncursesSupport=false;
systemdSupport=false;
nlsSupport=false;
translateManpages=false; };
utillinuxCurses = self.util-linux; utillinuxCurses = self.util-linux;
utillinuxMinimal = self.util-linux; utillinuxMinimal = self.util-linux;
}) })