qemu: use phram instead of block2mtd

This commit is contained in:
Daniel Barlow 2023-11-05 19:13:51 +00:00
parent 46991e2761
commit c40eef25d6
5 changed files with 12 additions and 8 deletions

View file

@ -26,8 +26,9 @@
PCI_HOST_GENERIC="y";
MTD = "y";
MTD_BLOCK2MTD = "y";
MTD_BLOCK = "y";
MTD_CMDLINE_PARTS = "y";
MTD_PHRAM = "y";
VIRTIO_MENU = "y";
PCI = "y";

View file

@ -52,8 +52,9 @@
CPU_MIPS32_R2= "y";
MTD = "y";
MTD_BLOCK2MTD = "y";
MTD_BLOCK = "y";
MTD_CMDLINE_PARTS = "y";
MTD_PHRAM = "y";
VIRTIO_MENU = "y";
PCI = "y";

View file

@ -10,7 +10,7 @@
OF = "y";
USE_OF = "y";
};
hardware.ram.startAddress = lim.parseInt "0x0";
hardware.ram.startAddress = lim.parseInt "0x80000000";
boot.commandLine = [
"console=ttyS0,115200" # true of all mips we've yet encountered
];

View file

@ -84,6 +84,7 @@ in
(if pkgs.stdenv.hostPlatform.isAarch
then "${pkgs.stdenv.cc.targetPrefix}objcopy -O binary -R .comment -S ${kernel} $out"
else "cp ${kernel} $out");
phram_address = lib.toHexString (config.hardware.ram.startAddress + 256 * 1024 * 1024);
in pkgs.runCommandCC "vmroot" {} ''
mkdir $out
cd $out
@ -94,7 +95,7 @@ in
echo ${cmdline} > commandline
cat > run.sh << EOF
#!${pkgs.runtimeShell}
CMDLINE=${cmdline} ${pkgs.pkgsBuildBuild.run-liminix-vm}/bin/run-liminix-vm --arch ${pkgs.stdenv.hostPlatform.qemuArch} \$* ${makeBootableImage} ${config.system.outputs.rootfs}
CMDLINE=${cmdline} PHRAM_ADDRESS=0x${phram_address} ${pkgs.pkgsBuildBuild.run-liminix-vm}/bin/run-liminix-vm --arch ${pkgs.stdenv.hostPlatform.qemuArch} \$* ${makeBootableImage} ${config.system.outputs.rootfs}
EOF
chmod +x run.sh
'';

View file

@ -54,13 +54,14 @@ case "$arch" in
;;
esac
INIT=${INIT-/bin/init}
phram="mtdparts=phram0:16M(rootfs) phram.phram=phram0,${PHRAM_ADDRESS},16Mi,65536 root=/dev/mtdblock0";
set -x
$QEMU \
-m 256 \
-m 272 \
-echr 16 \
-append "$CMDLINE liminix root=/dev/mtdblock0 block2mtd.block2mtd=/dev/vda,65536" \
-drive file=$rootfs,format=raw,readonly=off,if=virtio,index=0 \
-append "$CMDLINE liminix $phram" \
-device loader,file=$rootfs,addr=$PHRAM_ADDRESS \
${initramfs} \
-netdev socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1 \
-device virtio-net,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d:ea:21:02 \