aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-07 16:32:19 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-07 16:32:19 +0200
commit72d503eeed47e33bdb365e0e1b9783bc938c6f1e (patch)
tree3d41c221294e256e2f318d1ea68fec2fc7c3788a /bin
parent7589308a75a78e14e23d680b896f5afa63110657 (diff)
downloaddotfiles-72d503eeed47e33bdb365e0e1b9783bc938c6f1e.tar.gz
dotfiles-72d503eeed47e33bdb365e0e1b9783bc938c6f1e.zip
Streamline configuration for run-riscv-qemu.sh
Personal stuff like the location of the kernel image should go into my .bashrc file, and then require it on `run-riscv-qemu.sh`. Similarly, some environment variables were dropped, and some others removed. This brings some much needed consistency to the whole script. Last but not least, the `run-riscv-qemu.sh` now also had an extra configurable variable, which is used for the `-cpu` QEMU option. It defaults to 'max' so we can test the maximum amount of supported extensions as possible. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/run-riscv-qemu.sh24
1 files changed, 15 insertions, 9 deletions
diff --git a/bin/run-riscv-qemu.sh b/bin/run-riscv-qemu.sh
index 94310c5..c96cafb 100755
--- a/bin/run-riscv-qemu.sh
+++ b/bin/run-riscv-qemu.sh
@@ -2,16 +2,20 @@
set -e
-# Enfore the BUSYBOX_SRC path.
+# Enfore BUSYBOX_SRC and QEMU_KERNEL.
if [ -z "$BUSYBOX_SRC" ]; then
echo "run-qemu (error): you need to define BUSYBOX_SRC."
exit 1
fi
+if [ -z "$QEMU_KERNEL" ]; then
+ echo "run-qemu (error): you need to define QEMU_KERNEL with the Image to be used."
+ exit 1
+fi
-CORES=${CORES:-4}
+# Configurable variables.
+QEMU_CPU=${QEMU_CPU:-max}
+QEMU_SMP=${QEMU_SMP:-4}
EXTRA=${EXTRA:-}
-REPO=${REPO:-riscv}
-KERNEL=${KERNEL:-~/src/git.kernel.org/linux/kernel/$REPO/arch/riscv/boot/Image}
# Cleanup older environments.
rm -rf "$BUSYBOX_SRC/initramfs/home"
@@ -50,10 +54,9 @@ Run QEMU/KVM tailored to my needs for testing the Linux Kernel.
Environment variables that can be used the further configure the run:
- - CORES: number of cores (i.e. argument for '-smp'). Default: 4.
- EXTRA: extra arguments to pass. Default: (empty).
- - KERNEL: the kernel to be passed (i.e. argument for '-kernel'). Default: "$KERNEL".
- - REPO: the Linux repository to be used. Default: "riscv".
+ - QEMU_CPU: CPU model to use (i.e. argument for '-cpu'). Default: 'max'.
+ - QEMU_SMP: number of cores (i.e. argument for '-smp'). Default: 4.
HERE
exit 0
fi
@@ -68,9 +71,12 @@ popd
##
# Actual run.
+set -x
+
qemu-system-riscv64 -machine virt -nographic \
- -smp "$CORES" \
- -kernel "$KERNEL" \
+ -cpu "$QEMU_CPU" \
+ -smp "$QEMU_SMP" \
+ -kernel "$QEMU_KERNEL" \
-initrd "$BUSYBOX_SRC/initramfs.cpio.gz" \
-append "root=/dev/ram" \
-append nokaslr \