zynq_image: add various fixes

This commit is contained in:
Florian Agbuya 2023-11-24 10:09:56 +08:00
parent 2d2796c3a0
commit 4a93e91fae
1 changed files with 13 additions and 10 deletions

View File

@ -5,10 +5,13 @@
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"; };
# armv7l cross-compile and boot fixes 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;
@ -16,7 +19,7 @@ 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 config.system.build.toplevel}"; cmdline = "root=/dev/mmcblk0 console=ttyPS0,115200n8 systemConfig=${builtins.unsafeDiscardStringContext build.toplevel}";
qemuScript = '' qemuScript = ''
#!/bin/bash -v #!/bin/bash -v
export PATH=${x86pkgs.qemu}/bin:$PATH export PATH=${x86pkgs.qemu}/bin:$PATH
@ -33,7 +36,7 @@ in {
-serial /dev/null \ -serial /dev/null \
-serial stdio \ -serial stdio \
-display none \ -display none \
-dtb $base/zynq-zc702.dtb \ -dtb $base/zynq-zc706.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 \
@ -46,11 +49,11 @@ in {
} '' } ''
mkdir $out mkdir $out
cd $out cd $out
cp -s ${config.system.build.squashfs} root.squashfs cp ${build.squashfs} root.squashfs
cp -s ${config.system.build.kernel}/*zImage . cp ${build.kernel}/*zImage .
cp -s ${config.system.build.initialRamdisk}/initrd initrd cp ${build.initialRamdisk}/initrd initrd
cp -s ${config.system.build.kernel}/dtbs/zynq-zc702.dtb . cp ${build.kernel}/dtbs/zynq-zc706.dtb .
ln -sv ${config.system.build.toplevel} toplevel ln -sv ${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
@ -58,12 +61,12 @@ 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 ${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 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" ''
agetty ttyPS0 115200 bash </dev/ttyPS0 >/dev/ttyPS0
''; '';
environment.etc."pam.d/other".text = ""; environment.etc."pam.d/other".text = "";