forked from rarias/nixos-riscv
Add qemu support for Lagarto Ox
The network is still not working automatically, but the eth0 device is present in the host. Reviewed-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
This commit is contained in:
parent
ccf41b441d
commit
8da3468ee2
14
README.md
14
README.md
@ -45,6 +45,20 @@ $ picocom -q -b 115200 $FPGACTL_UART
|
|||||||
|
|
||||||
It should boot without any user interaction.
|
It should boot without any user interaction.
|
||||||
|
|
||||||
|
## Lagarto Ox on QEMU
|
||||||
|
|
||||||
|
To build the system and boot it on QEMU, you can run the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ nix develop -L '.#qemu-lagarto-ox'
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, simply run boot.sh to start the QEMU system.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ./boot.sh
|
||||||
|
```
|
||||||
|
|
||||||
## Lagarto Hun
|
## Lagarto Hun
|
||||||
|
|
||||||
WIP
|
WIP
|
||||||
|
15
boot.sh
15
boot.sh
@ -27,7 +27,7 @@ fi
|
|||||||
# Create a directory for exchanging data with the VM.
|
# Create a directory for exchanging data with the VM.
|
||||||
mkdir -p "$TMPDIR/xchg"
|
mkdir -p "$TMPDIR/xchg"
|
||||||
|
|
||||||
system="$NIXOS_SYSTEM_TOPLEVEL"
|
system="$TOPLEVEL"
|
||||||
echo "Booting $system"
|
echo "Booting $system"
|
||||||
|
|
||||||
cd "$TMPDIR"
|
cd "$TMPDIR"
|
||||||
@ -37,7 +37,7 @@ cd "$TMPDIR"
|
|||||||
#QEMU_KERNEL_PARAMS="boot.trace boot.debug1"
|
#QEMU_KERNEL_PARAMS="boot.trace boot.debug1"
|
||||||
|
|
||||||
# Trap the CPU on compressed instructions?
|
# Trap the CPU on compressed instructions?
|
||||||
TRAP_COMPRESSED="-cpu rv64,c=false"
|
#TRAP_COMPRESSED="-cpu rv64,c=false"
|
||||||
|
|
||||||
CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.bin"
|
CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.bin"
|
||||||
#CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_jump.elf"
|
#CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_jump.elf"
|
||||||
@ -45,11 +45,10 @@ CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.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"
|
#CUSTOM_BIOS="-bios opensbi-1.4-rv-bin/share/opensbi/lp64/generic/firmware/fw_payload.bin"
|
||||||
#DEBUG_GDB="-s -S"
|
#DEBUG_GDB="-s -S"
|
||||||
DEBUG_CPU="-d cpu_reset"
|
#DEBUG_CPU="-d cpu_reset"
|
||||||
#DEBUG_CPU="-d in_asm,cpu,cpu_reset"
|
#DEBUG_CPU="-d in_asm,cpu,cpu_reset"
|
||||||
|
|
||||||
|
|
||||||
# Start QEMU.
|
|
||||||
exec qemu-system-riscv64 \
|
exec qemu-system-riscv64 \
|
||||||
$DEBUG_GDB \
|
$DEBUG_GDB \
|
||||||
$DEBUG_CPU \
|
$DEBUG_CPU \
|
||||||
@ -60,18 +59,16 @@ exec qemu-system-riscv64 \
|
|||||||
-machine virt \
|
-machine virt \
|
||||||
-device virtio-rng-pci \
|
-device virtio-rng-pci \
|
||||||
$TRAP_COMPRESSED \
|
$TRAP_COMPRESSED \
|
||||||
$CUSTOM_BIOS \
|
-netdev user,id=net0,hostfwd=tcp::60022-:22 \
|
||||||
-netdev user,id=net0,hostfwd=tcp::60022-:22 -device virtio-net-device,netdev=net0 \
|
-device virtio-net-device,netdev=net0 \
|
||||||
-virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store \
|
-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="${SHARED_DIR:-$TMPDIR/xchg}",security_model=none,mount_tag=shared \
|
||||||
-virtfs local,path="$TMPDIR"/xchg,security_model=none,mount_tag=xchg \
|
-virtfs local,path="$TMPDIR"/xchg,security_model=none,mount_tag=xchg \
|
||||||
-device virtio-keyboard \
|
|
||||||
-drive "file=$NIX_DISK_IMAGE,if=none,id=hd0" \
|
-drive "file=$NIX_DISK_IMAGE,if=none,id=hd0" \
|
||||||
-device virtio-blk-device,drive=hd0 \
|
-device virtio-blk-device,drive=hd0 \
|
||||||
-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 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 \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
46
flake.nix
46
flake.nix
@ -18,6 +18,7 @@
|
|||||||
system = "${system}";
|
system = "${system}";
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
|
./lagarto-ox.nix
|
||||||
./vm.nix
|
./vm.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@ -54,6 +55,18 @@
|
|||||||
./no-compressed.nix
|
./no-compressed.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# QEMU configuration (x86 host) for a FPGA Lagarto Ox CPU virtual machine
|
||||||
|
qemu-lagarto-ox = nixosSystem {
|
||||||
|
specialArgs = { inherit self; };
|
||||||
|
system = "${system}";
|
||||||
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
./lagarto-ox.nix
|
||||||
|
./no-compressed.nix
|
||||||
|
./vm.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# A development shell with QEMU ready to boot the RISC-V system in an x86
|
# A development shell with QEMU ready to boot the RISC-V system in an x86
|
||||||
@ -131,6 +144,39 @@
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
devShells.x86_64-linux.qemu-lagarto-ox =
|
||||||
|
let
|
||||||
|
nixosconf = self.nixosConfigurations.qemu-lagarto-ox;
|
||||||
|
syspkgs = nixosconf.pkgs;
|
||||||
|
build = nixosconf.config.system.build;
|
||||||
|
in syspkgs.mkShell rec {
|
||||||
|
pname = "lagarto-ox-shell";
|
||||||
|
nativeBuildInputs = with syspkgs; [ qemu_full ];
|
||||||
|
COMMIT = if self ? rev then self.rev else "dirty";
|
||||||
|
TOPLEVEL = build.toplevel;
|
||||||
|
OPENSBI = syspkgs.opensbi;
|
||||||
|
KERNEL = build.kernel;
|
||||||
|
INITRD = build.initialRamdisk;
|
||||||
|
UBOOT_ENV = syspkgs.uboot-env;
|
||||||
|
BITSTREAM = syspkgs.bitstream;
|
||||||
|
BOOTROM = syspkgs.bootrom;
|
||||||
|
GCROOT = mkRoots syspkgs [
|
||||||
|
syspkgs.stdenv KERNEL OPENSBI syspkgs.riscv-tools
|
||||||
|
];
|
||||||
|
shellHook = ''
|
||||||
|
echo "Here are the current system pieces:"
|
||||||
|
echo " COMMIT = $COMMIT"
|
||||||
|
echo " TOPLEVEL = $TOPLEVEL"
|
||||||
|
echo " KERNEL = $KERNEL"
|
||||||
|
echo " OPENSBI = $OPENSBI"
|
||||||
|
echo " INITRD = $INITRD"
|
||||||
|
echo " UBOOT_ENV = $UBOOT_ENV"
|
||||||
|
echo " BITSTREAM = $BITSTREAM"
|
||||||
|
echo " BOOTROM = $BOOTROM"
|
||||||
|
echo " GCROOT = $GCROOT"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
devShells.x86_64-linux.lagarto-ox-rd =
|
devShells.x86_64-linux.lagarto-ox-rd =
|
||||||
let
|
let
|
||||||
nixosconf = self.nixosConfigurations.lagarto-ox;
|
nixosconf = self.nixosConfigurations.lagarto-ox;
|
||||||
|
18
vm.nix
18
vm.nix
@ -8,7 +8,9 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
# Enable ssh on boot
|
# Enable ssh on boot
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = lib.mkForce true;
|
||||||
|
networking.dhcpcd.enable = lib.mkForce true;
|
||||||
|
services.timesyncd.enable = lib.mkForce true;
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
kernelParams = [
|
kernelParams = [
|
||||||
@ -47,8 +49,8 @@
|
|||||||
INET y
|
INET y
|
||||||
NETWORK_FILESYSTEMS y
|
NETWORK_FILESYSTEMS y
|
||||||
OVERLAY_FS y
|
OVERLAY_FS y
|
||||||
#"9P_FS" y
|
9P_FS y
|
||||||
#"9P_FS_POSIX_ACL" y
|
9P_FS_POSIX_ACL y
|
||||||
PCI y
|
PCI y
|
||||||
VIRTIO_PCI y
|
VIRTIO_PCI y
|
||||||
PCI_HOST_GENERIC y
|
PCI_HOST_GENERIC y
|
||||||
@ -63,16 +65,6 @@
|
|||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
qemu = prev.qemu.override {
|
|
||||||
pulseSupport = false;
|
|
||||||
pipewireSupport = false;
|
|
||||||
sdlSupport = false;
|
|
||||||
jackSupport = false;
|
|
||||||
gtkSupport = false;
|
|
||||||
vncSupport = false;
|
|
||||||
smartcardSupport = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
uboot-custom = prev.ubootQemuRiscv64Smode.override {
|
uboot-custom = prev.ubootQemuRiscv64Smode.override {
|
||||||
# Override preboot to set 'bootcmd' directly to the kernel address in RAM
|
# Override preboot to set 'bootcmd' directly to the kernel address in RAM
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user