• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 Huawei Device Co., Ltd.
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16set -e
17
18export OUT_DIR=$1
19export BUILD_TYPE=$2
20export KERNEL_ARCH=$3
21export PRODUCT_PATH=$4
22export DEVICE_NAME=$5
23export KERNEL_VERSION=$6
24
25if [ "$BUILD_TYPE" == "small" ];then
26    LINUX_KERNEL_OUT=${OUT_DIR}/kernel/${KERNEL_VERSION}
27elif [ "$BUILD_TYPE" == "standard" ];then
28    LINUX_KERNEL_OUT=${OUT_DIR}/kernel/src_tmp/${KERNEL_VERSION}
29fi
30LINUX_KERNEL_OBJ_OUT=${OUT_DIR}/kernel/OBJ/${KERNEL_VERSION}
31
32export OHOS_ROOT_PATH=$(pwd)/../../..
33# it needs adaptation for more device target
34kernel_image=""
35if [ "$KERNEL_ARCH" == "arm" ];then
36    kernel_image="uImage"
37elif [ "$KERNEL_ARCH" == "arm64" ];then
38    kernel_image="Image"
39elif [ "$KERNEL_ARCH" == "x86_64" ];then
40    kernel_image="bzImage"
41elif [ "$KERNEL_ARCH" == "loongarch64" ];then
42    kernel_image="vmlinuz.efi"
43fi
44export KERNEL_IMAGE=${kernel_image}
45
46if [ "$KERNEL_ARCH" == "riscv64" ];then
47    LINUX_KERNEL_IMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/arch/riscv/boot/Image
48elif [ "$KERNEL_ARCH" == "loongarch64" ];then
49    LINUX_KERNEL_IMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/${kernel_image}
50else
51    LINUX_KERNEL_IMAGE_FILE=${LINUX_KERNEL_OBJ_OUT}/arch/${KERNEL_ARCH}/boot/${kernel_image}
52fi
53
54if [ "$DEVICE_NAME" == "hispark_phoenix"  ];then
55export SDK_SOURCE_DIR=${OHOS_ROOT_PATH}/device/soc/hisilicon/hi3751v350/sdk_linux/source
56fi
57
58make -f kernel.mk
59
60if [ -f "${LINUX_KERNEL_IMAGE_FILE}" ];then
61    echo "Image: ${LINUX_KERNEL_IMAGE_FILE} build success"
62else
63    echo "Image: ${LINUX_KERNEL_IMAGE_FILE} build failed!!!"
64    exit 1
65fi
66
67if [ "$5" == "hispark_taurus" ];then
68    cp -rf ${LINUX_KERNEL_IMAGE_FILE} ${OUT_DIR}/uImage_${DEVICE_NAME}_smp
69fi
70
71exit 0
72