1#!/bin/bash 2 3#Copyright (c) 2022 Huawei Device Co., Ltd. 4#Licensed under the Apache License, Version 2.0 (the "License"); 5#you may not use this file except in compliance with the License. 6#You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10#Unless required by applicable law or agreed to in writing, software 11#distributed under the License is distributed on an "AS IS" BASIS, 12#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13#See the License for the specific language governing permissions and 14#limitations under the License. 15 16set -e 17 18elf_file=$1 19rebuild_image=$2 20vnc_enable=$3 21add_boot_args=$4 22boot_args=$5 23net_enable=$6 24gdb_enable=$7 25qemu_test=$8 26test_file=$9 27qemu_help=${10} 28 29qemu_option="" 30 31#### Submit code to CI test command, do not modify ##### 32if [ "$qemu_test" = "test" ]; then 33 qemu_option+="-serial file:$test_file" 34fi 35 36if [ "$elf_file" = "Invalid" ]; then 37 elf_file=out/arm_mps3_an547/qemu_cm55_mini_system_demo/OHOS_Image 38fi 39 40help_info=$(cat <<-END 41Usage: qemu-run [OPTION]... 42Run a OHOS image in qemu according to the options. 43 44 Options: 45 46 -e, --exec file_name kernel exec file name 47 -g, --gdb enable gdb for kernel 48 -t, --test test mode, exclusive with -g 49 -h, --help print help info 50 51 By default, the kernel exec file is: ${elf_file}. 52END 53) 54 55if [ "$qemu_help" = "yes" ]; then 56 echo "${help_info}" 57 exit 0 58fi 59 60if [ "$gdb_enable" = "yes" ]; then 61 qemu_option+="-s -S" 62fi 63 64function unsupported_parameters_check(){ 65 if [ "$rebuild_image" = "yes" ]; then 66 echo "Error: The -f|--force option is not supported !" 67 echo "${help_info}" 68 exit 1 69 fi 70 71 if [ "$vnc_enable" = "no" ]; then 72 echo "Error: The -l|--local-desktop option is not supported !" 73 echo "${help_info}" 74 exit 1 75 fi 76 77 if [ "$add_boot_args" = "yes" ]; then 78 echo "Error: The -b|--bootargs option is not supported !" 79 echo "${help_info}" 80 exit 1 81 fi 82 83 if [ "$net_enable" = "yes" ]; then 84 echo "Error: The -n|--net-enable option is not supported !" 85 echo "${help_info}" 86 exit 1 87 fi 88} 89 90function start_qemu(){ 91 qemu-system-arm -M mps3-an547 -m 2G -kernel $elf_file $qemu_option \ 92 -append "root=dev/vda or console=ttyS0" -nographic 93} 94 95 96unsupported_parameters_check 97 98start_qemu 99