diff options
| author | Levent Kaya <levent.kaya@codefirst.io> | 2024-11-26 16:53:18 +0300 |
|---|---|---|
| committer | Levent Kaya <levent.kaya@codefirst.io> | 2024-11-26 16:53:18 +0300 |
| commit | 2acb66a1934a21185c4614837b0d9e6ff5b2bff8 (patch) | |
| tree | 8891d9053b26ad1239917dc5fd08b67c8cb9bcff | |
| parent | 46725b4a6414a39a944a485cebdf64ccea206b95 (diff) | |
[build] updated
| -rwxr-xr-x | fbgl_qemu_test_env.sh | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/fbgl_qemu_test_env.sh b/fbgl_qemu_test_env.sh index 0552539..c44a144 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/release/TinyCore-current.iso" # ISO_FILE="TinyCore.iso" # Local TinyCore ISO file DISK_IMAGE="tinycore_test.img" # Disk image for TinyCore DISK_SIZE="128M" # Size of the disk image -MOUNT_DIR="mnt_tinycore" # Temporary mount point for the disk image +MOUNT_DIR="mnt_tinycore" # Temporary mount point for the ISO +KERNEL_FILE="vmlinuz" # Extracted kernel file +INITRD_FILE="core.gz" # Extracted initrd file BINARY="$1" # Precompiled binary passed as argument # Ensure a binary is provided as an argument @@ -35,31 +37,42 @@ if [ ! -f "$ISO_FILE" ]; then wget -O $ISO_FILE $TINYCORE_URL fi -# Step 2: Create a 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/vmlinuz $KERNEL_FILE + cp $MOUNT_DIR/boot/core.gz $INITRD_FILE + sudo umount $MOUNT_DIR + rmdir $MOUNT_DIR +fi + +# Step 3: Create a Disk Image echo "Creating disk image..." dd if=/dev/zero of=$DISK_IMAGE bs=1M count=${DISK_SIZE/M/} status=progress mkfs.ext4 $DISK_IMAGE -# Step 3: Mount and Prepare Disk Image +# Step 4: Mount and Prepare Disk Image echo "Mounting disk image and adding binary..." mkdir -p $MOUNT_DIR sudo mount -o loop $DISK_IMAGE $MOUNT_DIR -# Create TinyCore directory structure and add binary +# Add precompiled binary to the disk sudo mkdir -p $MOUNT_DIR/tce sudo cp "$BINARY" $MOUNT_DIR/ sudo umount $MOUNT_DIR rmdir $MOUNT_DIR -# Step 4: Boot TinyCore Linux in QEMU +# Step 5: Boot TinyCore Linux in QEMU echo "Booting TinyCore Linux 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 \ -vga std \ - -boot d \ - -append "loglevel=3 tce=sda init=/init" \ -nographic echo "QEMU exited. Check above for errors or results." |
