-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
106610b
commit f442457
Showing
5 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
BASE=$(dirname $0) | ||
|
||
QEMU=qemu-system-riscv64 | ||
USERDISK=nixos-riscv64-qemu.raw | ||
ORIGDISK=$(ls $BASE/sd-image/*.zst) | ||
UBOOT=$(ls $BASE/u-boot.bin) | ||
|
||
check_command() { | ||
if ! command -v $1 &>/dev/null 2>&1; then | ||
>&2 echo "$1 is required to run this. Try \"nix-shell -p qemu -p zstd\"." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_command $QEMU | ||
check_command qemu-img | ||
check_command zstdcat | ||
|
||
if [ ! -e $USERDISK ]; then | ||
>&2 echo "Creating a persistent disk image at $USERDISK..." | ||
zstdcat $ORIGDISK > $USERDISK | ||
fi | ||
|
||
>&2 echo "Launching QEMU..." | ||
|
||
set -x | ||
exec $QEMU -M virt -cpu rv64 -m 2G -smp 4 \ | ||
-kernel $UBOOT \ | ||
-display gtk,gl=on \ | ||
-device qemu-xhci \ | ||
-device virtio-vga-gl -device usb-tablet -device virtio-keyboard \ | ||
-device intel-hda -device hda-duplex,audiodev=pa -audiodev pa,id=pa \ | ||
-device virtio-blk-device,drive=sdimage \ | ||
-drive file=$USERDISK,format=raw,id=sdimage \ | ||
-device virtio-net-device,netdev=usernet \ | ||
-netdev user,id=usernet,net=10.0.0.0/24,dhcpstart=10.0.0.10 |