summaryrefslogtreecommitdiff
path: root/fbgl_qemu_test_env.sh
diff options
context:
space:
mode:
authorLevent Kaya <levent.kaya@codefirst.io>2024-11-26 17:18:43 +0300
committerLevent Kaya <levent.kaya@codefirst.io>2024-11-26 17:18:43 +0300
commitc3252d07e4b03227b50a0564c2036be2dae61b7f (patch)
treeb7a4f50d85c1a9d27d9229cf27c512726df4693b /fbgl_qemu_test_env.sh
parentdbc515f42d76bebebb853bda1622e40668ab8a51 (diff)
[build]
Diffstat (limited to 'fbgl_qemu_test_env.sh')
-rwxr-xr-xfbgl_qemu_test_env.sh27
1 files changed, 21 insertions, 6 deletions
diff --git a/fbgl_qemu_test_env.sh b/fbgl_qemu_test_env.sh
index 6f329c3..e085b4d 100755
--- a/fbgl_qemu_test_env.sh
+++ b/fbgl_qemu_test_env.sh
@@ -5,7 +5,9 @@ TINYCORE_URL="http://tinycorelinux.net/14.x/x86_64/release/CorePure64-current.is
ISO_FILE="CorePure64.iso" # TinyCore Linux ISO file
DISK_IMAGE="tinycore_disk.img" # Writable disk image for TinyCore
DISK_SIZE="64M" # Size of the writable disk
-MOUNT_DIR="mnt_tinycore" # Temporary mount point for disk
+MOUNT_DIR="mnt_tinycore" # Temporary mount point for ISO
+KERNEL_FILE="vmlinuz64" # Kernel extracted from ISO
+INITRD_FILE="core.gz" # Initrd extracted from ISO
BINARY="$1" # Precompiled binary passed as argument
# Check if a binary is provided
@@ -35,12 +37,23 @@ if [ ! -f "$ISO_FILE" ]; then
wget -O $ISO_FILE $TINYCORE_URL
fi
-# Step 2: Create a writable disk image
+# Step 2: Extract Kernel and Initrd from ISO
+if [ ! -f "$KERNEL_FILE" ] || [ ! -f "$INITRD_FILE" ]; then
+ echo "Extracting kernel and initrd from TinyCore ISO..."
+ mkdir -p $MOUNT_DIR
+ sudo mount -o loop $ISO_FILE $MOUNT_DIR
+ cp $MOUNT_DIR/boot/vmlinuz64 $KERNEL_FILE
+ cp $MOUNT_DIR/boot/corepure64.gz $INITRD_FILE
+ sudo umount $MOUNT_DIR
+ rmdir $MOUNT_DIR
+fi
+
+# Step 3: Create a writable disk image
echo "Creating writable disk image..."
dd if=/dev/zero of=$DISK_IMAGE bs=1M count=${DISK_SIZE/M/} status=progress
mkfs.ext4 $DISK_IMAGE
-# Step 3: Mount the disk image and add the binary
+# Step 4: Mount the disk image and add the binary
echo "Mounting disk image and adding binary..."
mkdir -p $MOUNT_DIR
sudo mount -o loop $DISK_IMAGE $MOUNT_DIR
@@ -48,12 +61,14 @@ sudo cp "$BINARY" $MOUNT_DIR/
sudo umount $MOUNT_DIR
rmdir $MOUNT_DIR
-# Step 4: Run TinyCore Linux in QEMU without graphical interface
+# Step 5: Run TinyCore Linux in QEMU with extracted kernel and initrd
echo "Running TinyCore Linux in terminal mode with QEMU..."
qemu-system-x86_64 \
- -cdrom $ISO_FILE \
+ -kernel $KERNEL_FILE \
+ -initrd $INITRD_FILE \
+ -append "loglevel=3 tce=sda1 init=/init" \
-hda $DISK_IMAGE \
-m 512M \
- -append "loglevel=3 tce=sda1 init=/init"
+ -nographic
echo "QEMU exited. Check above for errors or results."