Boot opensbi without compressed
This commit is contained in:
parent
22de6d8297
commit
f8b624af67
@ -1,9 +1,5 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
#./examples/launchCageOnBoot.nix
|
||||
];
|
||||
|
||||
networking.hostName = "visionfive-nix";
|
||||
|
||||
boot = {
|
||||
@ -18,6 +14,8 @@
|
||||
];
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [ (import ./overlay.nix) ];
|
||||
|
||||
# Enable ssh on boot
|
||||
services.openssh.enable = true;
|
||||
}
|
||||
|
72
flake.lock
72
flake.lock
@ -1,40 +1,76 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": [
|
||||
"systems"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1657645802,
|
||||
"narHash": "sha256-wd+LiuGtHP8mTIc0gZrO2yqzmEPVvh5IyWrB8WCQNKM=",
|
||||
"owner": "matthewcroughan",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "39a827f18b870afb02f6c0f09151c69f2d8e7a4d",
|
||||
"lastModified": 1705309234,
|
||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "matthewcroughan",
|
||||
"ref": "mc/riscv-testing",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1705312285,
|
||||
"narHash": "sha256-rd+dY+v61Y8w3u9bukO/hB55Xl4wXv4/yC8rCGVnK5U=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "bee2202bec57e521e3bd8acd526884b9767d7fa0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixos-hardware",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1705316053,
|
||||
"narHash": "sha256-J2Ey5mPFT8gdfL2XC0JTZvKaBw/b2pnyudEXFvl+dQM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c3e128f3c0ecc1fb04aef9f72b3dcc2f6cecf370",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"vendor-kernel": "vendor-kernel"
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
"vendor-kernel": {
|
||||
"flake": false,
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1657526524,
|
||||
"narHash": "sha256-NiEeWgYzEhqLbvB0krpjoRv8oXXsJYp6KeDor+f9tak=",
|
||||
"owner": "starfive-tech",
|
||||
"repo": "linux",
|
||||
"rev": "74003f14f92e3c8eb31536b599c1f0c7aba3cdf2",
|
||||
"lastModified": 1680978846,
|
||||
"narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "x86_64-linux",
|
||||
"rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "starfive-tech",
|
||||
"repo": "linux",
|
||||
"owner": "nix-systems",
|
||||
"repo": "x86_64-linux",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
158
flake.nix
158
flake.nix
@ -1,63 +1,105 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:matthewcroughan/nixpkgs/mc/riscv-testing";
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
inputs.nixos-hardware.url = "github:nixos/nixos-hardware";
|
||||
|
||||
# VisionFive ("v1")
|
||||
vendor-kernel = {
|
||||
url = "github:starfive-tech/linux";
|
||||
flake = false;
|
||||
# Some dependencies of this flake are not yet available on non linux systems
|
||||
inputs.systems.url = "github:nix-systems/x86_64-linux";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.flake-utils.inputs.systems.follows = "systems";
|
||||
|
||||
outputs = { self, nixpkgs, nixos-hardware, flake-utils, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
overlay = import ./overlay.nix;
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
modules = [
|
||||
./configuration.nix
|
||||
"${nixos-hardware}/starfive/visionfive/v2/sd-image-installer.nix"
|
||||
];
|
||||
in {
|
||||
overlay = import ./overlay.nix;
|
||||
nixosConfigurations = {
|
||||
# The cross configuration defines a system that runs in the RISC-V
|
||||
# architecture, but is build from an x86 host machine.
|
||||
cross = nixpkgs.lib.nixosSystem {
|
||||
system = "${system}";
|
||||
modules = modules ++ [
|
||||
{
|
||||
nixpkgs.crossSystem = {
|
||||
gcc.arch = "rv64gv";
|
||||
gcc.tune = "rv64gv";
|
||||
system = "riscv64-linux";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
# The native configuration defines the same system, but built from an
|
||||
# RISC-V machine. Not needed for now.
|
||||
#native = nixpkgs.lib.nixosSystem {
|
||||
# system = "riscv64-linux";
|
||||
# modules = modules;
|
||||
#};
|
||||
};
|
||||
|
||||
# A development shell with QEMU ready to boot the RISC-V system in an x86
|
||||
# machine.
|
||||
devShells.x86_64-linux.default =
|
||||
let
|
||||
nixosconf = self.nixosConfigurations.cross;
|
||||
sysconf = nixosconf.config;
|
||||
syspkgs = nixosconf.pkgs;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
pname = "qemu-shell";
|
||||
buildInputs = with pkgs; [ qemu ];
|
||||
# Here we tell the run script where to find the system
|
||||
#NIXOS_SYSTEM_TOPLEVEL = "${sysconfig.system.build.toplevel}";
|
||||
OPENSBI = syspkgs.opensbi;
|
||||
};
|
||||
};
|
||||
outputs = { self, nixpkgs, vendor-kernel, ... }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
|
||||
modules = [
|
||||
{ nixpkgs.overlays = [ self.overlay ]; }
|
||||
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-riscv64-visionfive-installer.nix"
|
||||
./base.nix
|
||||
./configuration.nix
|
||||
];
|
||||
in
|
||||
{
|
||||
overlay = final: prev: {
|
||||
linuxPackages_visionfive = final.linuxPackagesFor (
|
||||
(
|
||||
final.callPackage ./kernel.nix { inherit vendor-kernel; }
|
||||
).override {
|
||||
patches = [];
|
||||
}
|
||||
);
|
||||
};
|
||||
legacyPackages.${system} =
|
||||
{
|
||||
inherit (pkgs.pkgsCross.riscv64.linux) linuxPackages_visionfive;
|
||||
};
|
||||
images = {
|
||||
visionfive-cross = self.nixosConfigurations.visionfive-cross.config.system.build.sdImage;
|
||||
visionfive-native = self.nixosConfigurations.visionfive-native.config.system.build.sdImage;
|
||||
|
||||
visionfive2-cross = self.nixosConfigurations.visionfive2-cross.config.system.build.sdImage;
|
||||
visionfive2-native = self.nixosConfigurations.visionfive2-native.config.system.build.sdImage;
|
||||
};
|
||||
nixosConfigurations = {
|
||||
visionfive-cross = nixpkgs.lib.nixosSystem {
|
||||
system = "${system}";
|
||||
modules = modules ++ [
|
||||
{
|
||||
nixpkgs.crossSystem = {
|
||||
gcc.arch = "rv64gv";
|
||||
gcc.tune = "rv64gv";
|
||||
system = "riscv64-linux";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
visionfive-native = nixpkgs.lib.nixosSystem {
|
||||
system = "riscv64-linux";
|
||||
modules = modules;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# flake-utils.lib.eachDefaultSystem (system:
|
||||
# rec {
|
||||
#
|
||||
# # .\#nixosConfigurations.visionfive-cross.config.system.build.toplevel
|
||||
# packages.default = packages.sd-image;
|
||||
# packages.sd-image = (import "${nixpkgs}/nixos" {
|
||||
# configuration =
|
||||
# { config, ... }: {
|
||||
# imports = [
|
||||
# "${nixos-hardware}/starfive/visionfive/v2/sd-image-installer.nix"
|
||||
# ];
|
||||
#
|
||||
# # If you want to use ssh set a password
|
||||
# users.users.nixos.password = "test123";
|
||||
# # OR add your public ssh key
|
||||
# # users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ];
|
||||
#
|
||||
# # AND configure networking
|
||||
# networking.interfaces.end0.useDHCP = true;
|
||||
# networking.interfaces.end1.useDHCP = true;
|
||||
#
|
||||
# # Additional configuration goes here
|
||||
#
|
||||
# #hardware.deviceTree.overlays = [{
|
||||
# # name = "8GB-patch";
|
||||
# # dtsFile = "${nixos-hardware}/starfive/visionfive/v2/8gb-patch.dts";
|
||||
# #}];
|
||||
#
|
||||
# #sdImage.compressImage = false;
|
||||
#
|
||||
# nixpkgs.crossSystem = {
|
||||
# config = "riscv64-unknown-linux-gnu";
|
||||
# system = "riscv64-linux";
|
||||
# };
|
||||
#
|
||||
# system.stateVersion = "24.05";
|
||||
# };
|
||||
# inherit system;
|
||||
# }).config.system.build.toplevel;
|
||||
# });
|
||||
#}
|
||||
|
44
old-flake.lock
Normal file
44
old-flake.lock
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1657645802,
|
||||
"narHash": "sha256-wd+LiuGtHP8mTIc0gZrO2yqzmEPVvh5IyWrB8WCQNKM=",
|
||||
"owner": "matthewcroughan",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "39a827f18b870afb02f6c0f09151c69f2d8e7a4d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "matthewcroughan",
|
||||
"ref": "mc/riscv-testing",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"vendor-kernel": "vendor-kernel"
|
||||
}
|
||||
},
|
||||
"vendor-kernel": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1657526524,
|
||||
"narHash": "sha256-NiEeWgYzEhqLbvB0krpjoRv8oXXsJYp6KeDor+f9tak=",
|
||||
"owner": "starfive-tech",
|
||||
"repo": "linux",
|
||||
"rev": "74003f14f92e3c8eb31536b599c1f0c7aba3cdf2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "starfive-tech",
|
||||
"repo": "linux",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
63
old-flake.nix
Normal file
63
old-flake.nix
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:matthewcroughan/nixpkgs/mc/riscv-testing";
|
||||
|
||||
# VisionFive ("v1")
|
||||
vendor-kernel = {
|
||||
url = "github:starfive-tech/linux";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
outputs = { self, nixpkgs, vendor-kernel, ... }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
|
||||
modules = [
|
||||
{ nixpkgs.overlays = [ self.overlay ]; }
|
||||
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-riscv64-visionfive-installer.nix"
|
||||
./base.nix
|
||||
./configuration.nix
|
||||
];
|
||||
in
|
||||
{
|
||||
overlay = final: prev: {
|
||||
linuxPackages_visionfive = final.linuxPackagesFor (
|
||||
(
|
||||
final.callPackage ./kernel.nix { inherit vendor-kernel; }
|
||||
).override {
|
||||
patches = [];
|
||||
}
|
||||
);
|
||||
};
|
||||
legacyPackages.${system} =
|
||||
{
|
||||
inherit (pkgs.pkgsCross.riscv64.linux) linuxPackages_visionfive;
|
||||
};
|
||||
images = {
|
||||
visionfive-cross = self.nixosConfigurations.visionfive-cross.config.system.build.sdImage;
|
||||
visionfive-native = self.nixosConfigurations.visionfive-native.config.system.build.sdImage;
|
||||
|
||||
visionfive2-cross = self.nixosConfigurations.visionfive2-cross.config.system.build.sdImage;
|
||||
visionfive2-native = self.nixosConfigurations.visionfive2-native.config.system.build.sdImage;
|
||||
};
|
||||
nixosConfigurations = {
|
||||
visionfive-cross = nixpkgs.lib.nixosSystem {
|
||||
system = "${system}";
|
||||
modules = modules ++ [
|
||||
{
|
||||
nixpkgs.crossSystem = {
|
||||
gcc.arch = "rv64gv";
|
||||
gcc.tune = "rv64gv";
|
||||
system = "riscv64-linux";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
visionfive-native = nixpkgs.lib.nixosSystem {
|
||||
system = "riscv64-linux";
|
||||
modules = modules;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
13
overlay.nix
Normal file
13
overlay.nix
Normal file
@ -0,0 +1,13 @@
|
||||
final: prev:
|
||||
|
||||
# Changes to packages from nixpkgs
|
||||
|
||||
{
|
||||
opensbi = prev.opensbi.overrideAttrs (old: {
|
||||
makeFlags = old.makeFlags ++ [
|
||||
# Build OpenSBI without compressed instructions
|
||||
"PLATFORM_RISCV_ISA=rv64gv"
|
||||
# Check with: riscv64-unknown-elf-objdump -d -M no-aliases rotate
|
||||
];
|
||||
});
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#! /nix/store/r4vxljid3iq94jp7qvd639sps0fscwy3-bash-5.2-p15/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
export PATH=/nix/store/c5xwy0rllg4lcw61mh20glairjz7ibv4-qemu-8.0.4/bin/:$PATH
|
||||
#export PATH=/nix/store/c5xwy0rllg4lcw61mh20glairjz7ibv4-qemu-8.0.4/bin/:$PATH
|
||||
|
||||
CDIR=$(readlink -f "$PWD")
|
||||
NIX_DISK_IMAGE=$(readlink -f "${NIX_DISK_IMAGE:-./visionfive-nix.qcow2}")
|
||||
@ -23,9 +23,9 @@ fi
|
||||
# Create a directory for exchanging data with the VM.
|
||||
mkdir -p "$TMPDIR/xchg"
|
||||
|
||||
system=$(readlink -f ./current-system)
|
||||
echo $system
|
||||
sleep 1
|
||||
#system=$(readlink -f ./current-system)
|
||||
#echo $system
|
||||
#sleep 1
|
||||
|
||||
cd "$TMPDIR"
|
||||
|
||||
@ -36,8 +36,9 @@ cd "$TMPDIR"
|
||||
# Trap the CPU on compressed instructions?
|
||||
TRAP_COMPRESSED="-cpu rv64,c=false"
|
||||
|
||||
CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.bin"
|
||||
#CUSTOM_BIOS="-bios $CDIR/bios-nc.bin"
|
||||
CUSTOM_BIOS="-bios $CDIR/bios.bin"
|
||||
#CUSTOM_BIOS="-bios $CDIR/bios.bin"
|
||||
#CUSTOM_BIOS="-bios opensbi-1.4-rv-bin/share/opensbi/lp64/generic/firmware/fw_payload.bin"
|
||||
#DEBUG_GDB="-s -S"
|
||||
DEBUG_CPU="-d cpu_reset"
|
||||
@ -62,12 +63,13 @@ exec qemu-system-riscv64 \
|
||||
-device virtio-keyboard \
|
||||
-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 \
|
||||
"$@"
|
||||
|
||||
#-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" \
|
||||
|
||||
# -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user