forked from guysoft/CustomPiOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qemu_boot64.sh
executable file
·73 lines (51 loc) · 2.69 KB
/
qemu_boot64.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# Script to start any CustomPiOS raspbian image from qemu
# Usage: qemu_boot.sh </path/to/zip/with/img/file.zip>
set -x
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ZIP_IMG=$1
DEST=/tmp
source ${DIR}/common.sh
if [[ $ZIP_IMG == *.zip ]]; then
IMG_NAME=$(unzip -Z "${ZIP_IMG}" | head -n 3 | tail -n 1 | awk '{ print $9 }')
else
unxz --keep "${ZIP_IMG}"
IMG_NAME=$(echo $(basename $ZIP_IMG) | sed "s/.xz//")
fi
BASE_IMG_PATH=${DEST}/"${IMG_NAME}"
if [ ! -f "${BASE_IMG_PATH}" ]; then
unzip -o "${ZIP_IMG}" -d "${DEST}"
BASE_ROOT_PARTITION=2
BASE_MOUNT_PATH=${DEST}/mount
mkdir -p "${BASE_MOUNT_PATH}"
sudo bash -c "$(declare -f mount_image); $(declare -f detach_all_loopback); mount_image $BASE_IMG_PATH $BASE_ROOT_PARTITION $BASE_MOUNT_PATH $BASE_BOOT_MOUNT_PATH $BASE_BOOT_PARTITION"
pushd "${BASE_MOUNT_PATH}"
sudo bash -c "$(declare -f fixLd); fixLd"
sudo sed -e '/PARTUUID/ s/^#*/#/' -i etc/fstab
popd
pushd "${BASE_MOUNT_PATH}/boot"
rm -rf /tmp/debian_bootpart || true
mkdir /tmp/debian_bootpart
cp kernel8.img /tmp/debian_bootpart
DTB_PATH="$(ls *-3-b.dtb | head)"
# sudo bash -c 'cp initrd.img*-arm64 /tmp/debian_bootpart'
cp ${DTB_PATH} /tmp/debian_bootpart
# sudo bash -c 'cp cmdline.txt /tmp/debian_bootpart'
# sudo bash -c 'cp vmlinuz-*-arm64 /tmp/debian_bootpart'
popd
sudo bash -c "$(declare -f mount_image); $(declare -f detach_all_loopback); unmount_image $BASE_MOUNT_PATH force"
fi
#/usr/bin/qemu-system-aarch64 -kernel ${KERNEL_PATH} -cpu host -m 256 -M virt -dtb ${DTB_PATH} -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda ${BASE_IMG_PATH} -net nic -net user,hostfwd=tcp::5022-:22
#sudo qemu-system-arm -enable-kvm -m 1024 -cpu host -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=vivid-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0,mac=$randmac
#/usr/bin/qemu-system-arm -kernel ${KERNEL_PATH} -cpu arm1176 -m 256 -M versatilepb -dtb ${DTB_PATH} -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda ${BASE_IMG_PATH} -net nic -net user,hostfwd=tcp::5022-:22
DTB_PATH=$(ls /tmp/debian_bootpart/*-3-b.dtb | head)
qemu-system-aarch64 \
-kernel /tmp/debian_bootpart/kernel8.img \
-dtb "${DTB_PATH}" \
-m 1024 -M raspi3 \
-cpu cortex-a53 \
-serial stdio \
-append "rw earlycon=pl011,0x3f201000 console=ttyAMA0 loglevel=8 root=/dev/mmcblk0p2 fsck.repair=yes net.ifnames=0 rootwait memtest=1" \
-drive file="${BASE_IMG_PATH}",format=raw,if=sd \
-no-reboot
#sudo umount ${BASE_MOUNT_PATH}