#!/bin/bash

# issue "zstd -d xxxxxx.zst" to decompress the disk image
# issue "sh ./start-qemu-display-riscv64-uboot.sh" to run this script
# default "root" passwd is "Slack1@#$5" (without quotation marks)
# login with "ssh root@localhost -p 51550" (or configured port)
# issue "nano /etc/resolv.conf" to edit DNS nameserver
# issue "poweroff" to shutdown normally and "reboot" to reboot
# press Ctrl-A and then press X in QEMU console to force poweroff
# comment out "-display sdl -device virtio-gpu" to disable GUI
# "-bios" firmware using u-boot as payload supports up to "-smp 16"
# firmware using Linux kernel Image as payload supports up to "-smp 32"

qemu-system-riscv64 \
  -nographic -machine virt \
  -smp 8 -m 8G \
  -bios fw_u-boot-2022.07_gnu.bin \
  -device virtio-net-device,netdev=usernet \
  -netdev user,id=usernet,hostfwd=tcp::51550-:22 \
  -drive file=slackware-riscv64-15.0.20220810-alfa.rawimg,format=raw,if=virtio \
  -device qemu-xhci -device usb-tablet -device usb-kbd \
  -display sdl -device virtio-gpu \
