Compare commits

...

6 Commits

8 changed files with 105 additions and 11 deletions

View File

@ -2436,3 +2436,17 @@ Sun Sep 17 16:44:31 BST 2023
Can we figure out which bits of the old doc are missing from the new
one and just transplant those? Then we can merge it sooner
instead of blocking on writig all the new stuff
We need to find a nice place for an introduction to choosing
rootfsType
Mon Sep 18 17:07:56 BST 2023
Let's see if we can hack up an aarch64 qemu port
From https://gist.github.com/oznu/ac9efae7c24fd1f37f1d933254587aa4 :
curl -L https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd -O
dd if=/dev/zero of=flash1.img bs=1M count=64
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=QEMU_EFI.fd of=flash0.img conv=notrunc

View File

@ -0,0 +1,75 @@
# This "device" generates images that can be used with the QEMU
# emulator. The default output is a directory containing separate
# kernel ("Image" format) and root filesystem (squashfs or jffs2)
# images
{
system = {
crossSystem = {
config = "aarch64-unknown-linux-musl";
};
};
module = {pkgs, config, ... }: {
kernel = {
src = pkgs.pkgsBuildBuild.fetchurl {
name = "linux.tar.gz";
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
};
config = {
CPU_LITTLE_ENDIAN= "y";
CPU_BIG_ENDIAN= "n";
VIRTUALIZATION = "y";
PCI_HOST_GENERIC="y";
MTD = "y";
MTD_BLOCK2MTD = "y";
MTD_BLKDEVS = "y";
MTD_BLOCK = "y";
VIRTIO_MENU = "y";
PCI = "y";
VIRTIO_PCI = "y";
BLOCK = "y";
VIRTIO_BLK = "y";
NETDEVICES = "y";
VIRTIO_NET = "y";
# https://stackoverflow.com/a/68340492
CMDLINE="\"earlycon=smh console=ttyAMA0\"";
CMDLINE_FROM_BOOTLOADER = "y";
SERIAL_EARLYCON_ARM_SEMIHOST = "y"; # earlycon=smh
SERIAL_AMBA_PL011 = "y";
SERIAL_AMBA_PL011_CONSOLE = "y";
};
};
hardware =
let
mac80211 = pkgs.mac80211.override {
drivers = ["mac80211_hwsim"];
klibBuild = config.system.outputs.kernel.modulesupport;
};
in {
defaultOutput = "vmroot";
loadAddress = "0x0";
entryPoint = "0x0";
rootDevice = "/dev/mtd1";
flash.eraseBlockSize = "65536"; # c.f. pkgs/mips-vm/mips-vm.sh
networkInterfaces =
let inherit (config.system.service.network) link;
in {
wan = link.build { ifname = "eth0"; };
lan = link.build { ifname = "eth1"; };
wlan_24 = link.build {
ifname = "wlan0";
dependencies = [ mac80211 ];
};
};
};
};
}

View File

@ -6,6 +6,7 @@
} :
let
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
arch = "arm64";
in {
kernel
, commandLine
@ -40,7 +41,7 @@ stdenv.mkDerivation {
buildPhase = ''
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
mkimage -A mips -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n 'MIPS Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage
mkimage -A ${arch} -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n '${arch} Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage
'';
installPhase = ''
cp kernel.uimage $out

View File

@ -56,9 +56,9 @@ in {
MODULE_SIG = if modular then "y" else "n";
DEBUG_FS = "y";
MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE = "y";
MIPS_BOOTLOADER_CMDLINE_COOKIE = "\"liminix\"";
MIPS_CMDLINE_DTB_EXTEND = "y";
# MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE = "y";
# MIPS_BOOTLOADER_CMDLINE_COOKIE = "\"liminix\"";
# MIPS_CMDLINE_DTB_EXTEND = "y";
# basic networking protocols
NET = "y";

View File

@ -76,11 +76,12 @@ in
inherit dtb;
};
# could use trivial-builders.linkFarmFromDrvs here?
vmroot = pkgs.runCommand "qemu" {} ''
vmroot = pkgs.runCommandCC "vmroot" {} ''
mkdir $out
cd $out
ln -s ${config.system.outputs.rootfs} rootfs
ln -s ${kernel} vmlinux
${pkgs.stdenv.cc.targetPrefix}objcopy -O binary -S ${kernel} Image
ln -s ${manifest} manifest
ln -s ${kernel.headers} build
'';

View File

@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
"-I${openssl.dev}/include -L${openssl.out}/lib -L${ncurses.out}/lib";
PKG_CONFIG_PATH = "./pkgconfig";
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
ARCH = "mips"; # kernel uses "mips" here for both mips and mipsel
ARCH = "arm64";
KBUILD_BUILD_HOST = "liminix.builder";
dontStrip = true;
@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
];
patches = [
./cmdline-cookie.patch
# ./cmdline-cookie.patch
];
# this is here to work around what I think is a bug in nixpkgs

View File

@ -42,10 +42,13 @@ fi
INIT=${INIT-/bin/init}
echo $QEMU_OPTIONS
qemu-system-mips \
-M malta -m 256 \
qemu-system-aarch64 \
-M virt -m 512 \
-echr 16 \
-append "liminix default console=ttyS0,38400n8 panic=10 oops=panic init=$INIT loglevel=8 root=/dev/mtdblock0 block2mtd.block2mtd=/dev/vda,65536" \
-append "liminix default earlycon=smh console=ttyAMA0,38400n8 panic=10 oops=panic init=$INIT loglevel=8 root=/dev/mtdblock0 block2mtd.block2mtd=/dev/vda,65536" \
-semihosting \
-cpu cortex-a72 \
-drive file=$rootfs,format=raw,readonly=off,if=virtio,index=0 \
${initramfs} \
-netdev socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1 \

View File

@ -1,7 +1,7 @@
let
nixpkgs = <nixpkgs>;
liminix = (import ./default.nix {
device = (import ./devices/qemu);
device = (import ./devices/qemu-aarch64);
liminix-config = ./vanilla-configuration.nix;
inherit nixpkgs;
});