4 echo "Usage: $(basename $0) --arch [arm|arm64] [options]"
5 echo -e "Starts QEMU system mode emulation for the architecture.\n"
6 echo -e " --help\t\t\tDisplay this information."
7 echo -e " --arch {arm|arm64}\t\tSelects architecture QEMU system emulation."
8 echo -e " --sve\t\t\t\tEnables AArch64 SVE mode."
9 echo -e " --mte\t\t\t\tEnables AArch64 MTE mode."
10 echo -e " --sme\t\t\t\tEnables AArch64 SME mode."
11 echo -e " --rootfs {path}\t\tPath of root file system image."
12 echo -e " --qemu {path}\t\t\tPath of pre-installed qemu-system-* executable."
13 echo -e " --kernel {path}\t\tPath of Linux kernel prebuilt image.\n"
14 echo -e "By default this utility will use:"
15 echo -e " QEMU image built from source in qemu.git directory"
16 echo -e " Linux kernel image from linux.build/(arm or arm64) directory."
17 echo -e "Custom Linux kernel image or QEMU binary can be provided using commandline."
22 echo "ERROR: Unrecognized argument: $1" >&2
35 -machine $QEMU_MACHINE \
36 -drive file=$ROOTFS_IMG,if=none
,format
=raw
,id
=hd0 \
37 -device virtio-blk-device
,drive
=hd0 \
38 -append "root=/dev/vda rw ip=dhcp mem=1024M raid=noautodetect \
39 crashkernel=128M rootwait console=ttyAMA0 devtmpfs.mount=0" \
40 -netdev type=tap
,id
=net0 \
41 -device virtio-net-device
,netdev
=net0 \
46 while [[ $# -gt 0 ]]; do
47 case "${END_OF_OPT}${1}" in
48 --arch) ARCH
=$2; shift;;
49 --rootfs) ROOTFS_IMG
=$2; shift;;
50 --kernel) KERNEL_IMG
=$2; shift;;
51 --qemu) QEMU_BIN
=$2; shift;;
55 --help) print_usage
0 ;;
56 *) invalid_arg
"$1" ;;
61 if [ "$ARCH" == "arm64" ] && [ "$ARCH" == "arm" ]; then
62 echo "Invalid architecture: $ARCH"
66 if [[ ! -f "$ROOTFS_IMG" ]]; then
67 echo "No root file system image image available for emulation."
71 if [[ ! -f "$KERNEL_IMG" ]]; then
72 KERNEL_IMG_PATH
=$
(pwd)/linux.build
/"$ARCH"/arch
/"$ARCH"/boot
/
74 if [[ ! -d "$KERNEL_IMG_PATH" ]]; then
75 echo "No Linux kernel image available for emulation."
79 if [[ "$ARCH" == "arm" ]]; then
80 KERNEL_IMG
=$KERNEL_IMG_PATH/zImage
81 elif [[ "$ARCH" == "arm64" ]]; then
82 KERNEL_IMG
=$KERNEL_IMG_PATH/Image
86 if [[ ! -f "$QEMU_BIN" ]]; then
87 if [[ "$ARCH" == "arm" ]]; then
88 QEMU_BIN
=$
(pwd)/qemu.git
/arm-softmmu
/qemu-system-arm
89 elif [[ "$ARCH" == "arm64" ]]; then
90 QEMU_BIN
=$
(pwd)/qemu.git
/aarch64-softmmu
/qemu-system-aarch64
93 if [[ ! -f "$QEMU_BIN" ]]; then
94 echo "QEMU $ARCH system emulation executable not found."
99 if [[ "$ARCH" == "arm" ]]; then
100 QEMU_MACHINE
="virt,highmem=off"
101 QEMU_CPU
="cortex-a15"
104 echo "warning: --sve is supported by AArch64 targets only"
107 echo "warning: --mte is supported by AArch64 targets only"
110 echo "warning: --sme is supported by AArch64 targets only"
112 elif [[ "$ARCH" == "arm64" ]]; then
115 QEMU_CPU
="cortex-a53"
117 if [[ $SVE ]] ||
[[ $MTE ]] ||
[[ $SME ]]; then
121 if [[ $SVE ]] ||
[[ $SME ]]; then
122 QEMU_CPU
="$QEMU_CPU,sve-max-vq=$QEMU_SVE_MAX_VQ"
125 QEMU_MACHINE
="$QEMU_MACHINE,mte=on"