| From 265dbc4d0129b04b94d566fb4c05ce1ec7871d14 Mon Sep 17 00:00:00 2001 |
| From: Shengken Lin <shengken.lin@amlogic.corp-partner.google.com> |
| Date: Mon, 4 Nov 2024 15:17:36 +0800 |
| Subject: [PATCH] Swift: Add amlogic Code check |
| |
| Bug: 340928508 |
| Test: build ok |
| |
| Change-Id: Idcf07b58b8f525ef7b2998b02f763dbd47373f68 |
| Signed-off-by: Shengken Lin <shengken.lin@amlogic.corp-partner.google.com> |
| --- |
| scripts/amlogic/amlogic_smarthome_utils.sh | 236 ++++++++++++ |
| scripts/amlogic/compare_text_section.sh | 122 ++++++ |
| scripts/amlogic/ext_modules_config | 8 + |
| scripts/amlogic/ext_modules_list | 10 + |
| scripts/amlogic/ext_modules_path | 4 + |
| scripts/amlogic/licence_check.pl | 153 ++++++++ |
| scripts/amlogic/licence_pre.pl | 53 +++ |
| scripts/amlogic/merge_pre_check.pl | 429 +++++++++++++++++++++ |
| scripts/amlogic/mk_c3_min.sh | 30 ++ |
| scripts/amlogic/mk_gx32.sh | 23 ++ |
| scripts/amlogic/mk_gx64.sh | 27 ++ |
| scripts/amlogic/mk_riscv.sh | 13 + |
| scripts/amlogic/mk_smarthome32.sh | 12 + |
| scripts/amlogic/mk_smarthome32_clang.sh | 13 + |
| scripts/amlogic/mk_smarthome64.sh | 12 + |
| scripts/amlogic/mk_smarthome64_clang.sh | 13 + |
| scripts/amlogic/mk_smarthome_common.sh | 95 +++++ |
| scripts/amlogic/mk_zapper32.sh | 30 ++ |
| scripts/amlogic/modules_sequence_list | 84 ++++ |
| scripts/amlogic/pre-commit | 24 ++ |
| 20 files changed, 1391 insertions(+) |
| create mode 100644 scripts/amlogic/amlogic_smarthome_utils.sh |
| create mode 100755 scripts/amlogic/compare_text_section.sh |
| create mode 100644 scripts/amlogic/ext_modules_config |
| create mode 100644 scripts/amlogic/ext_modules_list |
| create mode 100644 scripts/amlogic/ext_modules_path |
| create mode 100755 scripts/amlogic/licence_check.pl |
| create mode 100755 scripts/amlogic/licence_pre.pl |
| create mode 100755 scripts/amlogic/merge_pre_check.pl |
| create mode 100755 scripts/amlogic/mk_c3_min.sh |
| create mode 100755 scripts/amlogic/mk_gx32.sh |
| create mode 100755 scripts/amlogic/mk_gx64.sh |
| create mode 100755 scripts/amlogic/mk_riscv.sh |
| create mode 100755 scripts/amlogic/mk_smarthome32.sh |
| create mode 100755 scripts/amlogic/mk_smarthome32_clang.sh |
| create mode 100755 scripts/amlogic/mk_smarthome64.sh |
| create mode 100755 scripts/amlogic/mk_smarthome64_clang.sh |
| create mode 100755 scripts/amlogic/mk_smarthome_common.sh |
| create mode 100755 scripts/amlogic/mk_zapper32.sh |
| create mode 100644 scripts/amlogic/modules_sequence_list |
| create mode 100755 scripts/amlogic/pre-commit |
| |
| diff --git a/scripts/amlogic/amlogic_smarthome_utils.sh b/scripts/amlogic/amlogic_smarthome_utils.sh |
| new file mode 100644 |
| index 000000000000..29b7da54f041 |
| --- /dev/null |
| +++ b/scripts/amlogic/amlogic_smarthome_utils.sh |
| @@ -0,0 +1,236 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| +function handle_input_parameters_for_smarthome () { |
| + VA= |
| + ARGS=() |
| + for i in "$@" |
| + do |
| + case $i in |
| + --savedefconfig) |
| + SAVEDEFCONFIG=1 |
| + shift |
| + ;; |
| + --menuconfig) |
| + MENUCONFIG=1 |
| + shift |
| + ;; |
| + --dtbs) |
| + DTB=1 |
| + shift |
| + ;; |
| + --manual_insmod_module) |
| + MANUAL_INSMOD_MODULE=1 |
| + shift |
| + ;; |
| + --patch) |
| + ONLY_PATCH=1 |
| + shift |
| + ;; |
| + -h|--help) |
| + show_help |
| + exit 0 |
| + ;; |
| + *) |
| + if [[ -n $1 ]]; |
| + then |
| + if [[ -z ${VA} ]]; |
| + then |
| + ARGS+=("$1") |
| + fi |
| + fi |
| + VA= |
| + shift |
| + ;; |
| + esac |
| + done |
| +} |
| + |
| +export -f handle_input_parameters_for_smarthome |
| + |
| +function set_default_parameters_for_smarthome () { |
| + version_message=$(grep -rn BRANCH= ${KERNEL_DIR}/build.config.constants) |
| + if [[ -z ${version_message} ]]; then |
| + version_message=$(grep -rn BRANCH= ${KERNEL_DIR}/build.config.common) |
| + fi |
| + version_message="common${version_message##*android}" |
| + if [[ -n ${FULL_KERNEL_VERSION} ]]; then |
| + if [[ "${FULL_KERNEL_VERSION}" != "${version_message}" ]]; then |
| + echo "kernel version is not match!!" |
| + exit |
| + fi |
| + else |
| + FULL_KERNEL_VERSION=${version_message} |
| + fi |
| + |
| + tool_args=() |
| + prebuilts_paths=( |
| + CLANG_PREBUILT_BIN |
| + #BUILDTOOLS_PREBUILT_BIN |
| + ) |
| + echo CC_CLANG=$CC_CLANG |
| + if [[ $CC_CLANG -eq "1" ]]; then |
| + source ${ROOT_DIR}/${KERNEL_DIR}/build.config.common |
| + if [[ -n "${LLVM}" ]]; then |
| + tool_args+=("LLVM=1") |
| + fi |
| + #if [ -n "${DTC}" ]; then |
| + # tool_args+=("DTC=${DTC}") |
| + #fi |
| + for prebuilt_bin in "${prebuilts_paths[@]}"; do |
| + prebuilt_bin=\${${prebuilt_bin}} |
| + eval prebuilt_bin="${prebuilt_bin}" |
| + if [ -n "${prebuilt_bin}" ]; then |
| + PATH=${PATH//"${ROOT_DIR}\/${prebuilt_bin}:"} |
| + PATH=${ROOT_DIR}/${prebuilt_bin}:${PATH} # add the clang tool to env PATH |
| + fi |
| + done |
| + export PATH |
| + elif [[ -z $CROSS_COMPILE_TOOL ]]; then |
| + if [[ $ARCH == arm64 ]]; then |
| + CROSS_COMPILE_TOOL=${ROOT_DIR}/prebuilts/gcc/host/linux-x86/aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- |
| + else |
| + CROSS_COMPILE_TOOL=${ROOT_DIR}/prebuilts/gcc/host/linux-x86/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf- |
| + fi |
| + export CROSS_COMPILE=${CROSS_COMPILE_TOOL} |
| + fi |
| + |
| + local kernel_version=${FULL_KERNEL_VERSION##*-} |
| + if [[ $ARCH == arm64 ]]; then |
| + OUTDIR=${ROOT_DIR}/out/kernel-${kernel_version}-64 |
| + elif [[ $ARCH == arm ]]; then |
| + OUTDIR=${ROOT_DIR}/out/kernel-${kernel_version}-32 |
| + tool_args+=("LOADADDR=0x108000") |
| + elif [[ $ARCH == riscv ]]; then |
| + OUTDIR=${ROOT_DIR}/out/riscv-kernel-${kernel_version}-64 |
| + fi |
| + TOOL_ARGS="${tool_args[@]}" |
| + |
| + OUT_DIR=${OUTDIR}/common |
| + mkdir -p ${OUT_DIR} |
| + if [ "${SKIP_RM_OUTDIR}" != "1" ] ; then |
| + rm -rf ${OUTDIR} |
| + fi |
| + |
| + echo "========================================================" |
| + echo "" |
| + export DIST_DIR=$(readlink -m ${OUTDIR}/dist) |
| + export MODULES_STAGING_DIR=$(readlink -m ${OUTDIR}/staging) |
| + export OUT_AMLOGIC_DIR=$(readlink -m ${OUTDIR}/amlogic) |
| + echo OUTDIR=$OUTDIR DIST_DIR=$DIST_DIR MODULES_STAGING_DIR=$MODULES_STAGING_DIR KERNEL_DIR=$KERNEL_DIR |
| + |
| + |
| + source ${ROOT_DIR}/build/kernel/build_utils.sh |
| + |
| + DTS_EXT_DIR=${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/arch/${ARCH}/boot/dts/amlogic |
| + DTS_EXT_DIR=$(real_path ${ROOT_DIR}/${DTS_EXT_DIR} ${KERNEL_DIR}) |
| + export dtstree=${DTS_EXT_DIR} |
| + export DTC_INCLUDE=${ROOT_DIR}/${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/include |
| + |
| + EXT_MODULES=" |
| + ${EXT_MODULES} |
| + " |
| + |
| + EXT_MODULES_CONFIG=" |
| + ${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/scripts/amlogic/ext_modules_config |
| + " |
| + |
| + EXT_MODULES_PATH=" |
| + ${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/scripts/amlogic/ext_modules_path |
| + " |
| + |
| + POST_KERNEL_BUILD_CMDS="prepare_module_build" |
| + EXTRA_CMDS="extra_cmds" |
| + |
| + IN_KERNEL_MODULES=1 |
| +} |
| +export -f set_default_parameters_for_smarthome |
| + |
| +function savedefconfig_cmd_for_smarthome () { |
| + if [[ -n ${SAVEDEFCONFIG} ]]; then |
| + set -x |
| + make ARCH=${ARCH} -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${DEFCONFIG} |
| + make ARCH=${ARCH} -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} savedefconfig |
| + rm ${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/arch/${ARCH}/configs/${DEFCONFIG} |
| + cp -f ${OUT_DIR}/defconfig ${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/arch/${ARCH}/configs/${DEFCONFIG} |
| + set +x |
| + exit |
| + fi |
| +} |
| +export -f savedefconfig_cmd_for_smarthome |
| + |
| +function only_build_dtb_for_smarthome () { |
| + if [[ -n ${DTB} ]]; then |
| + set -x |
| + make ARCH=${ARCH} -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} ${DEFCONFIG} |
| + make ARCH=${ARCH} -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} dtbs || exit |
| + set +x |
| + cp ${OUT_DIR}/${COMMON_DRIVERS_DIR}/arch/${ARCH}/boot/dts/amlogic/*.dtb ${DIST_DIR} |
| + echo "finish building dtbs!" |
| + exit |
| + fi |
| +} |
| +export -f only_build_dtb_for_smarthome |
| + |
| +function make_menuconfig_cmd_for_smarthome () { |
| + if [[ -n ${MENUCONFIG} ]]; then |
| + set -x |
| + make ARCH=${ARCH} -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} ${DEFCONFIG} |
| + make ARCH=${ARCH} -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} menuconfig |
| + set +x |
| + exit |
| + fi |
| +} |
| +export -f make_menuconfig_cmd_for_smarthome |
| + |
| +function copy_modules_and_rebuild_rootfs_for_smarthome () { |
| + |
| + copy_modules_files_to_dist_dir |
| + |
| + if [ -f ${ROOT_DIR}/${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/rootfs_base.cpio.gz.uboot ]; then |
| + echo "========================================================" |
| + echo "Rebuild rootfs in order to install modules!" |
| + rebuild_rootfs ${ARCH} |
| + echo "Build success!" |
| + else |
| + echo "There's no file ${ROOT_DIR}/${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/rootfs_base.cpio.gz.uboot, so don't rebuild rootfs!" |
| + fi |
| +} |
| +export -f copy_modules_and_rebuild_rootfs_for_smarthome |
| + |
| +function build_kernel_for_different_cpu_architecture () { |
| + set -x |
| + if [[ -d ${MODULES_STAGING_DIR} ]]; then #for building fast with command SKIP_RM_OUTDIR=1 |
| + rm -rf ${MODULES_STAGING_DIR} #remove last build staging dir |
| + fi |
| + if [[ $ARCH == arm64 ]]; then |
| + make ARCH=arm64 -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} ${DEFCONFIG} |
| + make ARCH=arm64 -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} headers_install && |
| + make ARCH=arm64 -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} Image -j12 && |
| + make ARCH=arm64 -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} modules -j12 && |
| + make ARCH=arm64 -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} INSTALL_MOD_PATH=${MODULES_STAGING_DIR} INSTALL_MOD_STRIP=1 modules_install -j12 && |
| + make ARCH=arm64 -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} dtbs -j12 || exit |
| + elif [[ $ARCH == arm ]]; then |
| + make ARCH=arm -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} ${DEFCONFIG} |
| + make ARCH=arm -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} headers_install && |
| + make ARCH=arm -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} uImage -j12 && |
| + make ARCH=arm -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} modules -j12 && |
| + make ARCH=arm -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} INSTALL_MOD_PATH=${MODULES_STAGING_DIR} INSTALL_MOD_STRIP=1 modules_install -j12 && |
| + make ARCH=arm -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} dtbs -j12 || exit |
| + elif [[ $ARCH == riscv ]]; then |
| + make ARCH=riscv -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} ${DEFCONFIG} |
| + make ARCH=riscv -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} headers_install && |
| + make ARCH=riscv -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} Image -j12 && |
| + make ARCH=riscv -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} modules -j12 && |
| + make ARCH=riscv -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} INSTALL_MOD_PATH=${MODULES_STAGING_DIR} modules_install -j12 && |
| + make ARCH=riscv -C ${ROOT_DIR}/${KERNEL_DIR} O=${OUT_DIR} ${TOOL_ARGS} dtbs -j12 || exit |
| + fi |
| + cp ${OUT_DIR}/arch/${ARCH}/boot/Image* ${DIST_DIR} |
| + cp ${OUT_DIR}/arch/${ARCH}/boot/uImage* ${DIST_DIR} |
| + cp ${OUT_DIR}/${COMMON_DRIVERS_DIR}/arch/${ARCH}/boot/dts/amlogic/*.dtb ${DIST_DIR} |
| + cp ${OUT_DIR}/vmlinux ${DIST_DIR} |
| + set +x |
| +} |
| +export -f build_kernel_for_different_cpu_architecture |
| diff --git a/scripts/amlogic/compare_text_section.sh b/scripts/amlogic/compare_text_section.sh |
| new file mode 100755 |
| index 000000000000..1a01c6bb8424 |
| --- /dev/null |
| +++ b/scripts/amlogic/compare_text_section.sh |
| @@ -0,0 +1,122 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: GPL-2.0 |
| + |
| +# ./common/common_drivers/scripts/amlogic/compare_text_section --vmlinux_gki <path>/vmlinux --vmlinux_amlogic <path>/vmlinux |
| +function show_help { |
| + echo "USAGE:" |
| + echo |
| + echo " --vmlinux_gki ori vmlinux file, eg: <path>/vmlinux" |
| + echo " --vmlinux_amlogic amlogic vmlinux file, eg: <path>/vmlinux" |
| + echo " --buildtool_dir build tool bin path" |
| + echo " --output output dir, default: ./compare_text_tmp/" |
| +} |
| + |
| +for i in "$@" |
| +do |
| + case $i in |
| + --vmlinux_gki) |
| + VM_GKI_FILE=$2 |
| + shift |
| + ;; |
| + --vmlinux_amlogic) |
| + VM_AMLOGIC_FILE=$2 |
| + shift |
| + ;; |
| + --buildtool_dir) |
| + BUILDTOOL_DIR=$2 |
| + shift |
| + ;; |
| + --output) |
| + OUTPUT_DIR=$2 |
| + shift |
| + ;; |
| + -h|--help) |
| + show_help |
| + exit 0 |
| + ;; |
| + *) |
| + shift |
| + ;; |
| + esac |
| +done |
| + |
| +if [[ ! -e ${VM_GKI_FILE} ]]; then |
| + echo "gki vmlinux not exit, --vmlinux_gki ${VM_GKI_FILE}, Failed!" |
| + exit 0 |
| +fi |
| + |
| +if [[ ! -e ${VM_AMLOGIC_FILE} ]]; then |
| + echo "amlogic vmlinux not exit, --vmlinux_amlogic ${VM_AMLOGIC_FILE}, Failed!" |
| + exit 0 |
| +fi |
| + |
| +if [[ ! -d ${BUILDTOOL_DIR} ]]; then |
| + DEFAULT_BUILD_CONFIG_CONSTANTS=common/build.config.constants |
| + DEFAULT_BUILD_CONFIG_COMMON=common/build.config.common |
| + [[ -f ${DEFAULT_BUILD_CONFIG_CONSTANTS} ]] && source ${DEFAULT_BUILD_CONFIG_CONSTANTS} |
| + [[ -f ${DEFAULT_BUILD_CONFIG_COMMON} ]] && source ${DEFAULT_BUILD_CONFIG_COMMON} |
| + |
| + if [[ ! -d ${CLANG_PREBUILT_BIN} ]]; then |
| + echo "--buildtool_dir not exit, --buildtool_dir ${BUILDTOOL_DIR}, Failed!" |
| + exit 0 |
| + else |
| + BUILDTOOL_DIR=${CLANG_PREBUILT_BIN} |
| + fi |
| +fi |
| + |
| +if [ -z ${OUTPUT_DIR} ]; then |
| + OUTPUT_DIR=compare_text_tmp |
| +fi |
| + |
| +if [ -e ${OUTPUT_DIR} ] |
| +then |
| + rm -rf ${OUTPUT_DIR} |
| +fi |
| + |
| +echo "VM_GKI_FILE=${VM_GKI_FILE} VM_AMLOGIC_FILE=${VM_AMLOGIC_FILE} BUILDTOOL_DIR=${BUILDTOOL_DIR} OUTPUT_DIR=${OUTPUT_DIR}" |
| + |
| +mkdir -p ${OUTPUT_DIR} |
| +VM_GKI_FILE_NAME=${VM_GKI_FILE##*/}.gki |
| +VM_AMLOGIC_FILE_NAME=${VM_AMLOGIC_FILE##*/}.amlogic |
| +TEXT_GKI_FILE=${VM_GKI_FILE_NAME}.text |
| +TEXT_AMLOGIC_FILE=${VM_AMLOGIC_FILE_NAME}.text |
| + |
| +#copy vmlinux to output path |
| +cp ${VM_GKI_FILE} ${OUTPUT_DIR}/${VM_GKI_FILE_NAME} |
| +cp ${VM_AMLOGIC_FILE} ${OUTPUT_DIR}/${VM_AMLOGIC_FILE_NAME} |
| + |
| +#objdump .text section |
| +${BUILDTOOL_DIR}/llvm-objdump --section=.text -d ${OUTPUT_DIR}/${VM_GKI_FILE_NAME} > ${OUTPUT_DIR}/${TEXT_GKI_FILE} |
| +${BUILDTOOL_DIR}/llvm-objdump --section=.text -d ${OUTPUT_DIR}/${VM_AMLOGIC_FILE_NAME} > ${OUTPUT_DIR}/${TEXT_AMLOGIC_FILE} |
| + |
| +#only need compare until cmd column |
| +clang_hash_format=`awk 'NR==7 {print $2}' ${OUTPUT_DIR}/${TEXT_GKI_FILE}` |
| +echo clang_hash_format=${clang_hash_format} |
| +if [ $((16#${clang_hash_format})) -gt $((16#ff)) ]; then |
| + awk '{NF=3}1' ${OUTPUT_DIR}/${TEXT_GKI_FILE} > ${OUTPUT_DIR}/${TEXT_GKI_FILE}.tmp |
| + awk '{NF=3}1' ${OUTPUT_DIR}/${TEXT_AMLOGIC_FILE} > ${OUTPUT_DIR}/${TEXT_AMLOGIC_FILE}.tmp |
| +else |
| + awk '{NF=6}1' ${OUTPUT_DIR}/${TEXT_GKI_FILE} > ${OUTPUT_DIR}/${TEXT_GKI_FILE}.tmp |
| + awk '{NF=6}1' ${OUTPUT_DIR}/${TEXT_AMLOGIC_FILE} > ${OUTPUT_DIR}/${TEXT_AMLOGIC_FILE}.tmp |
| +fi |
| + |
| +diff -y --suppress-common-lines ${OUTPUT_DIR}/${TEXT_AMLOGIC_FILE}.tmp ${OUTPUT_DIR}/${TEXT_GKI_FILE}.tmp > ${OUTPUT_DIR}/diff.log.tmp |
| + |
| +#save cmd or address different line |
| +sed -i '/compare_text_tmp/d' ${OUTPUT_DIR}/diff.log.tmp |
| + |
| +if [ $((16#${clang_hash_format})) -gt $((16#ff)) ]; then |
| + awk '$1 ~ /:/ && ($1 != $5 || $3 != $7)' ${OUTPUT_DIR}/diff.log.tmp > ${OUTPUT_DIR}/diff.log |
| +else |
| + awk '$1 ~ /:/ && ($1 != $8 || $6 != $13)' ${OUTPUT_DIR}/diff.log.tmp > ${OUTPUT_DIR}/diff.log |
| +fi |
| + |
| +#output compare info |
| +if [ -s ${OUTPUT_DIR}/diff.log ]; then |
| + FIRST_ADDRESS=$(awk '{print $1}' ${OUTPUT_DIR}/diff.log | sed -n '1p') |
| + ADDR_INFO=`${BUILDTOOL_DIR}/llvm-addr2line -e ${OUTPUT_DIR}/${VM_AMLOGIC_FILE_NAME} ${FIRST_ADDRESS%%:*}` |
| + echo "Failed, first different with address: ${FIRST_ADDRESS}, info: ${ADDR_INFO}" |
| + echo "More different see the ${OUTPUT_DIR}/diff.log file" |
| +else |
| + echo "Succeed, Check not break" |
| +fi |
| diff --git a/scripts/amlogic/ext_modules_config b/scripts/amlogic/ext_modules_config |
| new file mode 100644 |
| index 000000000000..2b94d079baff |
| --- /dev/null |
| +++ b/scripts/amlogic/ext_modules_config |
| @@ -0,0 +1,8 @@ |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| + |
| +# CONFIG_M1_TEST1=m |
| + |
| +# CONFIG_M1_TEST2=m |
| +# CONFIG_M1_TEST2_PRINT_TASK=y |
| + |
| +# CONFIG_M2_TEST1=m |
| diff --git a/scripts/amlogic/ext_modules_list b/scripts/amlogic/ext_modules_list |
| new file mode 100644 |
| index 000000000000..54d74249bdba |
| --- /dev/null |
| +++ b/scripts/amlogic/ext_modules_list |
| @@ -0,0 +1,10 @@ |
| +EXTRA_CLOSED_SOURCE_MODULE_LIST=( |
| + tcon_fw.ko |
| + dnlp_alg.ko |
| + amlogic_fbc_lib.ko |
| + ldim_fw.ko |
| + hdr10_tmo_alg.ko |
| + cuva_hdr_alg.ko |
| + *_fe.ko |
| + frc*.ko |
| +) |
| diff --git a/scripts/amlogic/ext_modules_path b/scripts/amlogic/ext_modules_path |
| new file mode 100644 |
| index 000000000000..5b898657d560 |
| --- /dev/null |
| +++ b/scripts/amlogic/ext_modules_path |
| @@ -0,0 +1,4 @@ |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| + |
| +# my_drivers1 |
| +# ext_modules/my_drivers2 |
| diff --git a/scripts/amlogic/licence_check.pl b/scripts/amlogic/licence_check.pl |
| new file mode 100755 |
| index 000000000000..2163ce102ab6 |
| --- /dev/null |
| +++ b/scripts/amlogic/licence_check.pl |
| @@ -0,0 +1,153 @@ |
| +#!/usr/bin/perl -W |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| +use File::Basename; |
| +use File::Find; |
| + |
| +$sc_dir = File::Spec->rel2abs(dirname( "$0") ) ; |
| +$sc_dir =~ s/\/scripts\/amlogic//; |
| +my $top = "$sc_dir"; |
| + |
| +my $nofix = 0; |
| +my $failno = 0; |
| +my $shname = $0; |
| +#@ARGV=("../../include/linux/amlogic","../../drivers/amlogic" ) ; |
| +my @path; |
| +for(@ARGV) |
| +{ |
| + my $dir =$_; |
| + if(/^\//) |
| + { |
| + } |
| + elsif(/--nofix/) |
| + { |
| + $nofix = 1; |
| + next; |
| + } |
| + else |
| + { |
| + $dir = File::Spec->rel2abs($dir); |
| + #print "\n Real2abs Dir: --$dir-- \n"; |
| + } |
| + push(@path,$dir); |
| +} |
| + |
| + |
| +my $licence_start="// SPDX-License-Identifier: (GPL-2.0+ OR MIT)\n"; |
| +my $licence_end= |
| +"/* |
| + * Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| + */\n\n"; |
| + |
| +#print $licence; |
| + |
| +sub licence_process |
| +{ |
| + my ($file_name) = @_; |
| + my $d = dirname($file_name); |
| + my $f = basename($file_name); |
| + #print "\n Abs <$d>, f_ $f"; |
| + #print "\n Top: <$top> "; |
| + |
| + $licence_0=$licence_start.$licence_end; |
| + my $count = 0; |
| + my $text_0=""; |
| + my $text_all=$licence_0; |
| + open(my $f_in, '<', $file_name) or die "Can't Open $file_name: For Read \n"; |
| + my ($left,$right, $lineno,$space) = (0, 0, 0,0); |
| + while ($line = <$f_in>) |
| + { |
| + $text_0 .= $line; |
| + #Empty Line or Line marked by // |
| + if(($space==0) &&(($line =~/^\s*$/)|| |
| + (($line =~/^\s*\/\//)&&($line !~ /\*\//)))) |
| + { |
| + #print "\n Line $lineno is empty."; |
| + } |
| + elsif(($space==0) &&($line =~ /^\s*\/\*/)) #Match /* |
| + { |
| + $left ++; |
| + #print "\n L Matched: $lineno $line, $left "; #Match that /* and */ in the same line |
| + if($line =~ /\*\//) |
| + { |
| + $right ++; |
| + #print "\n L Matched: $lineno $line, $left "; |
| + } |
| + } |
| + elsif(($space==0) &&($line =~ /\*\//)&& ($line !~ /\/\*/) ) #Match */ |
| + { |
| + $right ++; |
| + #print "\n R Matched: $lineno $line, $right "; |
| + if($left == $right) |
| + { |
| + $space = 1; |
| + } |
| + } |
| + elsif($left==$right) #Content Lines |
| + { |
| + if(($line =~/^\s*$/)&& ($count==0)) |
| + { |
| + |
| + } |
| + else |
| + { |
| + #print $line; |
| + $space = 1; |
| + $count +=1; |
| + $text_all .=$line; |
| + } |
| + } |
| + $lineno++; |
| + } |
| + close($f_in); |
| + |
| + if($text_0 ne $text_all) |
| + { |
| + $failno ++; |
| + if($nofix) |
| + { |
| + print "\n Licence_WARN: <"; |
| + print File::Spec->abs2rel($file_name, $top).">\n";; |
| + } |
| + else |
| + { |
| + print "\n Licence_FIXED: <"; |
| + print File::Spec->abs2rel($file_name, $top).">\n";; |
| + open(my $f_out, '>', $file_name) |
| + or die "Can't Open $file_name\n"; |
| + print $f_out $text_all; |
| + close $f_out; |
| + } |
| + } |
| + $text_all=''; |
| +} |
| + |
| + |
| +my ($c_cnt, $h_cnt) = (0, 0); |
| +sub process |
| +{ |
| + my $file = $File::Find::name; |
| + if (-f $file) |
| + { |
| + if(($file =~ /.*\.[Cc]$/i) || ($file =~ /.*\.dtsi$/i) || ($file =~ /.*\.dts$/i)) |
| + { |
| + $c_cnt++; |
| + $licence_start="// SPDX-License-Identifier: (GPL-2.0+ OR MIT)\n"; |
| + licence_process($file); |
| + } |
| + if(($file =~ /.*\.[hH]$/i)) |
| + { |
| + $c_cnt++; |
| + $licence_start="/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */\n"; |
| + licence_process($file); |
| + } |
| + } |
| +} |
| + |
| +for(@path) |
| +{ |
| + #print "\n Fine $_ \n"; |
| + find(\&process, $_); |
| +} |
| diff --git a/scripts/amlogic/licence_pre.pl b/scripts/amlogic/licence_pre.pl |
| new file mode 100755 |
| index 000000000000..a364fbe60a84 |
| --- /dev/null |
| +++ b/scripts/amlogic/licence_pre.pl |
| @@ -0,0 +1,53 @@ |
| +#!/usr/bin/perl -W |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| +my $FILE; |
| +$flist = " "; |
| +open($FILE, '<&STDIN'); |
| +while (<$FILE>) { |
| + chomp; |
| + my $line = $_; |
| + my $new = ""; |
| + if($line =~/^A\s+(.+\.[cChH])/) |
| + { |
| + $new = $1; |
| + } |
| + elsif(/^A\s+(.+\.dts*)/i) |
| + { |
| + $new = $1; |
| + } |
| + if( -e $new) |
| + { |
| + $flist = $flist.$new." "; |
| + } |
| + |
| +} |
| +close $FILE; |
| + |
| +if($flist =~/^\s*$/) |
| +{ |
| + #print "\n LicenceCheck exit:No *.[CcHh] added.\n\n"; |
| + exit 0; |
| +} |
| +else |
| +{ |
| + print "\n Check :$flist\n"; |
| +} |
| + |
| +$match = "Licence_WARN: <"; |
| +$pl = "./scripts/amlogic/licence_check.pl"; |
| +$out = 0; |
| +$result_0 = `$pl --nofix $flist`; |
| +if($result_0 =~/$match/) |
| +{ |
| + $out =1; |
| + print $result_0; |
| + print "\n Licence Check Error, please try to fix:\n $pl $flist\n\n" |
| +} |
| +else |
| +{ |
| + print "\n Licence Check OK\n\n" |
| +} |
| +exit $out; |
| diff --git a/scripts/amlogic/merge_pre_check.pl b/scripts/amlogic/merge_pre_check.pl |
| new file mode 100755 |
| index 000000000000..b2c9a1df0f17 |
| --- /dev/null |
| +++ b/scripts/amlogic/merge_pre_check.pl |
| @@ -0,0 +1,429 @@ |
| +#!/usr/bin/perl -W |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| +my $top = "."; |
| +my $err_cnt = 0; |
| +my $k_v = 4; |
| +my $exit = 0; |
| +my $git_format_link="http://wiki-china.amlogic.com/Platform/Bootloader/Bootloader_commit_message_format"; |
| +my $config1 = "arch/arm64/configs/meson64_a64_smarthome_defconfig"; |
| +my $skip = 0; |
| +my $make_build_link = "https://confluence.amlogic.com/display/SW/5.+c2+bringup"; |
| +my $make_defconfig_link = "https://confluence.amlogic.com/display/SW/1.+Quick+Start"; |
| +my $env_common = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"; |
| +my $arm64_dts = "arch/arm64/boot/dts/amlogic/"; |
| +my $arm_dts = "arch/arm/boot/dts/amlogic/"; |
| + |
| +#Check mesonxx_defconfig |
| +sub check_defconfig |
| +{ |
| + my $arm64_config = `git diff --name-only arch/arm64/configs | grep -E *defconfig`; |
| + my $is_common_drivers = `pwd | grep -E *common_drivers*`; |
| + if (!$arm64_config || !$is_common_drivers) |
| + { |
| + return 0; |
| + } |
| + my $err = 0; |
| + #print "2. Check meson_defconfig: "; |
| + if( -e $config1) |
| + { |
| + `cd .. && mkdir -p out/kernel-5.15/common`; |
| + `cd .. && export CROSS_COMPILE=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-`; |
| + `cd .. && cp -rf common_drivers/arch/arm64/configs/meson64_a64_smarthome_defconfig common/arch/arm64/configs/`; |
| + `cd .. && make ARCH=arm64 -C ${PWD}/common/ O=${PWD}/out/kernel-5.15/common/ meson64_a64_smarthome_defconfig`; |
| + `cd .. && make ARCH=arm64 -C ${PWD}/common/ O=${PWD}/out/kernel-5.15/common/ savedefconfig`; |
| + `cd .. && rm -rf ../common/arch/arm64/configs/meson64_a64_smarthome_defconfig`; |
| + `cd .. && rm -rf ../out/kernel-5.15/common/.config`; |
| + my $diff = `diff ../out/kernel-5.15/common/defconfig arch/arm64/configs/meson64_a64_smarthome_defconfig`; |
| + if(length($diff)) |
| + { |
| + $err_cnt += 1; |
| + $err = 1; |
| + $err_msg .= " $err_cnt: meson64_a64_smarthome_defconfig not generated by savedefconfig\n"; |
| + } |
| + } |
| + |
| + |
| + if($err) |
| + { |
| + $err_msg .= " Please refer to:\n"; |
| + $err_msg .= " $make_defconfig_link \n"; |
| + $err_msg .= " $make_build_link\n"; |
| + } |
| + #print $err ? "fail\n" : "success\n"; |
| +} |
| + |
| +sub dts_check |
| +{ |
| + my $is_common_drivers = `pwd | grep -E *common_drivers*`; |
| + if (!$is_common_drivers) |
| + { |
| + return 0; |
| + } |
| + my @dts_path = @_; |
| + my $dts_diff = ""; |
| + my $diff = `git diff --name-only @dts_path | grep -E *dts\$`; |
| + if (!$diff) |
| + { |
| + return 0; |
| + } |
| + my $all_dts = `find @dts_path -name "*dts"`; |
| + my @diff_str = split /[\n]/, $diff; |
| + my @all_dts_str = split /[\n]/, $all_dts; |
| + my $diff_count = 0; |
| + my $all_dts_count = 0; |
| + my $count = 0; |
| + my $t = 0; |
| + my $q = 0; |
| + my $temp = ""; |
| + my @arry = (""); |
| + my @arry1 = (""); |
| + my @arry2 = (""); |
| + for (@diff_str) |
| + { |
| + $re = $_; |
| + if ($re=~m/^(.*?)\_/) |
| + { |
| + $dts_diff = $1; |
| + $dts_diff =~ /@dts_path/; |
| + $temp=$'; |
| + $dts_diff = $dts_diff."_"; |
| + } |
| + if (!($_ =~ "pxp.dts")) |
| + { |
| + for (@diff_str) |
| + { |
| + if ($_ =~ $dts_diff) |
| + { |
| + $_ =~ /@dts_path/; |
| + $arry1->[$diff_count] = $'; |
| + $diff_count = $diff_count+1; |
| + } |
| + } |
| + for (@all_dts_str) |
| + { |
| + if (!($_ =~ "pxp.dts")) |
| + { |
| + if ($_ =~ $dts_diff) |
| + { |
| + $all_dts_count=$all_dts_count+1; |
| + $_ =~ /@dts_path/; |
| + $arry->[$all_dts_count] = $'; |
| + } |
| + } |
| + } |
| + } |
| + if ($diff_count != $all_dts_count) |
| + { |
| + $count=$count+1; |
| + } |
| + while ($q<$t) |
| + { |
| + if ($arry2->[$q] =~ $temp ) |
| + { |
| + $count=0; |
| + } |
| + $q=$q+1; |
| + } |
| + if ($count != 0) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt:You are modifying the board $temp DTS file in @dts_path \n"; |
| + $err_msg .= " You have modified dts is "; |
| + while($diff_count > 0) |
| + { |
| + $err_msg .= "$arry1->[$diff_count-1] "; |
| + $diff_count=$diff_count-1; |
| + } |
| + $err_msg .= "\n"; |
| + $err_msg .= " Please confirm should you modify other boards for $temp in @dts_path too? "; |
| + |
| + $err_msg .= "\n"; |
| + $count = 0; |
| + $diff_count = 0; |
| + $all_dts_count = 0; |
| + $arry2->[$t]=$temp; |
| + $t=$t+1; |
| + $q=0; |
| + } |
| + } |
| +} |
| + |
| +sub check_dtsi |
| +{ |
| + my $file = `git diff --name-only | grep -E *dtsi\$`; |
| + my $arm_dts_num = () = ($file =~ /arch\/arm\/boot\/dts\/amlogic/g); |
| + my $arm64_dts_num = () = ($file =~ /arch\/arm64\/boot\/dts\/amlogic/g); |
| + |
| + if( $arm_dts_num != $arm64_dts_num ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: maybe should modify dtsi in both arm and arm64\n"; |
| + } |
| +} |
| + |
| +# check module_param number |
| +sub check_module_param |
| +{ |
| + my $num = `git format-patch -1 --stdout | grep -c "module_param("`; |
| + my $MAX_NUM = 5; |
| + |
| + if( $num > $MAX_NUM ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: the number of module_param too much\n"; |
| + } |
| +} |
| + |
| +my $MAX_LEN = 100; |
| + |
| +sub check_msg_common |
| +{ |
| + my $line = pop(@_); |
| + my $lnum = pop(@_); |
| + |
| + if( (length($line) > ($MAX_LEN + 4) ) && ($lnum > 4) ) |
| + { #Line over 100 characters is not allowed. |
| + $line =~ s/^(\s){4}//; |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: Line over $MAX_LEN characters: <$line>\n"; |
| + } |
| + |
| + if ( ($line =~ /\s+$/) && $line !~/^(\s){4}$/ ) |
| + { #No space at the end of line |
| + $err_cnt += 1; |
| + $line =~ s/^(\s){4}//; |
| + $err_msg .= " $err_cnt: No space at the end of line: <$line>\n"; |
| + } |
| +} |
| + |
| + |
| +sub check_msg_49_2 |
| +{ |
| + my $msg = `git cat-file commit HEAD~0 | sed '1,/\^\$/d'`; |
| + my @str = split /[\n][\n]/, $msg; |
| + my $i = 0; |
| + my $len = @str; |
| + |
| + if( $msg =~ /^Revert\s/ ) |
| + { |
| + return 0; |
| + } |
| + |
| + if( $len != 6 ) |
| + { |
| + $err_cnt += 5; |
| + $err_msg .= " module: message [n/m]\n\n"; |
| + $err_msg .= " PD#SWPL-XXXX\n\n"; |
| + $err_msg .= " Problem:\n detailed description\n\n"; |
| + $err_msg .= " Solution:\n detailed description\n\n"; |
| + $err_msg .= " Verify:\n detailed description\n\n"; |
| + return -1; |
| + } |
| + |
| + if( $msg !~ /Merge\s/ && $msg =~ /5\.15/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: this branch is 5.15, all changes here are for 5.15. No「5.15」in commit message please\n"; |
| + } |
| + |
| + if( $str[$i] !~ /^([\w-]+:\s){1,2}.+(\s)\[[\d]+\/[\d]+\]$/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: module: message [n/m]\n"; |
| + } |
| + elsif( $str[$i] =~ /(kernel)/i ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: Should be no 'kernel' in kernel commit message\n"; |
| + } |
| + |
| + if( $str[++ $i] !~ /^PD\#SWPL-.+(\d)$/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: PD#SWPL-XXXX\n"; |
| + return -1; |
| + |
| + } |
| + |
| + if( $str[++ $i] !~ /^Problem:[\n].+/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: Problem:\n detailed description\n"; |
| + return -1; |
| + } |
| + |
| + $i += 1; |
| + while( $str[$i] !~ /^Solution:[\n].+/ && $str[$i] !~ /^Change-Id:/ && $str[$i] !~ /^Verify:[\n].+/ && ($i + 1) < $len ) |
| + { |
| + $i = $i + 1; |
| + } |
| + |
| + if( $str[$i] !~ /^Solution:[\n].+/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: Solution:\n detailed description\n"; |
| + return -1; |
| + } |
| + |
| + if( $str[$i] =~ /^Change-Id:/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: Verify:\n detailed description\n"; |
| + return -1; |
| + } |
| + |
| + while( $str[$i] !~ /^Verify:[\n].+/ && $str[$i] !~ /^Change-Id:/ && ($i + 1) < $len ) |
| + { |
| + $i += 1; |
| + } |
| + |
| + if( $str[$i] !~ /^Verify:[\n].+/ ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: Verify:\n detailed description\n"; |
| + } |
| +} |
| + |
| +sub sync_arm64_arm_diff |
| +{ |
| + my $file = `git diff --name-only HEAD HEAD^`; |
| + my $arm_dts_num = () = ($file =~ /arch\/arm\/boot\/dts\/amlogic/g); |
| + my $arm64_dts_num = () = ($file =~ /arch\/arm64\/boot\/dts\/amlogic/g); |
| + my $arm_config_num = () = ($file =~ /arch\/arm\/config/g); |
| + my $arm64_config_num = () = ($file =~ /arch\/arm64\/config/g); |
| + |
| + if( $arm_config_num != $arm64_config_num ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: maybe should modify the config in both arm and arm64\n"; |
| + } |
| + if( $arm_dts_num != $arm64_dts_num ) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " $err_cnt: maybe should modify the dts in both arm and arm64\n"; |
| + } |
| +} |
| + |
| +sub check_nonascii_character |
| +{ |
| + my $add_msg = `git format-patch -1 --stdout | sed -e '/^-/d'`; |
| + my @add_str = split /[\n][\n]/,, $add_msg; |
| + my $i = 0; |
| + my $len = @add_str; |
| + for ($i = 0; $i < $len; $i = $i + 1) |
| + { |
| + if (!$add_str[$i] =~ m/[^\x00-\x7f]/) |
| + { |
| + $err_cnt += 1; |
| + $err_msg .= " @add_str[$i]\n"; |
| + } |
| + } |
| +} |
| + |
| + |
| +sub check_commit_msg |
| +{ |
| + |
| + my $lnum = 0; |
| + my $err = 0; |
| + my $result = 0; |
| + my $commit; |
| + my $FILE; |
| + |
| + open($FILE, '<&STDIN'); |
| + |
| + while (<$FILE>) { |
| + chomp; |
| + my $line = $_; |
| + |
| + |
| + if( $line =~ /^commit\s([0-9a-z])+$/) |
| + { |
| + $lnum = 0; |
| + $commit = $line; |
| + $skip = 0; |
| + } |
| + $lnum ++; |
| + |
| + |
| + if( ($lnum ==2) && ($line =~ /^Merge: /)) |
| + { |
| + #$skip =1; #Don't Check branch merge |
| + } |
| + if( ($lnum==2) && ($line !~ /^Author: .*\@amlogic\.com\>$/)) |
| + { |
| + #$skip =1; #Don't Check commit which is not from amlogic |
| + } |
| + |
| + if( $err == 1) |
| + { |
| + $skip = 1; |
| + $err = 0; |
| + $result = 1; |
| + } |
| + if( $skip ==1) |
| + { |
| + next; |
| + } |
| + |
| + check_msg_common($lnum, $line); |
| + } |
| + close $FILE; |
| + if ($k_v >= 4) |
| + { |
| + check_msg_49_2; |
| + } |
| +} |
| + |
| +sub out_review |
| +{ |
| + my $out_msg = ""; |
| + my $out_file = "../output/review.txt"; |
| + |
| + if ($err_cnt) |
| + { |
| + $out_msg = <<END; |
| + \$ total $err_cnt errors. |
| +${err_msg} |
| + |
| +END |
| + |
| + #open O, "> $out_file" or die "Can't Open $out_file For Write \n"; |
| + #print O $out_msg; |
| + #close O; |
| + $exit = 1; |
| + print $out_msg; |
| + print "Please refer to:\n $git_format_link\n"; |
| + } |
| + else |
| + { |
| + print ""; |
| + } |
| +} |
| + |
| +#start |
| + |
| +my $err_msg_p = "\nCommit Pre check failed. Total $err_cnt errors.\n"; |
| + |
| +#Check meson_defconfig |
| +check_defconfig(); |
| +dts_check($arm64_dts); |
| +#dts_check($arm_dts); |
| +#check_dtsi(); |
| + |
| +#check_module_param |
| +check_module_param(); |
| + |
| +#Check commit message |
| +#check_commit_msg(); |
| + |
| +#check config and dts in arm and arm64 |
| +#sync_arm64_arm_diff(); |
| +check_nonascii_character(); |
| + |
| +out_review(); |
| +#out |
| +exit $exit; |
| diff --git a/scripts/amlogic/mk_c3_min.sh b/scripts/amlogic/mk_c3_min.sh |
| new file mode 100755 |
| index 000000000000..9578e7214cd1 |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_c3_min.sh |
| @@ -0,0 +1,30 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| +ARCH=arm |
| +CROSS_COMPILE_TOOL=${ROOT_DIR}/prebuilts/gcc/linux-x86/host/x86_64-arm-10.3-2021.07/bin/arm-none-linux-gnueabihf- |
| + |
| +OPTION_PARAM="$*" |
| +if [[ "${OPTION_PARAM}" =~ "--c3_debug" ]]; then |
| + echo "make meson64_a32_C3_mini_defconfig & C3_debug_defconfig" |
| + DEBUG=1 |
| + OPTION_PARAM=${OPTION_PARAM//--c3_debug/} |
| + DEFCONFIG=meson64_a32_C3_mini_merge_defconfig |
| + CONFIG_DIR=${ROOT_DIR}/common/common_drivers/arch/${ARCH}/configs |
| + KCONFIG_CONFIG=${CONFIG_DIR}/${DEFCONFIG} ${ROOT_DIR}/common/scripts/kconfig/merge_config.sh -m -r \ |
| + ${CONFIG_DIR}/meson64_a32_C3_mini_defconfig \ |
| + ${CONFIG_DIR}/C3_debug_defconfig |
| +else |
| + echo "make meson64_a32_C3_mini_defconfig" |
| + DEFCONFIG=meson64_a32_C3_mini_defconfig |
| +fi |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh ${OPTION_PARAM} |
| + |
| +if [[ "${DEBUG}" == "1" ]]; then |
| + rm -f ${CONFIG_DIR}/${DEFCONFIG}* |
| +fi |
| diff --git a/scripts/amlogic/mk_gx32.sh b/scripts/amlogic/mk_gx32.sh |
| new file mode 100755 |
| index 000000000000..001ce871ea11 |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_gx32.sh |
| @@ -0,0 +1,23 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=arm |
| +DEFCONFIG=amlogic_gx32_defconfig |
| + |
| +KCONFIG_CONFIG=${ROOT_DIR}/common/common_drivers/arch/${ARCH}/configs/${DEFCONFIG} |
| +export KCONFIG_CONFIG |
| + |
| +${ROOT_DIR}/common/scripts/kconfig/merge_config.sh -m -r \ |
| + ${ROOT_DIR}/common/common_drivers/arch/${ARCH}/configs/a32_base_defconfig \ |
| + ${ROOT_DIR}/common/common_drivers/arch/${ARCH}/configs/amlogic_a32.fragment \ |
| + ${ROOT_DIR}/common/common_drivers/arch/${ARCH}/configs/amlogic_gcc32_defconfig\ |
| + |
| +export -n KCONFIG_CONFIG |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| +rm ${KCONFIG_CONFIG}* |
| diff --git a/scripts/amlogic/mk_gx64.sh b/scripts/amlogic/mk_gx64.sh |
| new file mode 100755 |
| index 000000000000..a80d430792e1 |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_gx64.sh |
| @@ -0,0 +1,27 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=arm64 |
| + |
| +DEFCONFIG=amlogic_gx64_defconfig |
| + |
| +KCONFIG_CONFIG=${ROOT_DIR}/common/common_drivers/arch/arm64/configs/${DEFCONFIG} |
| +export KCONFIG_CONFIG |
| + |
| +${ROOT_DIR}/common/scripts/kconfig/merge_config.sh -m -r \ |
| + ${ROOT_DIR}/common/arch/arm64/configs/gki_defconfig \ |
| + ${ROOT_DIR}/common/common_drivers/arch/arm64/configs/amlogic_gki.fragment \ |
| + ${ROOT_DIR}/common/common_drivers/arch/arm64/configs/amlogic_gki.10 \ |
| + ${ROOT_DIR}/common/common_drivers/arch/arm64/configs/amlogic_gki.debug \ |
| + ${ROOT_DIR}/common/common_drivers/arch/arm64/configs/amlogic_gcc64_deconfig |
| + |
| +export -n KCONFIG_CONFIG |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| + |
| +rm ${KCONFIG_CONFIG}* |
| diff --git a/scripts/amlogic/mk_riscv.sh b/scripts/amlogic/mk_riscv.sh |
| new file mode 100755 |
| index 000000000000..2cb94fb4d04e |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_riscv.sh |
| @@ -0,0 +1,13 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=riscv |
| +DEFCONFIG=meson64_smarthome_defconfig |
| +CROSS_COMPILE_TOOL=${ROOT_DIR}/prebuilts/gcc/linux-x86/host/nuclei_riscv_glibc_prebuilt_linux64_2022.04/bin/riscv-nuclei-linux-gnu- |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| diff --git a/scripts/amlogic/mk_smarthome32.sh b/scripts/amlogic/mk_smarthome32.sh |
| new file mode 100755 |
| index 000000000000..0cd4347dafc9 |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_smarthome32.sh |
| @@ -0,0 +1,12 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=arm |
| +DEFCONFIG=meson64_a32_smarthome_defconfig |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| diff --git a/scripts/amlogic/mk_smarthome32_clang.sh b/scripts/amlogic/mk_smarthome32_clang.sh |
| new file mode 100755 |
| index 000000000000..0153f2f7e49f |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_smarthome32_clang.sh |
| @@ -0,0 +1,13 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=arm |
| +DEFCONFIG=meson64_a32_smarthome_defconfig |
| +CC_CLANG=1 |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| diff --git a/scripts/amlogic/mk_smarthome64.sh b/scripts/amlogic/mk_smarthome64.sh |
| new file mode 100755 |
| index 000000000000..c126c85f8eaa |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_smarthome64.sh |
| @@ -0,0 +1,12 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=arm64 |
| +DEFCONFIG=meson64_a64_smarthome_defconfig |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| diff --git a/scripts/amlogic/mk_smarthome64_clang.sh b/scripts/amlogic/mk_smarthome64_clang.sh |
| new file mode 100755 |
| index 000000000000..6aa7da103dfd |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_smarthome64_clang.sh |
| @@ -0,0 +1,13 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| + |
| +ARCH=arm64 |
| +DEFCONFIG=meson64_a64_smarthome_defconfig |
| +CC_CLANG=1 |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh $@ |
| diff --git a/scripts/amlogic/mk_smarthome_common.sh b/scripts/amlogic/mk_smarthome_common.sh |
| new file mode 100755 |
| index 000000000000..82da4e459b4e |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_smarthome_common.sh |
| @@ -0,0 +1,95 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +function show_help { |
| + echo "USAGE: $0 [--nongki] [--abi]" |
| + echo " --kernel_dir for KERNEL_DIR, common[default]|other dir, require parameter value" |
| + echo " --common_drivers_dir for COMMON_DRIVERS_DIR, common[default]|other dir, require parameter value" |
| + echo " --savedefconfig for SAVEDEFCONFIG, [default]|1, not require parameter value" |
| + echo " --menuconfig for MENUCONFIG, [default]|1, not require parameter value" |
| + echo " --manual_insmod_module for insmod ko manually when kernel is booting.It's usually used in debug test" |
| + echo " --patch for only am patches" |
| +} |
| + |
| +VA= |
| +ARGS=() |
| +for i in "$@" |
| +do |
| + case $i in |
| + --kernel_dir) |
| + KERNEL_DIR=$2 |
| + VA=1 |
| + shift |
| + ;; |
| + --common_drivers_dir) |
| + COMMON_DRIVERS_DIR=$2 |
| + VA=1 |
| + shift |
| + ;; |
| + *) |
| + if [[ -n $1 ]]; |
| + then |
| + if [[ -z ${VA} ]]; |
| + then |
| + ARGS+=("$1") |
| + fi |
| + fi |
| + VA= |
| + shift |
| + ;; |
| + esac |
| +done |
| +set -- "${ARGS[@]}" # other parameters are used as script parameters of build_abi.sh or build.sh |
| + |
| +if [[ -z "${KERNEL_DIR}" ]]; then |
| + KERNEL_DIR=common |
| +fi |
| +if [[ ! -f ${KERNEL_DIR}/init/main.c ]]; then |
| + echo "The directory of kernel does not exist"; |
| + exit |
| +fi |
| +if [[ -z "${COMMON_DRIVERS_DIR}" ]]; then |
| + if [[ -d ${KERNEL_DIR}/../common_drivers ]]; then |
| + COMMON_DRIVERS_DIR=../common_drivers |
| + elif [[ -d "${KERNEL_DIR}/common_drivers" ]]; then |
| + COMMON_DRIVERS_DIR=common_drivers |
| + fi |
| +fi |
| +if [[ ! -f ${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/amlogic_utils.sh ]]; then |
| + echo "The directory of common_drivers does not exist"; |
| + exit |
| +fi |
| + |
| +source ${ROOT_DIR}/${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/amlogic_utils.sh |
| +source ${ROOT_DIR}/${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/scripts/amlogic/amlogic_smarthome_utils.sh |
| + |
| +copy_pre_commit |
| + |
| +handle_input_parameters_for_smarthome "$@" |
| + |
| +export KERNEL_DIR COMMON_DRIVERS_DIR MANUAL_INSMOD_MODULE |
| + |
| +set_default_parameters_for_smarthome |
| + |
| +auto_patch_to_common_dir |
| + |
| +mkdir -p ${DIST_DIR} ${MODULES_STAGING_DIR} |
| + |
| +savedefconfig_cmd_for_smarthome |
| + |
| +only_build_dtb_for_smarthome |
| + |
| +make_menuconfig_cmd_for_smarthome |
| + |
| +build_kernel_for_different_cpu_architecture |
| + |
| +prepare_module_build |
| +build_ext_modules |
| +extra_cmds |
| + |
| +copy_modules_and_rebuild_rootfs_for_smarthome |
| + |
| + |
| diff --git a/scripts/amlogic/mk_zapper32.sh b/scripts/amlogic/mk_zapper32.sh |
| new file mode 100755 |
| index 000000000000..aab24806ed35 |
| --- /dev/null |
| +++ b/scripts/amlogic/mk_zapper32.sh |
| @@ -0,0 +1,30 @@ |
| +#!/bin/bash |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| +# |
| + |
| +ROOT_DIR=`pwd` |
| +ARCH=arm |
| +CROSS_COMPILE_TOOL=${ROOT_DIR}/prebuilts/gcc/linux-x86/host/x86_64-arm-10.3-2021.07/bin/arm-none-linux-gnueabihf- |
| + |
| +OPTION_PARAM="$*" |
| +if [[ "${OPTION_PARAM}" =~ "--all" ]]; then |
| + echo "make meson64_a32_zapper_defconfig and meson64_a32_zapper_ext_defconfig" |
| + DEBUG=1 |
| + OPTION_PARAM=${OPTION_PARAM//--all/} |
| + DEFCONFIG=meson64_a32_zapper_all_defconfig |
| + CONFIG_DIR=${ROOT_DIR}/common/common_drivers/arch/${ARCH}/configs |
| + KCONFIG_CONFIG=${CONFIG_DIR}/${DEFCONFIG} ${ROOT_DIR}/common/scripts/kconfig/merge_config.sh -m -r \ |
| + ${CONFIG_DIR}/meson64_a32_zapper_defconfig \ |
| + ${CONFIG_DIR}/meson64_a32_zapper_ext_defconfig |
| +else |
| + echo "make meson64_a32_zapper_defconfig" |
| + DEFCONFIG=meson64_a32_zapper_defconfig |
| +fi |
| + |
| +source ${ROOT_DIR}/common/common_drivers/scripts/amlogic/mk_smarthome_common.sh ${OPTION_PARAM} |
| + |
| +if [[ "${DEBUG}" == "1" ]]; then |
| + rm ${CONFIG_DIR}/${DEFCONFIG} |
| +fi |
| diff --git a/scripts/amlogic/modules_sequence_list b/scripts/amlogic/modules_sequence_list |
| new file mode 100644 |
| index 000000000000..463ce3f2e30e |
| --- /dev/null |
| +++ b/scripts/amlogic/modules_sequence_list |
| @@ -0,0 +1,84 @@ |
| +RAMDISK_MODULES_LOAD_LIST=( |
| + amlogic-debug-iotrace |
| + amlogic-uart |
| + amlogic-hwspinlock |
| + amlogic-gkitool |
| + amlogic-memory-debug |
| + amlogic-secmon |
| + amlogic-clk |
| + amlogic-aoclk |
| + amlogic-gpio |
| + amlogic-pinctrl |
| + amlogic-mailbox |
| + amlogic-pwm |
| + pwm-regulator |
| + amlogic-reset |
| + amlogic-power |
| + amlogic-cpuinfo |
| + amlogic-cpufreq |
| + amlogic-efuse-unifykey |
| + amlogic-mmc |
| + amlogic-i2c.ko |
| + amlogic-spi.ko |
| + amlogic-rng.ko |
| + tee.ko |
| + optee.ko |
| + amlogic-tee.ko |
| + videobuf-core.ko |
| + dvb-core.ko |
| + amlogic-pm.ko |
| + amlogic-input.ko |
| + amlogic-regulator.ko |
| + amlogic-watchdog.ko |
| + aml-dvb.ko |
| + aml_media.ko |
| + amlogic-camera.ko |
| + amlogic-adc.ko |
| + amlogic-rtc-virtual.ko |
| + amlogic-thermal.ko |
| + amlogic-usb.ko |
| + amlogic-irblaster.ko |
| + amlogic-inphy.ko |
| + aml_drm.ko |
| +) |
| + |
| +VENDOR_MODULES_LOAD_FIRST_LIST=( |
| + amlogic-crypto-dma |
| + amlogic-usb.ko |
| + amlogic-wireless.ko |
| + amlogic_pcie_v2_host.ko |
| + amlogic-pcie-v3_host.ko |
| +) |
| + |
| +VENDOR_MODULES_LOAD_LAST_LIST=( |
| +) |
| + |
| +RECOVERY_MODULES_LOAD_LIST=( |
| + i2c-dev.ko |
| + dwc_otg.ko |
| +) |
| + |
| +COMMON_GKI_MODULES_LIST=( |
| + zsmalloc.ko |
| + zram.ko |
| + libarc4.ko |
| + rfkill.ko |
| + mii.ko |
| + aqc111.ko |
| + asix.ko |
| + ax88179_178a.ko |
| + cdc_eem.ko |
| + cdc_ether.ko |
| + cdc_ncm.ko |
| + r8152.ko |
| + r8153_ecm.ko |
| + rtl8150.ko |
| + usbnet.ko |
| + ptp.ko |
| + pps_core.ko |
| +) |
| + |
| +GKI_MODULES_LOAD_WHITE_LIST=( |
| + ${COMMON_GKI_MODULES_LIST[@]} |
| + ${EXTRA_GKI_MODULES_LIST[@]} |
| +) |
| diff --git a/scripts/amlogic/pre-commit b/scripts/amlogic/pre-commit |
| new file mode 100755 |
| index 000000000000..fba48e4904e0 |
| --- /dev/null |
| +++ b/scripts/amlogic/pre-commit |
| @@ -0,0 +1,24 @@ |
| +#!/bin/sh |
| +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| +# |
| +# pre-commit hook to run check-patch on the output and stop any commits |
| +# that do not pass. Note, only for git-commit, and not for any of the |
| +# other scenarios |
| +# |
| +# Copyright 2010 Ben Dooks, <ben-linux@fluff.org> |
| + |
| +if git rev-parse --verify HEAD 2>/dev/null >/dev/null |
| +then |
| + against=HEAD |
| +else |
| + # Initial commit: diff against an empty tree object |
| + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
| +fi |
| + |
| +git diff --cached --stat -p $against -- | ./scripts/checkpatch.pl --ignore GERRIT_CHANGE_ID,COMMIT_MESSAGE --strict --no-signoff - |
| +if [ $? -ne 0 ] |
| +then |
| +exit 1; |
| +fi |
| + |
| +git diff --name-status --cached $against -- | ./scripts/amlogic/licence_pre.pl - |
| -- |
| 2.34.1 |
| |