Booting Linux and userspace OK

This commit is contained in:
Rodrigo Arias 2024-01-19 12:32:06 +01:00
parent c6a304ca7d
commit 9a475bc1e3
5 changed files with 80 additions and 24 deletions

View File

@ -67,7 +67,7 @@ exec qemu-system-riscv64 \
-device loader,addr=0x84000000,file=$system/kernel \ -device loader,addr=0x84000000,file=$system/kernel \
-kernel $system/kernel \ -kernel $system/kernel \
-initrd $system/initrd \ -initrd $system/initrd \
-append "$(cat $system/kernel-params) init=$system/init regInfo=/nix/store/x3zpwfbk2wkiisxhgi7zwsfwbdfxk0w1-closure-info-riscv64-unknown-linux-gnu/registration console=ttyS0,115200n8 loglevel=7 $QEMU_KERNEL_PARAMS" -append "$(cat $system/kernel-params) init=$system/init console=ttyS0,115200n8 loglevel=7 $QEMU_KERNEL_PARAMS"
$QEMU_OPTS \ $QEMU_OPTS \
"$@" "$@"
@ -78,9 +78,9 @@ exec qemu-system-riscv64 \
-kernel ${NIXPKGS_QEMU_KERNEL_visionfive_nix:-/nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/kernel} \ # -kernel ${NIXPKGS_QEMU_KERNEL_visionfive_nix:-/nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/kernel} \
-initrd /nix/store/96058frp51dn0xxfci4kyvzz0rvd5ngy-initrd-linux-riscv64-unknown-linux-gnu-6.1.72/initrd \ # -initrd /nix/store/96058frp51dn0xxfci4kyvzz0rvd5ngy-initrd-linux-riscv64-unknown-linux-gnu-6.1.72/initrd \
-append "$(cat /nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/kernel-params) init=/nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/init regInfo=/nix/store/bgqa92gznhcr9aryx6ac4ycx4s2385cr-closure-info-riscv64-unknown-linux-gnu/registration console=ttyS0,115200n8 console=tty0 $QEMU_KERNEL_PARAMS" \ # -append "$(cat /nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/kernel-params) init=/nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/init regInfo=/nix/store/bgqa92gznhcr9aryx6ac4ycx4s2385cr-closure-info-riscv64-unknown-linux-gnu/registration console=ttyS0,115200n8 console=tty0 $QEMU_KERNEL_PARAMS" \
# -drive "file=$NIX_DISK_IMAGE,if=virtio,id=hd0" \ # -drive "file=$NIX_DISK_IMAGE,if=virtio,id=hd0" \

View File

@ -3,27 +3,16 @@
{ {
imports = [ imports = [
"${modulesPath}/profiles/base.nix" "${modulesPath}/profiles/base.nix"
#"${modulesPath}/virtualisation/qemu-vm.nix"
]; ];
networking.hostName = "visionfive-nix"; networking.hostName = "visionfive-nix";
boot = { # boot = {
kernelParams = [ "boot.shell_on_fail" ]; # loader = {
consoleLogLevel = lib.mkDefault 7; # grub.enable = false;
initrd.kernelModules = [ # generic-extlinux-compatible.enable = true;
"virtio_pci" # };
"virtio_blk" # };
"virtio_input"
"9pnet"
"9pnet_virtio"
];
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
};
nixpkgs.overlays = [ (import ./overlay.nix) ]; nixpkgs.overlays = [ (import ./overlay.nix) ];
@ -31,4 +20,6 @@
services.openssh.enable = true; services.openssh.enable = true;
system.stateVersion = "24.05"; system.stateVersion = "24.05";
boot.kernelPackages = lib.mkForce pkgs.linuxPackagesCustom;
} }

View File

@ -13,8 +13,11 @@
overlay = import ./overlay.nix; overlay = import ./overlay.nix;
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
modules = [ modules = [
# For now we only define a config for VM, later we will want to split
# this into different configs.
./vm.nix
./configuration.nix ./configuration.nix
#"${nixos-hardware}/starfive/visionfive/v2/sd-image-installer.nix"
]; ];
in { in {
overlay = import ./overlay.nix; overlay = import ./overlay.nix;
@ -47,8 +50,8 @@
let let
nixosconf = self.nixosConfigurations.cross; nixosconf = self.nixosConfigurations.cross;
syspkgs = nixosconf.pkgs; syspkgs = nixosconf.pkgs;
#toplevel = nixosconf.config.system.build.toplevel; toplevel = nixosconf.config.system.build.toplevel;
toplevel = "${nixosconf.config.system.build.vm}/system"; #toplevel = "${nixosconf.config.system.build.vm}/system";
in in
pkgs.mkShell { pkgs.mkShell {
pname = "qemu-shell"; pname = "qemu-shell";

View File

@ -35,4 +35,37 @@ final: prev:
"FW_PAYLOAD_PATH=${final.uboot-custom}/u-boot.bin" "FW_PAYLOAD_PATH=${final.uboot-custom}/u-boot.bin"
]; ];
}); });
linuxPackagesCustom = prev.linuxPackagesFor (prev.linux.override {
structuredExtraConfig = with prev.lib.kernel; {
KEXEC = yes;
SERIAL_8250_DW = yes;
PINCTRL_STARFIVE = yes;
# Doesn't build as a module
DW_AXI_DMAC_STARFIVE = yes;
# stmmac hangs when built as a module
#PTP_1588_CLOCK = yes;
#STMMAC_ETH = yes;
#STMMAC_PCI = yes;
# For qemu
BLOCK = yes;
BLK_DEV = yes;
DEVTMPFS = yes;
VIRTIO_MENU = yes;
VIRTIO_BLK = yes;
# For 9P: https://wiki.qemu.org/Documentation/9psetup
NET_9P = yes;
NET_9P_VIRTIO = yes;
NET_9P_DEBUG = yes;
"9P_FS" = yes;
"9P_FS_POSIX_ACL" = yes;
PCI = yes;
VIRTIO_PCI = yes;
PCI_HOST_GENERIC = yes;
};
});
} }

29
vm.nix Normal file
View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, modulesPath, ... }:
# Contains the configuration to make a VM bootable with qemu.
{
imports = [
"${modulesPath}/virtualisation/qemu-vm.nix"
];
boot = {
kernelParams = [ "boot.shell_on_fail" ];
consoleLogLevel = lib.mkDefault 7;
initrd.kernelModules = [
"virtio_pci"
"virtio_blk"
"virtio_input"
"9pnet"
"9pnet_virtio"
];
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
};
virtualisation.diskImage = null;
}