1#!/bin/bash 2 3#Copyright (c) 2020-2021 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 31if [ "$elf_file" = "Invalid" ]; then 32 elf_file=out/SmartL_E802/qemu_csky_mini_system_demo/OHOS_Image 33fi 34 35help_info=$(cat <<-END 36Usage: qemu-run [OPTION]... 37Run a OHOS image in qemu according to the options. 38 39 Options: 40 41 -e, --exec file_name kernel exec file name 42 -g, --gdb enable gdb for kernel 43 -h, --help print help info 44 45 By default, the kernel exec file is: ${elf_file}. 46END 47) 48 49if [ "$qemu_help" = "yes" ]; then 50 echo "${help_info}" 51 exit 0 52fi 53 54if [ "$gdb_enable" = "yes" ]; then 55 qemu_option+="-s -S" 56fi 57 58function unsupported_parameters_check(){ 59 if [ "$rebuild_image" = "yes" ]; then 60 echo "Error: The -f|--force option is not supported !" 61 echo "${help_info}" 62 exit 1 63 fi 64 65 if [ "$vnc_enable" = "no" ]; then 66 echo "Error: The -l|--local-desktop option is not supported !" 67 echo "${help_info}" 68 exit 1 69 fi 70 71 if [ "$add_boot_args" = "yes" ]; then 72 echo "Error: The -b|--bootargs option is not supported !" 73 echo "${help_info}" 74 exit 1 75 fi 76 77 if [ "$net_enable" = "yes" ]; then 78 echo "Error: The -n|--net-enable option is not supported !" 79 echo "${help_info}" 80 exit 1 81 fi 82 83 if [ "$qemu_test" = "test" ]; then 84 echo "Error: The -t|--qemu-test option is not supported !" 85 echo "${help_info}" 86 exit 1 87 fi 88} 89 90function start_qemu(){ 91 qemu-system-cskyv2 -machine smartl -nographic -kernel $elf_file $qemu_option 92} 93 94unsupported_parameters_check 95 96start_qemu 97