From f3363c108806cf2d647464342322d39afc33235a Mon Sep 17 00:00:00 2001 From: Marco Cutecchia Date: Sat, 11 Mar 2023 12:51:47 +0100 Subject: [PATCH] Meta: Run aarch64 with the disk image in the SD card slot Co-authored-by: Timon Kruiper Co-authored-by: Ollrogge --- Meta/build-image-qemu.sh | 13 +++++++++++++ Meta/run.sh | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh index 852789ef7c..779bc87b0b 100755 --- a/Meta/build-image-qemu.sh +++ b/Meta/build-image-qemu.sh @@ -71,6 +71,19 @@ else DISK_SIZE_BYTES="$SERENITY_DISK_SIZE_BYTES" fi +nearest_power_of_2() { + local n=$1 + local p=1 + while [ $p -lt "$n" ]; do + p=$((p*2)) + done + echo $p +} +if [ "$SERENITY_ARCH" = "aarch64" ]; then + # The Aarch64 port loads from an SD card, which must have a size that is a power of 2 + DISK_SIZE_BYTES=$(nearest_power_of_2 "$DISK_SIZE_BYTES") +fi + USE_EXISTING=0 if [ -f _disk_image ]; then diff --git a/Meta/run.sh b/Meta/run.sh index ffba395508..b3a2209754 100755 --- a/Meta/run.sh +++ b/Meta/run.sh @@ -279,7 +279,11 @@ fi # add -machine vmport=off below to run the machine with ps/2 mouse if [ -z "$SERENITY_MACHINE" ]; then if [ "$SERENITY_ARCH" = "aarch64" ]; then - SERENITY_MACHINE="-M raspi3b -serial stdio" + SERENITY_MACHINE=" + -M raspi3b + -serial stdio + -drive file=${SERENITY_DISK_IMAGE},if=sd,format=raw + " else SERENITY_MACHINE=" -m $SERENITY_RAM_SIZE