Booting
This commit is contained in:
parent
e59cf267a7
commit
a6a958a9df
1
base.nix
1
base.nix
@ -6,6 +6,7 @@
|
||||
# RISC-V Quirks and patches, should be upstreamed
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
hpcg = prev.callPackage ./examples/hpcg.nix { };
|
||||
vte = (prev.vte.override {
|
||||
stdenv = prev.stdenv;
|
||||
}).overrideAttrs (old: {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
./examples/launchCageOnBoot.nix
|
||||
#./examples/launchCageOnBoot.nix
|
||||
];
|
||||
|
||||
# networking = {
|
||||
@ -22,7 +22,11 @@
|
||||
kernelParams = [ "boot.shell_on_fail" ];
|
||||
consoleLogLevel = lib.mkDefault 7;
|
||||
initrd.kernelModules = [
|
||||
"virtio_pci"
|
||||
"virtio_blk"
|
||||
"virtio_input"
|
||||
"9pnet"
|
||||
"9pnet_virtio"
|
||||
];
|
||||
};
|
||||
|
||||
@ -30,19 +34,19 @@
|
||||
services.openssh.enable = true;
|
||||
|
||||
# Open port 19999 for Netdata
|
||||
networking.firewall.allowedTCPPorts = [ 19999 ];
|
||||
services.netdata.enable = true;
|
||||
#networking.firewall.allowedTCPPorts = [ 19999 ];
|
||||
#services.netdata.enable = true;
|
||||
|
||||
# Enable Avahi mDNS, you should be able to reach http://visionfive-nix:19999
|
||||
# to reach netdata when booted
|
||||
services.avahi = {
|
||||
openFirewall = true;
|
||||
nssmdns = true; # Allows software to use Avahi to resolve.
|
||||
enable = true;
|
||||
publish = {
|
||||
enable = true;
|
||||
addresses = true;
|
||||
workstation = true;
|
||||
};
|
||||
};
|
||||
#services.avahi = {
|
||||
# openFirewall = true;
|
||||
# nssmdns = true; # Allows software to use Avahi to resolve.
|
||||
# enable = true;
|
||||
# publish = {
|
||||
# enable = true;
|
||||
# addresses = true;
|
||||
# workstation = true;
|
||||
# };
|
||||
#};
|
||||
}
|
||||
|
32
examples/hpcg.nix
Normal file
32
examples/hpcg.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{ lib, stdenv, fetchFromGitHub, cmake } :
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "hpcg";
|
||||
version = "114602d";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "hpcg-benchmark";
|
||||
repo = pname;
|
||||
rev = "114602d458d1034faa52b71e4c15aba9b3a17698";
|
||||
hash = "sha256-n+Qz0G630SyG3v1E1buwjHO8t779tq2TbWBcAjwwvxw=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
enableParallelBuilding = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/share/hpcg
|
||||
|
||||
cp xhpcg $out/bin
|
||||
#cp hpcg.dat $out/share/hpcg
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "HPC conjugate gradient benchmark";
|
||||
homepage = "https://www.hpcg-benchmark.org";
|
||||
platforms = platforms.linux;
|
||||
license = licenses.bsd3;
|
||||
maintainers = [ maintainers.markuskowa ];
|
||||
};
|
||||
}
|
||||
|
113
flake.lock
113
flake.lock
@ -1,110 +1,5 @@
|
||||
{
|
||||
"nodes": {
|
||||
"jh7100_ddrinit": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-pOlg3FtFdFhHHnE16izS26RkJ7RbQpglDKgpVRdyAso=",
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/JH7100_ddrinit/releases/download/ddrinit-2133-211102/ddrinit-2133-211102.bin.out"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/JH7100_ddrinit/releases/download/ddrinit-2133-211102/ddrinit-2133-211102.bin.out"
|
||||
}
|
||||
},
|
||||
"jh7100_recovery_binary": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-T3vqaelqwXiOqD8yRHw899A5GI2J+hU/5l5S3euIs2g=",
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/bootloader_recovery/releases/download/JH7100_recovery_binary/jh7100_recovery_boot.bin"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/bootloader_recovery/releases/download/JH7100_recovery_binary/jh7100_recovery_boot.bin"
|
||||
}
|
||||
},
|
||||
"jh7100_secondBoot": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-Ek8RK8t3y9JfpVfey1X9yZn9OIbOj/EJokUeWbZWZGU=",
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/JH7100_secondBoot/releases/download/bootloader-211102_VisionFive_JH7100/bootloader-JH7100-211102.bin.out"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/JH7100_secondBoot/releases/download/bootloader-211102_VisionFive_JH7100/bootloader-JH7100-211102.bin.out"
|
||||
}
|
||||
},
|
||||
"jh7110-kernel": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673450975,
|
||||
"narHash": "sha256-o1k1UDUXUsRb4200zZ5ozVL15g7wsheet8O5UhX2HWY=",
|
||||
"owner": "starfive-tech",
|
||||
"repo": "linux",
|
||||
"rev": "59cf9af678dbfa3d73f6cb86ed1ae7219da9f5c9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "starfive-tech",
|
||||
"ref": "JH7110_VisionFive2_devel",
|
||||
"repo": "linux",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"jh7110_recovery_binary": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-WL2ltlIJoWQFrRxEQNYQdzBBj0qv9FnMWLHVZVzWzBQ=",
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/Tools/blob/bc6dc7e33e0c2466db0476b5043f0f77842f98f0/recovery/jh7110-recovery-20221205.bin?raw=true"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/Tools/blob/bc6dc7e33e0c2466db0476b5043f0f77842f98f0/recovery/jh7110-recovery-20221205.bin?raw=true"
|
||||
}
|
||||
},
|
||||
"jh7110_u-boot-bin": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-DfB8HpWv+/i+fdGvF6oGVVgc+A+LV5NA8PZ1JSOSuys=",
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/visionfive2_fw_payload.img"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/visionfive2_fw_payload.img"
|
||||
}
|
||||
},
|
||||
"jh7110_u-boot-spl-bin": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-Mgw6YUn69MNvgZFd1WvamF0N1ZjF35km76i1AknaAT8=",
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/u-boot-spl.bin.normal.out"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/u-boot-spl.bin.normal.out"
|
||||
}
|
||||
},
|
||||
"jh71xx-tools": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1644591616,
|
||||
"narHash": "sha256-eCOI/kYmkSxL4HPqBPoJFWa6qJwqafPOxS8KhIuMF4s=",
|
||||
"owner": "xypron",
|
||||
"repo": "jh71xx-tools",
|
||||
"rev": "afe3328923d6c3883886a00c4ed10eda019f2db1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "xypron",
|
||||
"repo": "jh71xx-tools",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1657645802,
|
||||
@ -123,14 +18,6 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"jh7100_ddrinit": "jh7100_ddrinit",
|
||||
"jh7100_recovery_binary": "jh7100_recovery_binary",
|
||||
"jh7100_secondBoot": "jh7100_secondBoot",
|
||||
"jh7110-kernel": "jh7110-kernel",
|
||||
"jh7110_recovery_binary": "jh7110_recovery_binary",
|
||||
"jh7110_u-boot-bin": "jh7110_u-boot-bin",
|
||||
"jh7110_u-boot-spl-bin": "jh7110_u-boot-spl-bin",
|
||||
"jh71xx-tools": "jh71xx-tools",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"vendor-kernel": "vendor-kernel"
|
||||
}
|
||||
|
56
flake.nix
56
flake.nix
@ -7,44 +7,8 @@
|
||||
url = "github:starfive-tech/linux";
|
||||
flake = false;
|
||||
};
|
||||
jh7100_ddrinit = {
|
||||
url = "https://github.com/starfive-tech/JH7100_ddrinit/releases/download/ddrinit-2133-211102/ddrinit-2133-211102.bin.out";
|
||||
flake = false;
|
||||
};
|
||||
jh7100_secondBoot = {
|
||||
url = "https://github.com/starfive-tech/JH7100_secondBoot/releases/download/bootloader-211102_VisionFive_JH7100/bootloader-JH7100-211102.bin.out";
|
||||
flake = false;
|
||||
};
|
||||
jh7100_recovery_binary = {
|
||||
url = "https://github.com/starfive-tech/bootloader_recovery/releases/download/JH7100_recovery_binary/jh7100_recovery_boot.bin";
|
||||
flake = false;
|
||||
};
|
||||
jh71xx-tools = {
|
||||
url = "github:xypron/jh71xx-tools";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# VisionFive 2
|
||||
jh7110-kernel = {
|
||||
# url = "github:starfive-tech/linux/50a831018ed997c9fb3b603574176b221a28aa12"; # JH7110_VisionFive2_devel via VisionFive2 project submodule about two revisions back.
|
||||
url = "github:starfive-tech/linux/JH7110_VisionFive2_devel";
|
||||
flake = false;
|
||||
};
|
||||
jh7110_recovery_binary = {
|
||||
url = "https://github.com/starfive-tech/Tools/blob/bc6dc7e33e0c2466db0476b5043f0f77842f98f0/recovery/jh7110-recovery-20221205.bin?raw=true";
|
||||
flake = false;
|
||||
};
|
||||
# Should be possible to build from https://github.com/starfive-tech/VisionFive2
|
||||
jh7110_u-boot-spl-bin = {
|
||||
url = https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/u-boot-spl.bin.normal.out;
|
||||
flake = false;
|
||||
};
|
||||
jh7110_u-boot-bin = {
|
||||
url = https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/visionfive2_fw_payload.img;
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
outputs = inputs@{ self, nixpkgs, jh71xx-tools, jh7100_recovery_binary, jh7100_secondBoot, jh7100_ddrinit, vendor-kernel, ... }:
|
||||
outputs = { self, nixpkgs, vendor-kernel, ... }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
system = "x86_64-linux";
|
||||
@ -55,16 +19,16 @@
|
||||
./base.nix
|
||||
./configuration.nix
|
||||
];
|
||||
|
||||
# Pass arguments to a module inside a function inside a file, while preserving
|
||||
# the file name behavior of the module system.
|
||||
importApply =
|
||||
modulePath: staticArgs:
|
||||
lib.setDefaultModuleLocation modulePath (import modulePath staticArgs);
|
||||
in
|
||||
{
|
||||
overlay = final: prev: {
|
||||
linuxPackages_visionfive = final.linuxPackagesFor ((final.callPackage ./kernel.nix { inherit vendor-kernel; }).override { patches = []; });
|
||||
linuxPackages_visionfive = final.linuxPackagesFor (
|
||||
(
|
||||
final.callPackage ./kernel.nix { inherit vendor-kernel; }
|
||||
).override {
|
||||
patches = [];
|
||||
}
|
||||
);
|
||||
};
|
||||
legacyPackages.${system} =
|
||||
{
|
||||
@ -77,10 +41,6 @@
|
||||
visionfive2-cross = self.nixosConfigurations.visionfive2-cross.config.system.build.sdImage;
|
||||
visionfive2-native = self.nixosConfigurations.visionfive2-native.config.system.build.sdImage;
|
||||
};
|
||||
nixosModules = {
|
||||
visionfive2-sd-image = importApply ./visionfive2/sd-image.nix { inherit inputs importApply; };
|
||||
visionfive2-kernel = importApply ./visionfive2/kernel/nixos-module.nix { inherit inputs importApply; };
|
||||
};
|
||||
nixosConfigurations = {
|
||||
visionfive-cross = nixpkgs.lib.nixosSystem {
|
||||
system = "${system}";
|
||||
|
17
kernel.nix
17
kernel.nix
@ -38,6 +38,23 @@ in buildLinux (args // {
|
||||
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;
|
||||
};
|
||||
|
||||
extraMeta = {
|
||||
|
@ -2,13 +2,16 @@
|
||||
|
||||
set -e
|
||||
|
||||
export PATH=/nix/store/c5xwy0rllg4lcw61mh20glairjz7ibv4-qemu-8.0.4/bin/:$PATH
|
||||
|
||||
NIX_DISK_IMAGE=$(readlink -f "${NIX_DISK_IMAGE:-./visionfive-nix.qcow2}")
|
||||
|
||||
if ! test -e "$NIX_DISK_IMAGE"; then
|
||||
/nix/store/gn94kgxqg9wv7y9cjkkavv2626sbq5vz-qemu-host-cpu-only-riscv64-unknown-linux-gnu-7.0.0/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \
|
||||
1024M
|
||||
qemu-img create -f qcow2 "$NIX_DISK_IMAGE" 1024M
|
||||
fi
|
||||
|
||||
echo "NIX_DISK_IMAGE = $NIX_DISK_IMAGE"
|
||||
|
||||
# Create a directory for storing temporary data of the running VM.
|
||||
if [ -z "$TMPDIR" ] || [ -z "$USE_TMPDIR" ]; then
|
||||
TMPDIR=$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)
|
||||
@ -19,33 +22,43 @@ fi
|
||||
# Create a directory for exchanging data with the VM.
|
||||
mkdir -p "$TMPDIR/xchg"
|
||||
|
||||
system=$(readlink -f ./current-system)
|
||||
echo $system
|
||||
sleep 1
|
||||
|
||||
|
||||
cd "$TMPDIR"
|
||||
|
||||
|
||||
QEMU_KERNEL_PARAMS="boot.trace "
|
||||
#QEMU_KERNEL_PARAMS="boot.debug1devices"
|
||||
#QEMU_KERNEL_PARAMS="boot.trace boot.debug1"
|
||||
|
||||
|
||||
# Start QEMU.
|
||||
exec /nix/store/c5xwy0rllg4lcw61mh20glairjz7ibv4-qemu-8.0.4/bin/qemu-system-riscv64 \
|
||||
exec qemu-system-riscv64 \
|
||||
-name visionfive-nix \
|
||||
-m 1024 \
|
||||
-smp 1 \
|
||||
-nographic \
|
||||
-machine virt \
|
||||
-device virtio-rng-pci \
|
||||
-net nic,netdev=user.0,model=virtio -netdev user,id=user.0,"$QEMU_NET_OPTS" \
|
||||
-netdev user,id=net0,hostfwd=tcp::60022-:22 -device virtio-net-device,netdev=net0 \
|
||||
-virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store \
|
||||
-virtfs local,path="${SHARED_DIR:-$TMPDIR/xchg}",security_model=none,mount_tag=shared \
|
||||
-virtfs local,path="$TMPDIR"/xchg,security_model=none,mount_tag=xchg \
|
||||
-hda "$NIX_DISK_IMAGE" \
|
||||
-device virtio-keyboard \
|
||||
-kernel ${NIXPKGS_QEMU_KERNEL_visionfive_nix:-/nix/store/y0912x26b1fxrs0d8yfzsznak56pk2c8-nixos-system-visionfive-nix-22.11.20220712.39a827f/kernel} \
|
||||
-initrd /nix/store/y0912x26b1fxrs0d8yfzsznak56pk2c8-nixos-system-visionfive-nix-22.11.20220712.39a827f/initrd \
|
||||
-append "$(cat /nix/store/y0912x26b1fxrs0d8yfzsznak56pk2c8-nixos-system-visionfive-nix-22.11.20220712.39a827f/kernel-params) init=/nix/store/y0912x26b1fxrs0d8yfzsznak56pk2c8-nixos-system-visionfive-nix-22.11.20220712.39a827f/init regInfo=/nix/store/x3zpwfbk2wkiisxhgi7zwsfwbdfxk0w1-closure-info-riscv64-unknown-linux-gnu/registration console=ttyS0,115200n8 loglevel=7 $QEMU_KERNEL_PARAMS" \
|
||||
-drive "file=$NIX_DISK_IMAGE,if=none,id=hd0" \
|
||||
-device virtio-blk-device,drive=hd0 \
|
||||
-kernel $system/kernel \
|
||||
-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" \
|
||||
$QEMU_OPTS \
|
||||
"$@"
|
||||
|
||||
# -drive "file=$NIX_DISK_IMAGE,if=virtio,id=hd0" \
|
||||
# -hda "$NIX_DISK_IMAGE" \
|
||||
#-net nic,model=virtio,macaddr=16:da:11:b4:44:c9 -net user \
|
||||
# -net nic,netdev=user.0,model=virtio -netdev user,id=user.0,"$QEMU_NET_OPTS" \
|
||||
#console=tty0
|
||||
#console=ttyS0,115200n8
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user