Compare commits

..

10 Commits

Author SHA1 Message Date
Florian Agbuya 4a93e91fae zynq_image: add various fixes 2023-11-24 10:09:56 +08:00
Florian Agbuya 2d2796c3a0 flake: update some inputs 2023-11-24 10:08:48 +08:00
Florian Agbuya 03eaa5b0c4 flake: add u-boot and fsbl 2023-11-24 10:08:12 +08:00
Florian Agbuya abac1cc5b0 revert to mainline kernel
Signed-off-by: Florian Agbuya <fa@m-labs.ph>
2023-11-14 11:44:55 +08:00
Florian Agbuya 9f00247e8f zynq_image: disable video and sound support
Signed-off-by: Florian Agbuya <fa@m-labs.ph>
2023-11-14 10:12:45 +08:00
Florian Agbuya a8542697f1 use the linux xilinx fork for the kernel
Signed-off-by: Florian Agbuya <fa@m-labs.ph>
2023-11-13 13:50:16 +08:00
Florian Agbuya 861dd9d8a9 add linux xilinx fork
Signed-off-by: Florian Agbuya <fa@m-labs.ph>
2023-11-13 13:47:57 +08:00
Florian Agbuya 5d823d57b3 gitignore: add 'tmp' folder 2023-11-08 15:57:52 +08:00
Florian Agbuya 09cd531c2b zynq_image: fix image size for qemu 2023-11-08 15:56:56 +08:00
Florian Agbuya 62a97f5510 zynq_image: fix formatting 2023-11-08 15:13:04 +08:00
4 changed files with 162 additions and 40 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
result
tmp

View File

@ -16,7 +16,39 @@
"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": {
"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": {
"lastModified": 1697730408,
"narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=",
@ -30,10 +62,26 @@
"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": {
"inputs": {
"firmware": "firmware",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1699416673,
@ -51,7 +99,28 @@
},
"root": {
"inputs": {
"not-os": "not-os"
"nixpkgs": "nixpkgs",
"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,9 +1,56 @@
{
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, 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
platforms = (import not-os.inputs.nixpkgs { config = {}; }).platforms;
eval = (import "${not-os}" {

View File

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