您尚未登录。

#1 Re: 全志 SOC » 九鼎创展 A733 开发板使用记录 » 昨天 10:08:02

现在基本确定了,就是打包工具导致 boot0_*.fex 几个文件并没有更新成功


折腾半小时,修改 longan/build/pack 脚本,从正常的img提取出来的boot0_*.fex 复制到 longan/out/a733/demo_aiot/pack_out/ 目录,

然后强制 boot0_*.fex 不更新

longan/build/pack 修改前:

#!/bin/bash
#
# pack/pack
# (c) Copyright 2013
# Allwinner Technology Co., Ltd. <www.allwinnertech.com>
# James Deng <csjamesdeng@allwinnertech.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

############################ Notice #####################################
# a. Some config files priority is as follows:
#    - xxx_${platform}.{cfg|fex} > xxx.{cfg|fex}
#    - ${chip}/${board}/*.{cfg|fex} > ${chip}/default/*.{cfg|fex}
#    - ${chip}/default/*.cfg > ${LICHEE_COMMON_CONFIG_DIR}/imagecfg/*.cfg
#    - ${chip}/default/*.fex > ${LICHEE_COMMON_CONFIG_DIR}/partition/*.fex
#  e.g. sun8iw7p1/configs/perf/image_linux.cfg > sun8iw7p1/configs/default/image_linux.cfg
#       > ${LICHEE_COMMON_CONFIG_DIR}/imagecfg/image_linux.cfg > sun8iw7p1/configs/perf/image.cfg
#       > sun8iw7p1/configs/default/image.cfg > ${LICHEE_COMMON_CONFIG_DIR}/imagecfg/image.cfg
#
# b. Support Nor storages rule:
#    - Need to create sys_partition_nor.fex or sys_partition_nor_${platform}.fex
#    - Add "{filename = "full_img.fex",     maintype = "12345678", \
#      subtype = "FULLIMG_00000000",}" to image[_${platform}].cfg
#
# c. Switch uart port
#    - Need to add your chip configs into ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin
#    - Call pack with 'debug' parameters

#if you want to debug pack, set vlaue to 1. use pause func in the place where you want to stop
enable_pause=0

function get_char()
{
	SAVEDSTTY=`stty -g`
	stty -echo
	stty cbreak
	dd if=/dev/tty bs=1 count=1 2> /dev/null
	stty -raw
	stty echo
	stty $SAVEDSTTY
}

function pause()
{
	if [ "x$1" != "x" ] ;then
		echo "$1"
	fi
	if [ $enable_pause -eq 1 ] ; then
		echo "Press any key to continue!"
		char=`get_char`
	fi
}

function pack_error()
{
	echo -e "\033[47;31mERROR: $*\033[0m"
}

function pack_warn()
{
	echo -e "\033[47;34mWARN: $*\033[0m"
}

function pack_info()
{
	echo -e "\033[47;30mINFO: $*\033[0m"
}

localpath=$(cd $(dirname $0) && pwd)
. $localpath/shflags

# define option, format:
#   'long option' 'default value' 'help message' 'short option'
DEFINE_string 'chip' '' 'chip to build, e.g. sun7i' 'c'
DEFINE_string 'ic' '' 'ic to build, e.g. a50' 'i'
DEFINE_string 'addition' '' 'additional config files, e.g. xx.fex' 'a'
DEFINE_string 'platform' '' 'platform to build, e.g. linux, android' 'p'
DEFINE_string 'platform_version' '' 'platform version to build' 'V'
DEFINE_string 'board' '' 'board to build, e.g. evb' 'b'
DEFINE_string 'kernel' '' 'kernel to build, e.g. linux-3.4, linux-3.10' 'k'
DEFINE_string 'debug_mode' 'uart0' 'config debug mode, e.g. uart0, card0' 'd'
DEFINE_string 'signture' 'none' 'pack boot signture to do secure boot' 's'
DEFINE_string 'secure' 'none' 'pack secure boot with -v arg' 'v'
DEFINE_string 'mode' 'normal' 'pack dump firmware' 'm'
DEFINE_string 'function' 'android' 'pack private firmware' 'f'
DEFINE_string 'vsp' '' 'pack firmware for vsp' 't'
DEFINE_string 'programmer' '' 'creat programmer img or not' 'w'
DEFINE_string 'key_path' '' 'the path of keys' 'P'
DEFINE_string 'nor' 'none' 'pack nor image' 'n'
DEFINE_boolean 'verity' false 'if enable dm-verity' ''
DEFINE_boolean 'signfel' false 'if enable fel signing' ''
DEFINE_string 'boot_path' '' 'the path of gki boot.img' 'B'
DEFINE_string 'output_resources' '' 'only output resources to pack-out' ''
DEFINE_string 'from_resources' '' 'pack from resources path' ''

# parse the command-line
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"

PACK_CHIP=${FLAGS_chip}
PACK_IC=${FLAGS_ic}
PACK_PLATFORM=${FLAGS_platform}
PACK_PLATFORM_VERSION=${FLAGS_platform_version}
PACK_BOARD=${FLAGS_board}
PACK_KERN=${FLAGS_kernel}
PACK_DEBUG=${FLAGS_debug_mode}
PACK_SIG=${FLAGS_signture}
PACK_SECURE=${FLAGS_secure}
PACK_MODE=${FLAGS_mode}
PACK_FUNC=${FLAGS_function}
PACK_VSP=${FLAGS_vsp}
PACK_PROGRAMMER=${FLAGS_programmer}
PACK_NOR=${FLAGS_nor}
PACK_PRODUCT=${FLAGS_product}
PACK_VERITY=${FLAGS_verity}
PACK_SIGNFEL=${FLAGS_signfel}
PACK_ADD_FILES=(${FLAGS_addition})
PACK_KEY_PATH=${FLAGS_key_path}
PACK_BOOT_PATH=${FLAGS_boot_path}

CFG_TOP_DIR=$(cd $localpath/../ && pwd)
CFG_PLAT_OUT=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM
CFG_KEY_DIR=$CFG_TOP_DIR/out/$PACK_IC/common/keys

if [ ! -z "${PACK_KEY_PATH}" ]; then
    CFG_KEY_DIR=${PACK_KEY_PATH}
fi
pack_info "${CFG_KEY_DIR}"

if [ ! -d ${CFG_PLAT_OUT} ] || \
   [ ! -f $CFG_PLAT_OUT/.buildconfig ]; then
	pack_error "config & build lichee before you pack"
	exit 1
fi

source $CFG_PLAT_OUT/.buildconfig

if [ -z "${PACK_KERN}" ]; then
	pack_info "No kernel param, parse it from .buildconfig"
	PACK_KERN=$LICHEE_KERN_VER
	if [ -z "${PACK_KERN}" ]; then
		pack_error "Failed to parse kernel param from .buildconfig"
		exit 1
	fi
fi

PACK_TYPE=""
case "x${PACK_PLATFORM}" in
	"xandroid")
		PACK_TYPE="android"
		;;
	"xdragonboard")
		PACK_TYPE="dragonboard"
		;;
	"xdragonabts")
		PACK_TYPE="dragonabts"
		;;
	"xbsp"|"xsata"|"xbuildroot"|"xopenwrt"|"xdebian")
		PACK_TYPE="linux"
		;;
	*)
		pack_error "Unsupport PACK_PLATFORM: ${PACK_PLATFORM}"
		exit 1
		;;
esac

export PATH=${LICHEE_TOOLS_DIR}/pack/pctools/linux/mod_update:${LICHEE_TOOLS_DIR}/pack/pctools/linux/openssl:${LICHEE_TOOLS_DIR}/pack/pctools/linux/eDragonEx:${LICHEE_TOOLS_DIR}/pack/pctools/linux/fsbuild200:${LICHEE_TOOLS_DIR}/pack/pctools/linux/android:$PATH
export LD_LIBRARY_PATH=${LICHEE_TOOLS_DIR}/pack/pctools/linux/softhsm/lib/:$LD_LIBRARY_PATH

tools_file_list=(
${LICHEE_COMMON_CONFIG_DIR}/tools/split_xxxx.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/split_xxxx.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool_test.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool_crash.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/usbtool_test.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript_secure.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/cardscript.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/cardscript_secure.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/cardtool.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/cardtool.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/usbtool.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool_crash.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/usbtool_crash.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/aultls32.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/aultls32.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/aultools.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/aultools.fex
)

configs_file_list=(
${LICHEE_COMMON_CONFIG_DIR}/toc/toc1.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_sdcard.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_nand.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_ufs.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_ft.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/boot_package.fex
${LICHEE_COMMON_CONFIG_DIR}/hdcp/esm.fex
${LICHEE_COMMON_CONFIG_DIR}/dtb/sunxi.fex
${LICHEE_COMMON_CONFIG_DIR}/imagecfg/*.cfg
${LICHEE_COMMON_CONFIG_DIR}/partition/sys_partition_dump.fex
${LICHEE_COMMON_CONFIG_DIR}/partition/sys_partition_private.fex
${LICHEE_COMMON_CONFIG_DIR}/version/version_base.mk
${LICHEE_CHIP_CONFIG_DIR}/configs/default/*
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/*.fex
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/boot_package*.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${LICHEE_KERN_VER}/*.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/version_base.mk
${LICHEE_CHIP_CONFIG_DIR}/dtbo/*
${LICHEE_BOARD_CONFIG_DIR}/dtbo/*
${LICHEE_CHIP_CONFIG_DIR}/${BIN_PATH}/ft_${PACK_CHIP}.bin
${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_ft.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc_ft.cfg
${LICHEE_COMMON_CONFIG_DIR}/sign_config/cnf_base.cnf
${LICHEE_PLAT_OUT}/.buildconfig
)

product_configs_file_list=(
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${PACK_PLATFORM}/*.fex
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${PACK_PLATFORM}/*.cfg
)

boot_resource_list=(
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource:${LICHEE_PACK_OUT_DIR}
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource.ini:${LICHEE_PACK_OUT_DIR}
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/*.bmp:${LICHEE_PACK_OUT_DIR}/boot-resource/
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/bootlogo.bmp:${LICHEE_PACK_OUT_DIR}/bootlogo.bmp
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/wavefile/*:${LICHEE_PACK_OUT_DIR}/boot-resource/wavefile/
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${PACK_TYPE}/*.bmp:${LICHEE_PACK_OUT_DIR}/boot-resource/
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource/bat/bempty.bmp:${LICHEE_PACK_OUT_DIR}/bempty.bmp
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource/bat/battery_charge.bmp:${LICHEE_PACK_OUT_DIR}/battery_charge.bmp
)

boot_file_list=(
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_nand.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_ufs.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_${LICHEE_BOOT0_BIN_NAME}_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_nandfastboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_nandfastboot_${PACK_CHIP}.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_spinor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_spinor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/fes1_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/fes1_uart_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1_uart.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-${LICHEE_EFEX_BIN_NAME}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-${LICHEE_EFEX_BIN_NAME}.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-crashdump-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-crash.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-crashdump-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-crash.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/bl31.bin:${LICHEE_PACK_OUT_DIR}/monitor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/bl31_${PACK_BOARD}.bin:${LICHEE_PACK_OUT_DIR}/monitor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/scp.bin:${LICHEE_PACK_OUT_DIR}/scp.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_dsp0.bin:${LICHEE_PACK_OUT_DIR}/amp_dsp0.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_dsp1.bin:${LICHEE_PACK_OUT_DIR}/amp_dsp1.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_arm64.bin:${LICHEE_PACK_OUT_DIR}/amp_arm64.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_rv0.bin:${LICHEE_PACK_OUT_DIR}/amp_rv0.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/video.bin:${LICHEE_PACK_OUT_DIR}/video.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/optee.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}-monitor.bin:${LICHEE_PACK_OUT_DIR}/optee-monitor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/opensbi_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/opensbi.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-spinor-secure-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-secure.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/*.fex:${LICHEE_PACK_OUT_DIR}/
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/*.dtb:${LICHEE_PACK_OUT_DIR}/
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/*.bin:${LICHEE_PACK_OUT_DIR}/
)

boot_file_list_2=(
${LICHEE_PLAT_OUT}/arisc:${LICHEE_PACK_OUT_DIR}/arisc.fex
${LICHEE_PLAT_OUT}/sunxi.dtb:${LICHEE_PACK_OUT_DIR}/sunxi.fex
${LICHEE_PLAT_OUT}/boot0_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_nand.fex
${LICHEE_PLAT_OUT}/boot0_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
${LICHEE_PLAT_OUT}/boot0_${LICHEE_BOOT0_BIN_NAME}_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex
${LICHEE_PLAT_OUT}/boot0_spinor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_spinor.fex
${LICHEE_PLAT_OUT}/fes1_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1.fex
${LICHEE_PLAT_OUT}/fes1_uart_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1_uart.fex
${LICHEE_PLAT_OUT}/sboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot.bin
${LICHEE_PLAT_OUT}/sboot_nor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nor.bin
${LICHEE_PLAT_OUT}/sboot_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_sdcard.bin
${LICHEE_PLAT_OUT}/sboot_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nand.bin
${LICHEE_PLAT_OUT}/sboot_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_ufs.bin
${LICHEE_PLAT_OUT}/u-boot-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot.fex
${LICHEE_PLAT_OUT}/u-boot-${LICHEE_EFEX_BIN_NAME}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-${LICHEE_EFEX_BIN_NAME}.fex
${LICHEE_PLAT_OUT}/u-boot-crashdump-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-crash.fex
${LICHEE_PLAT_OUT}/u-boot-crashdump-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-crash.fex
${LICHEE_PLAT_OUT}/scp.bin:${LICHEE_PACK_OUT_DIR}/scp.fex
${LICHEE_PLAT_OUT}/u-boot-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor.fex
${LICHEE_PLAT_OUT}/u-boot-spinor-secure-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-secure.fex
${LICHEE_PLAT_OUT}/vmlinux.tar.bz2:${LICHEE_PACK_OUT_DIR}/vmlinux.fex
)

arm_boot_file_secure=(
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/semelis_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/semelis.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/optee.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nor.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_sdcard.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nand.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_ufs.bin
${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
)

arm64_boot_file_secure=(
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/optee.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nor.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_sdcard.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nand.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_ufs.bin
${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_a64_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_rv0.bin:${LICHEE_PACK_OUT_DIR}/amp_rv0.fex
)

#
# This function can get the realpath between $SRC and $DST
#
function get_realpath()
{
	local src=$(cd $1; pwd);
	local dst=$(cd $2; pwd);
	local res="./";
	local tmp="$dst"

	while [ "${src##*$tmp}" == "${src}" ]; do
		tmp=${tmp%/*};
		res=$res"../"
	done
	res="$res${src#*$tmp/}"

	printf "%s" $res
}

function show_boards()
{
	printf "\nAll avaiable chips, platforms and boards:\n\n"
	printf "Chip            Board\n"
	for chipdir in $(find chips/ -mindepth 1 -maxdepth 1 -type d) ; do
		chip=`basename ${chipdir}`
		printf "${chip}\n"
		for boarddir in $(find chips/${chip}/configs/${platform} \
			-mindepth 1 -maxdepth 1 -type d) ; do
			board=`basename ${boarddir}`
			printf "                ${board}\n"
		done
	done
	printf "\nFor Usage:\n"
	printf "     $(basename $0) -h\n\n"
}

function uart_switch()
{
	rm -rf ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	touch ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	TX=`awk  '$0~"'$PACK_CHIP'"{print $2}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	RX=`awk  '$0~"'$PACK_CHIP'"{print $3}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	PORT=`awk  '$0~"'$PACK_CHIP'"{print $4}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	MS=`awk  '$0~"'$PACK_CHIP'"{print $5}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	CK=`awk  '$0~"'$PACK_CHIP'"{print $6}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	DO=`awk  '$0~"'$PACK_CHIP'"{print $7}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	DI=`awk  '$0~"'$PACK_CHIP'"{print $8}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`

	BOOT_UART_ST=`awk  '$0~"'$PACK_CHIP'"{print $2}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	BOOT_PORT_ST=`awk  '$0~"'$PACK_CHIP'"{print $3}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	BOOT_TX_ST=`awk  '$0~"'$PACK_CHIP'"{print $4}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	BOOT_RX_ST=`awk  '$0~"'$PACK_CHIP'"{print $5}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_ST=`awk  '$0~"'$PACK_CHIP'"{print $6}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_USED_ST=`awk  '$0~"'$PACK_CHIP'"{print $7}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_PORT_ST=`awk  '$0~"'$PACK_CHIP'"{print $8}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_TX_ST=`awk  '$0~"'$PACK_CHIP'"{print $9}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_RX_ST=`awk  '$0~"'$PACK_CHIP'"{print $10}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART1_ST=`awk  '$0~"'$PACK_CHIP'"{print $11}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	JTAG_ST=`awk  '$0~"'$PACK_CHIP'"{print $12}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	MS_ST=`awk  '$0~"'$PACK_CHIP'"{print $13}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	CK_ST=`awk  '$0~"'$PACK_CHIP'"{print $14}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	DO_ST=`awk  '$0~"'$PACK_CHIP'"{print $15}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	DI_ST=`awk  '$0~"'$PACK_CHIP'"{print $16}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	MMC0_ST=`awk  '$0~"'$PACK_CHIP'"{print $17}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	MMC0_USED_ST=`awk  '$0~"'$PACK_CHIP'"{print $18}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`

	if [ -z "$TX" ] || [ -z "$BOOT_UART_ST" ]; then
		pack_error "$FUNCNAME: $PACK_CHIP not configured in card_debug_pin/card_debug_string!"
		exit 1
	fi

	echo '$0!~";" && $0~"'$BOOT_TX_ST'"{if(C)$0="'$BOOT_TX_ST' = '$TX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$BOOT_RX_ST'"{if(C)$0="'$BOOT_RX_ST' = '$RX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$BOOT_PORT_ST'"{if(C)$0="'$BOOT_PORT_ST' = '$PORT'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	if [ "`grep "auto_print_used" "${LICHEE_PACK_OUT_DIR}/sys_config.fex" | grep "1"`" ]; then
		echo '$0!~";" && $0~"'$MMC0_USED_ST'"{if(A)$0="'$MMC0_USED_ST' = 1";A=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	else
	echo '$0!~";" && $0~"'$MMC0_USED_ST'"{if(A)$0="'$MMC0_USED_ST' = 0";A=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	fi
	echo '$0!~";" && $0~"\\['$MMC0_ST'\\]"{A=1}  \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$UART0_TX_ST'"{if(B)$0="'$UART0_TX_ST' = '$TX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$UART0_RX_ST'"{if(B)$0="'$UART0_RX_ST' = '$RX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$UART0_ST'\\]"{B=1} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$UART0_USED_ST'"{if(B)$0="'$UART0_USED_ST' = 1"}  \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '/^'$UART0_PORT_ST'/{next} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$UART1_ST'\\]"{B=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$BOOT_UART_ST'\\]"{C=1} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$JTAG_ST'\\]"{C=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$MS_ST'"{$0="'$MS_ST' = '$MS'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$CK_ST'"{$0="'$CK_ST' = '$CK'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$DO_ST'"{$0="'$DO_ST' = '$DO'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$DI_ST'"{$0="'$DI_ST' = '$DI'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '1' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0

	if [ "`grep "auto_print_used" "${LICHEE_PACK_OUT_DIR}/sys_config.fex" | grep "1"`" ]; then
		sed -i -e '/^uart0_rx/a\pinctrl-1=' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i -e '/^uart0_rx/a\pinctrl-0=' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	awk -f ${LICHEE_PACK_OUT_DIR}/awk_debug_card0 ${LICHEE_PACK_OUT_DIR}/sys_config.fex > ${LICHEE_PACK_OUT_DIR}/sys_config_debug.fex
	rm -f ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	mv ${LICHEE_PACK_OUT_DIR}/sys_config_debug.fex ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	echo "uart -> card0"
}

function add_lzma_header()
{
	lzma_file=$1
	original_file=$2
	file_size=$(printf "%.8x\n" `stat -c%s ${lzma_file}`)
	original_file_size=$(printf "%.8x\n" `stat -c%s ${original_file}`)

	bin_str=""

	file_size_len=${#file_size}

	#"LZMA"+size+origin_size
	bin_str="\x4c\x5a\x4d\x41\x${file_size:6:2}\x${file_size:4:2}\x${file_size:2:2}\x${file_size:0:2}"
	bin_str+="\x${original_file_size:6:2}\x${original_file_size:4:2}\x${original_file_size:2:2}\x${original_file_size:0:2}"


	printf "%b" ${bin_str} > tempbin

	cat ${lzma_file} >> tempbin

	mv tempbin "${lzma_file}.head"
}

function partition_size_handle()
{
	echo "handle partition_size"
	local filename=${LICHEE_PACK_OUT_DIR}/sys_partition.fex
	local size
	local number
	local dimension
	local blocks
	local line
	local m
	local index=0
	while read line; do
		let "index++"
		size=$(echo $line | awk -F= '/^[[:space:]]*size[[:space:]]*=/{print $2}' | sed 's|\s\+||g')
		if [ -n "$size" ]; then
			dimension=$(echo $size | sed 's|^[0-9,.]\+||g')
			[ -z "$dimension" ] && continue
			case $dimension in
				B|b)
					m=1
					;;
				K|k)
					m=1024
					;;
				M|m)
					m=1048576
					;;
				G|g)
					m=1073741824
					;;
				*)
					pack_error "ERROR Dimension($dimension)!"
					return 1
					;;
			esac
			number=$(echo $size | sed 's|[a-z,A-Z]*$||g')
			blocks=$(echo "$number * $m / 512" | bc | awk -F. '{print $1}')
			printf "sys_partition.fex: size %6s => %7d Blocks\n" "${number}${dimension}" "${blocks}"
			size="$(echo "$line" | sed "s|=.*$|= $blocks|g")"
			sed -i "${index}s|$line|$size|g" $filename
		fi
	done < $filename
	return 0
}

function do_prepare()
{
	local runinfo=($(lsof 2>/dev/null | awk '$9~"'$LICHEE_TOP_DIR/tools/build/buildserver'"{print $2}'))
	local possible_bin_path="${LICHEE_POSSIBLE_BIN_PATH}"

	if [ ${#runinfo[@]} -lt 2 ]; then
		pack_error "something is incorrect:please <./build.sh config>."
	fi

	if [ -z "${PACK_CHIP}" -o -z "${PACK_TYPE}" -o -z "${PACK_BOARD}" ] ; then
		pack_error "Invalid parameters Chip: ${PACK_CHIP}, \
			Platform: ${PACK_TYPE}, Board: ${PACK_BOARD}"
		show_boards
		exit 1
	fi

	if [ ! -d ${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD} ] ; then
		pack_error "Board's directory \
			\"${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}\" is not exist."
		show_boards
		exit 1
	fi

	# Cleanup
	if [ "x" != "x${LICHEE_PACK_OUT_DIR}" ]; then
		rm -rf ${LICHEE_PACK_OUT_DIR}
	fi
	mkdir -p ${LICHEE_PACK_OUT_DIR}

	(
		cd $LICHEE_OUT_DIR
		if [ "${LICHEE_PACK_OUT_DIR}" != "$LICHEE_OUT_DIR/pack_out" ]; then
			rm -rf pack_out
			ln -sf ${LICHEE_IC}/${LICHEE_BOARD}/pack_out pack_out
		fi
	)

	printf "copying tools file\n"
	for file in ${tools_file_list[@]} ; do
		cp -f $file ${LICHEE_PACK_OUT_DIR} 2> /dev/null
	done

	if [ "x${PACK_KERN}" = "xlinux-3.4" ]; then
		cp -f ${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript.fex ${LICHEE_PACK_OUT_DIR} 2> /dev/null
	fi

	printf "copying configs file\n"
	for file in ${configs_file_list[@]} ; do
		cp -f $file ${LICHEE_PACK_OUT_DIR} 2> /dev/null
	done

	printf "copying product configs file\n"
	for file in ${product_configs_file_list[@]}; do
		cp -f $file ${LICHEE_PACK_OUT_DIR} 2>/dev/null
	done

	if [ x"${PACK_PLATFORM}" != x"android" ]; then
		printf "linux copying boardt&linux_kernel_version configs file\n"
		local possible_env_path=(
			configs/default
			configs/${LICHEE_BOARD}
			configs/${LICHEE_BOARD}/${LICHEE_KERN_VER}
			configs/${LICHEE_BOARD}/${PACK_PLATFORM}
		)
		local possible_env_list=(
			env.cfg
			env-$(echo ${LICHEE_KERN_VER} | awk -F '-' '{print $2}').cfg
		)
		local copy_env_file=''

		for d in ${possible_env_path[@]}; do
			[ ! -d ${LICHEE_CHIP_CONFIG_DIR}/$d ] && continue
			for file in ${possible_env_list[@]} ; do
				if [ -e "${LICHEE_CHIP_CONFIG_DIR}/$d/$file" ]; then
					copy_env_file=${LICHEE_CHIP_CONFIG_DIR}/$d/$file
				fi
			done
		done
		echo "Use u-boot env file: ${copy_env_file}"
		if [[ ! -f ${copy_env_file} ]]
		then
			echo -e "\e[33mWarning: u-boot env file '${copy_env_file}' not exist! use file in default directory other than '${PACK_BOARD}' directory\e[0m"
		fi

		cp -f ${copy_env_file} ${LICHEE_PACK_OUT_DIR}/env.cfg 2>/dev/null

		cp -f ${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${LICHEE_KERN_VER}/sys_* ${LICHEE_PACK_OUT_DIR} 2>/dev/null
	fi

	# If platform config files exist, we will cover the default files
	# For example, mv pack_out/image_linux.cfg pack_out/image.cfg
	if [ ${PACK_PLATFORM} != "android" ]; then
		cp -f ${LICHEE_BOARD_CONFIG_DIR}/${PACK_PLATFORM}/* ${LICHEE_PACK_OUT_DIR} 2> /dev/null
		if [ ${PACK_PLATFORM} = "bsp" -o "x${PACK_PLATFORM}" = "xsata" ] ; then
			find ${LICHEE_PACK_OUT_DIR}/* -type f -a \( -name "*.fex" -o -name "*.cfg" \) -print | \
			sed "s#\(.*\)_linux\(\..*\)#mv -fv & \1\2#e"
		else
			find ${LICHEE_PACK_OUT_DIR}/* -type f -a \( -name "*.fex" -o -name "*.cfg" \) -print | \
			sed "s#\(.*\)_${PACK_PLATFORM}\(\..*\)#mv -fv & \1\2#e"
		fi
	else
		find ${LICHEE_PACK_OUT_DIR}/* -type f -a \( -name "*.fex" -o -name "*.cfg" \) -print | \
			sed "s#\(.*\)_${PACK_TYPE}\(\..*\)#mv -fv & \1\2#e"
	fi

	if [ "x${PACK_MODE}" = "xdump" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/sys_partition_dump.fex ${LICHEE_PACK_OUT_DIR}/sys_partition.fex
		cp -vf ${LICHEE_PACK_OUT_DIR}/usbtool_test.fex ${LICHEE_PACK_OUT_DIR}/usbtool.fex
	elif [ "x${PACK_FUNC}" = "xprvt" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/sys_partition_private.fex ${LICHEE_PACK_OUT_DIR}/sys_partition.fex
	fi

	printf "copying boot resource\n"
	for file in ${boot_resource_list[@]} ; do
		cp -rf $(echo $file | sed -e 's/:/ /g') 2>/dev/null
	done

	# openwrt use these logo files
	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		rm -rf ${LICHEE_PACK_OUT_DIR}/boot-resource
		cp -rf $CFG_TOP_DIR/${PACK_PLATFORM}/target/$PACK_IC/$PACK_IC-common/boot-resource/boot-resource ${LICHEE_PACK_OUT_DIR}
		cp -rf $CFG_TOP_DIR/${PACK_PLATFORM}/target/$PACK_IC/$PACK_IC-common/boot-resource/boot-resource.ini ${LICHEE_PACK_OUT_DIR}/boot-resource.ini
	fi

	if [ ! -f ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp ]; then
		cp ${LICHEE_PACK_OUT_DIR}/boot-resource/bootlogo.bmp ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp
	fi

	lzma -k ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp
	lzma -k ${LICHEE_PACK_OUT_DIR}/bempty.bmp
	lzma -k ${LICHEE_PACK_OUT_DIR}/battery_charge.bmp

	if [ -f ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp.lzma ]; then
		add_lzma_header "${LICHEE_PACK_OUT_DIR}/bootlogo.bmp.lzma" "${LICHEE_PACK_OUT_DIR}/bootlogo.bmp"
		(cd ${LICHEE_PACK_OUT_DIR}; ln -sf bootlogo.bmp.lzma.head  bootlogo.fex)
	fi

	printf "copying boot file\n"
	for d in ${possible_bin_path[@]}; do
		[ ! -d ${LICHEE_CHIP_CONFIG_DIR}/$d ] && continue
		BIN_PATH=$d
		for file in ${boot_file_list[@]} ; do
			eval cp -v -f $(echo $file | sed -e 's/:/ /g') 2>/dev/null
		done
	done
	printf "copying boot file 2.0\n"
	for file in ${boot_file_list_2[@]} ; do
		eval cp -v -f $(echo $file | sed -e 's/:/ /g') 2>/dev/null
	done
	if [[ ${LICHEE_BOARD} == *fastboot*spinand* ]] ; then
		mv -v ${LICHEE_PACK_OUT_DIR}/boot0_nandfastboot_${PACK_CHIP}.fex ${LICHEE_PACK_OUT_DIR}/boot0_nand.fex
	fi

	if ! [ -z ${LICHEE_BOOT0_BIN_NAME} ]; then
                # nand fastboot
                cp -v -f ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_nand.fex

		if [[ ${LICHEE_FLASH} == default ]] ; then
			mv -v ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
		elif [[ ${LICHEE_FLASH} == nor ]] ; then
			mv -v ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_spinor.fex
		else
			echo "invalid LICHEE_FLASH, default choose sdcard!"
			mv -v ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
		fi
	fi

	[ -z "${BIN_PATH}" ] &&
	pack_error "No BIN_PATH found!" && exit 1

	printf "copying $LICHEE_ARCH secure boot file\n"
	for d in ${possible_bin_path[@]}; do
		[ ! -d ${LICHEE_CHIP_CONFIG_DIR}/$d ] && continue
		BIN_PATH=$d
		for file in $(eval echo '$'"{${LICHEE_ARCH}_boot_file_secure[@]}"); do
			eval cp -f $(echo $file | sed -e 's/:/ /g') 2>/dev/null
		done
	done

	# If platform config use
	if [ -f ${LICHEE_CHIP_CONFIG_DIR}/tools/plat_config.sh ] ; then
		${LICHEE_CHIP_CONFIG_DIR}/tools/plat_config.sh
	fi

	if [ "x${PACK_NOR}" = "xnor" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/image_nor.cfg ${LICHEE_PACK_OUT_DIR}/image.cfg
		cp -vf ${LICHEE_PACK_OUT_DIR}/sboot_nor.bin ${LICHEE_PACK_OUT_DIR}/sboot.bin
		cp -vf ${LICHEE_PACK_OUT_DIR}/dragon_toc_nor.cfg ${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
	fi

	if [ "x${PACK_VSP}" = "xvsp" ] ; then
		printf "change usb_port_type to device...\n"
		printf "disable usb_serial_unique...\n"
		printf "change usb_serial_number to ${PACK_TYPE}_android...\n"
		sed -i 's/^usb_port_type.*/usb_port_type = 0/g' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i 's/^usb_serial_unique.*/usb_serial_unique = 0/g' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i 's/^usb_serial_number.*/usb_serial_number = "'"${PACK_CHIP}"'_android"/g' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	printf "copying additional files\n"
	for file in ${PACK_ADD_FILES[@]}; do
		cp -vf $(echo $file | sed -e 's/:/ /g') 2>/dev/null
	done

	if [ "x${PACK_PLATFORM}" == "xandroid" ] && [ "x$TARGET_BUILD_VARIANT" == "xuser" ]; then
		pack_info "change kernel loglevel to 3 for android user build"
		sed -i 's|^\s*loglevel=[0-9]\s*$|loglevel=3|g' ${LICHEE_PACK_OUT_DIR}/env.cfg
		if [ "${ENABLE_VENDOR_ADB}" == "true" ]; then
			pack_info "enable vendor adb for android user build"
			sed -i 's|^init_rc=.*$|init_rc=/vendor/etc/init/hw/init.aw.rc|g' ${LICHEE_PACK_OUT_DIR}/env.cfg
		fi
	fi

	if [ "x${PACK_PROGRAMMER}" = "xprogrammer" ]; then
		printf "add programmer img info target in sys config\n"
		sed -i -e '/^\[target\]/a\programmer=1' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	sed -i 's/\\boot-resource/\/boot-resource/g' ${LICHEE_PACK_OUT_DIR}/boot-resource.ini
	sed -i 's/\\\\/\//g' ${LICHEE_PACK_OUT_DIR}/image.cfg
	sed -i 's/^imagename/;imagename/g' ${LICHEE_PACK_OUT_DIR}/image.cfg

	prepare_mixed_androiddragonboard
	[ $? -ne 0 ] && exit 1

	partition_size_handle
	[ $? -ne 0 ] && exit 1

	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		cd ${LICHEE_PACK_OUT_DIR}/
		echo "vmlinux" > ${LICHEE_PACK_OUT_DIR}/vmlinux.fex
		if [ "x${PACK_NOR}" = "xnor" ] ; then
			make_user_res sys_partition_nor.fex
			make_app_res sys_partition_nor.fex
			make_data_res sys_partition_nor.fex
		else
			make_user_res sys_partition.fex
			make_app_res sys_partition.fex
			make_data_res sys_partition.fex
		fi
		cd - > /dev/null
	fi
}

function img_to_programmer()
{
	local out_img=$1
	local in_img=$2

	cd ${LICHEE_PACK_OUT_DIR}/

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		if [ -f toc0_sdcard.fex ] ; then
			programmer_img toc0_sdcard.fex toc1.fex ${out_img} > /dev/null
		elif [ -f toc0_nand.fex ] ; then
			programmer_img toc0_nand.fex toc1.fex ${out_img} > /dev/null
		else
			programmer_img toc0.fex toc1.fex ${out_img} > /dev/null
		fi
	else
		programmer_img boot0_sdcard.fex boot_package.fex ${out_img} > /dev/null
	fi

	if [ -f sunxi_gpt.fex ] ; then
		#create_img for sunxi_gpt.fex
		programmer_img sys_partition.bin sunxi_mbr.fex ${out_img} ${in_img} sunxi_gpt.fex > /dev/null
	else
		#create_img for sunxi_mbr.fex
		programmer_img sys_partition.bin sunxi_mbr.fex ${out_img} ${in_img} > /dev/null
	fi

}

function uboot_ini_to_dts()
{
	local TARGET_UBOOT
	local PLATFORM_ADDR
	local SOC_ADDR
	local DTC_FLAGS=""

	if [ x${LICHEE_BRANDY_UBOOT_VER} == x2023 ]; then
		pack_info "skip split fdt"
		return
	fi

	if [ "x${PACK_NOR}" == "xnor" ]; then
		TARGET_UBOOT=${LICHEE_PACK_OUT_DIR}/u-boot-spinor.fex
	else
		TARGET_UBOOT=${LICHEE_PACK_OUT_DIR}/u-boot.fex
	fi
	sunxi_ubootools split ${TARGET_UBOOT} > /dev/null
	if [ $? -ne 0 ]
	then
		pack_warn "split uboot and fdt failed!!"
		return
	fi

	[ "$(readlink -f .)" != "$(readlink -f ${LICHEE_PACK_OUT_DIR})" ] && {
		mv temp_fdt.dtb  ${LICHEE_PACK_OUT_DIR}
		mv temp_ubootnodtb.bin  ${LICHEE_PACK_OUT_DIR}
	}

	# to dts
	$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb  2>/dev/null

	PLATFORM_ADDR=`grep -Po "(?<=platform@)(\w+)(?=\s*{)" ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp | head -1`
	SOC_ADDR=`grep -Po "(?<=soc@)(\w+)(?=\s*{)" ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp | head -1`

	if [ "x${PACK_TYPE}" = "xdragonboard" -o "x${PACK_TYPE}" = "xdragonabts" ] ; then
		cat <<- EOF >> ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp
		/{
			soc@${SOC_ADDR} {
				platform@${PLATFORM_ADDR} {
				dragonboard_test = <1>;
				};
			};
		};
		EOF
	fi

	# to dtb
	$DTC_COMPILER ${DTC_FLAGS} -I dts -O dtb -o ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp  2>/dev/null

	# get update_to_ubootfdt value from sysconfig
	sunxi_ubootools subkey_value sys_config.bin sunxi_ubootools update_to_ubootfdt > /dev/null
	if [ $? -eq 1 ]; then
		echo "uboot ini to dts"
		$DTC_COMPILER -p 2048 ${DTC_FLAGS} -@ -O dtb -o ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb	\
			-b 0			\
			-i ${LICHEE_PACK_OUT_DIR}	\
			-F $DTC_INI_FILE \
			-d ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp 2>/dev/null
	else
		mv ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb  ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb
	fi

	sunxi_ubootools merge ${LICHEE_PACK_OUT_DIR}/temp_ubootnodtb.bin ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb > /dev/null
	cp -vf ${LICHEE_PACK_OUT_DIR}/temp_ubootnodtb.bin ${TARGET_UBOOT}
	# .uboot.dts is the last dts of uboot
	$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PACK_OUT_DIR}/.uboot.dts ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb 2>/dev/null
}

function do_ini_to_dts()
{
	cd ${LICHEE_PACK_OUT_DIR}/

	maybe_busybox unix2dos sys_config.fex
	script  sys_config.fex > /dev/null

	local DTC_SRC_PATH=${LICHEE_PLAT_OUT}
	local DTC_COMPILER=${LICHEE_PLAT_OUT}/dtc
	local DTC_FLAGS=""

	uboot_ini_to_dts

	if [ "x${PACK_KERN}" == "xlinux-3.4" \
			-o "x${PACK_KERN}" == "xlinux-3.10" \
			-o "x${PACK_KERN}" == "xlinux-4.4" \
			-o "x${PACK_KERN}" == "xlinux-5.4" \
			-o "x${PACK_KERN}" == "xlinux-5.4-ansc" \
			-o "x${PACK_KERN}" == "xlinux-5.10" \
			-o "x${PACK_KERN}" == "xlinux-5.10-origin" \
			-o "x${PACK_KERN}" == "xlinux-5.15" \
			-o "x${PACK_KERN}" == "xlinux-5.15-origin" ] || [[  ${PACK_KERN/linux-} > 5.15 ]]; then
		# For debug: sunxi.dtb -> .sunxi.dts
		$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PLAT_OUT}/.sunxi.dts ${LICHEE_PLAT_OUT}/sunxi.dtb 2>/dev/null
		return
	fi

	local dtc_file_list=(
		.board.dtb.d.dtc.tmp:.board.dtb.dts.tmp
		.${PACK_CHIP}-${PACK_BOARD}.dtb.d.dtc.tmp:.${PACK_CHIP}-${PACK_BOARD}.dtb.dts.tmp
		.${PACK_CHIP}-${LICHEE_BUSSINESS}.dtb.d.dtc.tmp:.${PACK_CHIP}-${LICHEE_BUSSINESS}.dtb.dts.tmp
		.${PACK_CHIP}-soc.dtb.d.dtc.tmp:.${PACK_CHIP}-soc.dtb.dts.tmp)

	local DTC_INI_FILE_BASE=${LICHEE_PACK_OUT_DIR}/sys_config.fex
	local DTC_INI_FILE=${LICHEE_PACK_OUT_DIR}/sys_config_fix.fex

	cp $DTC_INI_FILE_BASE $DTC_INI_FILE
	sed -i "s/\(\[dram\)_para\(\]\)/\1\2/g" $DTC_INI_FILE
	sed -i "s/\(\[nand[0-9]\)_para\(\]\)/\1\2/g" $DTC_INI_FILE

	if [ ! -f $DTC_COMPILER ]; then
		pack_error "Script_to_dts: Can not find dtc compiler.\n"
		exit 1
	fi

	local DTC_DEP_FILE DTC_SRC_FILE
	for e in ${dtc_file_list[@]}; do
		DTC_DEP_FILE=$DTC_SRC_PATH/${e/:*}
		if [ -f $DTC_DEP_FILE ]; then
			DTC_SRC_FILE=$DTC_SRC_PATH/${e#*:}
			break
		fi
	done

	echo "sunxi_dtb create"
	$DTC_COMPILER -p 2048 ${DTC_FLAGS} -@ -O dtb -o ${LICHEE_PLAT_OUT}/sunxi.dtb	\
		-b 0			\
		-i $DTC_SRC_PATH	\
		-F $DTC_INI_FILE	\
		-d $DTC_DEP_FILE $DTC_SRC_FILE 2>/dev/null

	if [ $? -ne 0 ]; then
		pack_error "Conver script to dts failed"
		exit 1
	fi

	#restore the orignal dtsi
	if [ "x${PACK_TYPE}" = "xdragonboard" \
		-o "x${PACK_TYPE}" = "xdragonmat" ]; then
		local DTS_PATH=${LICHEE_KERN_DIR}/arch/${LICHEE_ARCH}/boot/dts
		[ "x${LICHEE_ARCH}" = "xarm64" ] && DTS_PATH=${LICHEE_KERN_DIR}/arch/${LICHEE_ARCH}/boot/dts/sunxi
		if [ -f ${DTS_PATH}/${PACK_CHIP}_bak.dtsi ];then
			rm -f ${DTS_PATH}/${PACK_CHIP}.dtsi
			mv  ${DTS_PATH}/${PACK_CHIP}_bak.dtsi  ${DTS_PATH}/${PACK_CHIP}.dtsi
		fi
	fi

	printf "Conver script to dts ok.\n"

	# It'is used for debug dtb
	$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PLAT_OUT}/.sunxi.dts ${LICHEE_PLAT_OUT}/sunxi.dtb 2>/dev/null

	return
}

function maybe_busybox()
{
	if [ "x$(which busybox)" == "x" ]; then
		pack_error "Tool busybox does not exist!"
		exit 1
	fi

	busybox $@ || $@
}

function generate_env_for_uboot()
{
	printf "$1 Conver to $2.\n"
	printf "LICHEE_BRANDY_UBOOT_VER : ${LICHEE_BRANDY_UBOOT_VER}\n"
	if [ -n "${LICHEE_BRANDY_UBOOT_VER}" ] && [ ${LICHEE_BRANDY_UBOOT_VER} -ge 2023 ]; then
		printf "create env.fex for uboot2023 or later, size 128K\n"
		# mkenvimage -p 0x00 -s 0x20000 -o env.fex env.cfg
		mkenvimage -p 0x00 -s 0x20000 -o $2 $1
	else
		# u_boot_env_gen env_nor.cfg env_nor.fex >/dev/null
		u_boot_env_gen $1 $2 >/dev/null
	fi
}

function do_common()
{
	cd ${LICHEE_PACK_OUT_DIR}/

	echo $(date -d "$ts" +"%Y-%m-%d %H:%M:%S") > ${LICHEE_PACK_OUT_DIR}/sunxi_version.fex

	# Here, we can switch uart to card or normal
	if [ "x${PACK_DEBUG}" = "xcard0" -a "x${PACK_MODE}" != "xdump" \
		-a "x${PACK_FUNC}" != "xprvt" ] ; then \
		uart_switch
	else
		sed -i -e '/^auto_print_used/s\1\0\' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		printf "add burn_secure_mode in target in sys config\n"
		sed -i -e '/^\[target\]/a\burn_secure_mode=1' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i -e '/^\[platform\]/a\secure_without_OS=0' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		if [ -f ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex ]; then
			rm -f ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex
		fi
	else
		sed -i '/^burn_secure_mod/d' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i '/^secure_without_OS/d' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		if [ -f ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex ]; then
			mv -v ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex ${LICHEE_PACK_OUT_DIR}/optee.fex
		fi
	fi

	if [ ! -f board_config.fex ]; then
		echo "[empty]" > board_config.fex
	fi

	maybe_busybox unix2dos sys_config.fex
	maybe_busybox unix2dos board_config.fex
	script  sys_config.fex > /dev/null
	cp -f   sys_config.bin config.fex
	script  board_config.fex > /dev/null
	cp -f board_config.bin board.fex

	maybe_busybox unix2dos sys_partition.fex
	script  sys_partition.fex > /dev/null


	if [ "x${PACK_TYPE}" = "xdragonboard" ] ; then
		maybe_busybox dos2unix test_config.fex
		cp test_config.fex boot-resource/
		maybe_busybox unix2dos test_config.fex
		script test_config.fex > /dev/null
		cp test_config.bin boot-resource/
	fi

	if [ "x${PACK_TYPE}" = "xdragonabts" ] ; then
		maybe_busybox dos2unix test_config.fex
		cp test_config.fex boot-resource/
		maybe_busybox unix2dos test_config.fex
		script test_config.fex > /dev/null
		cp test_config.bin boot-resource/
	fi
	# Those files for SpiNor. We will try to find sys_partition_nor.fex
	if [ "x${PACK_NOR}" = "xnor" ] ; then

		if [ ! -f sys_partition_nor.fex ];  then
			echo "sys partition for nor not exist"
			exit 1
		fi

		if [ ! -f ${LICHEE_CHIP_CONFIG_DIR}/tools/arisc_config_parse.sh ]; then
			if [ -f "scp.fex" ]; then
				echo "update scp"
				update_scp scp.fex sunxi.fex >/dev/null
			fi
		fi

		# Here, will create sys_partition_nor.bin
		maybe_busybox unix2dos sys_partition_nor.fex
		script  sys_partition_nor.fex > /dev/null
		update_boot0 boot0_spinor.fex   sys_config.bin SPINOR_FLASH > /dev/null
		update_chip boot0_spinor.fex   > /dev/null
		update_fes1  fes1.fex           sys_config.bin > /dev/null

		if [ "x${PACK_KERN}" = "xlinux-3.4" ] ; then
			update_uboot -merge u-boot-spinor.fex  sys_config.bin > /dev/null
		else
			update_uboot -no_merge u-boot-spinor.fex  sys_config.bin > /dev/null
			update_uboot -no_merge u-boot-spinor-secure.fex  sys_config.bin > /dev/null
			[ -f u-boot-efex.fex ] && {
				update_uboot -no_merge u-boot-efex.fex  sys_config.bin > /dev/null
			}
		fi

		while read line
		do
			compress_name=(`echo $line | awk '($1 !~ ";" && ($2 ~ "lzma" || $2 ~ "lz4" || $2 ~ "gz")) {print $2}'`)
			source_name=(`echo $compress_name | cut -d \.  -f 1,2 | cut -d \  -f 2`)
			compress_type=(`echo $compress_name | cut -d \.  -f 3 | cut -d \  -f 2`)
			[ -z "$compress_name" ] && continue
			case $compress_type in
			"gz")
				[ -f $source_name ] && gzip -c $source_name > $compress_name || echo "no exist $source_name"
				echo "compress name: $compress_name"
				;;
			"lzma")
				[ -f $source_name ] && lzma -k $source_name || echo "no exist $source_name"
				mv $source_name.lzma $compress_name >/dev/null 2<&1
				echo "compress name: $compress_name"
				;;
			"lz4")
				[ -f $source_name ] && lz4 -f $source_name $compress_name || echo "no exist $source_name"
				echo "compress name: $compress_name"
				;;
			*)
				echo "no match compress type"
				;;
			esac
			echo "compress type: $compress_type"
		done < boot_package_nor.cfg

		if [ -f boot_package_nor.cfg ]; then
			mv u-boot-spinor-crash.fex u-boot-crash.fex
			echo "pack boot package"
			maybe_busybox unix2dos boot_package.cfg
			dragonsecboot -pack boot_package_nor.cfg
			cp boot_package.fex boot_package_nor.fex
		fi
		# Ugly, but I don't have a better way to change it.
		# We just set env's downloadfile name to env_nor.cfg in sys_partition_nor.fex
		# And if env_nor.cfg is not exist, we should copy one.
		if [ ! -f env_nor.cfg ]; then
			cp -f env.cfg env_nor.cfg >/dev/null 2<&1
		fi

		#card sprite
		if [ -f "boot0_sdcard.fex" ]; then
			update_boot0 boot0_sdcard.fex   sys_config.bin SDMMC_CARD > /dev/null
			update_chip boot0_sdcard.fex > /dev/null
		fi

		# Fixup boot mode for SPINor, just can bootm
		sed -i '/^boot_normal/s#\<boota\>#bootm#g' env_nor.cfg

		echo 1:LICHEE_REDUNDANT_ENV_SIZE:$LICHEE_REDUNDANT_ENV_SIZE
		if [ "x${LICHEE_REDUNDANT_ENV_SIZE}" != "x" ]; then
			echo "--mkenvimage create redundant env data!--"
			echo "--redundant nor env data size ${LICHEE_REDUNDANT_ENV_SIZE}---"
			mkenvimage -r -p 0x00 -s ${LICHEE_REDUNDANT_ENV_SIZE} -o env_nor.fex env_nor.cfg
		else
			generate_env_for_uboot env_nor.cfg env_nor.fex
		fi
	else
		update_boot0 boot0_nand.fex     sys_config.bin NAND > /dev/null
		update_boot0 boot0_sdcard.fex   sys_config.bin SDMMC_CARD > /dev/null
		update_boot0 boot0_ufs.fex   sys_config.bin UFS > /dev/null
		update_chip boot0_nand.fex >/dev/null
		update_chip boot0_sdcard.fex >/dev/null
		update_chip boot0_ufs.fex >/dev/null
	fi

	if [ ! -f "u-boot-crash.fex" ]; then
		touch "u-boot-crash.fex"
		echo "ensure u-boot-crash.fex is not empty" > u-boot-crash.fex
	fi

	if [ -f "sunxi.fex" ]; then
		update_dtb sunxi.fex 4096
	fi

	if [ ! -f ${LICHEE_CHIP_CONFIG_DIR}/tools/arisc_config_parse.sh ]; then
		if [ -f "scp.fex" ]; then
			echo "update scp"
			update_scp scp.fex sunxi.fex >/dev/null
		fi
	fi

	if [ -f "optee.fex" ]; then
		echo "update optee"
		update_optee optee.fex sunxi.fex >/dev/null
	fi

	# Those files for Nand or Card
	if [ "x${PACK_KERN}" = "xlinux-3.4" ] ; then
		update_uboot -merge u-boot.fex sys_config.bin > /dev/null
	else
		update_uboot -no_merge u-boot.fex sys_config.bin > /dev/null
		[ -f u-boot-nodtb.fex ] && {
			update_uboot -no_merge u-boot-nodtb.fex sys_config.bin > /dev/null
		}
		[ -f u-boot-efex.fex ] && {
			update_uboot -no_merge u-boot-efex.fex  sys_config.bin > /dev/null
		}
	fi

	if [ -f "fes1_uart.fex" ]; then
		update_fes1  fes1_uart.fex           sys_config.bin > /dev/null
	fi

	update_fes1  fes1.fex           sys_config.bin > /dev/null
	if [ -f ${LICHEE_TOOLS_DIR}/pack/pctools/linux/mod_update/update_sboot ];then
		update_sboot sboot.bin  sys_config.bin  > /dev/null
		if [ $? -ne 0 ]
		then
			pack_error "update sboot run error"
			exit 1
		fi
	fi
	fsbuild      boot-resource.ini  split_xxxx.fex > /dev/null

	if [ -f boot_package_uartburn.cfg ]; then
		dragonsecboot -pack boot_package_uartburn.cfg
		if [ $? -ne 0 ]
		then
			pack_error "dragon pack boot_package_uartburn run error"
			exit 1
		fi
		mv boot_package.fex boot_package_uartburn.fex
	fi

	if [ -f boot_package.cfg ]; then
		if [ "x$LINUX_DTBO_FILE" = "x" ]; then
			echo "do not set LINUX_DTBO_FILE"
			line_num=`sed -n -e "/default.dtbo/=" boot_package.cfg`
			if [ "x$line_num" != "x" ]; then
				sed -i "$line_num s/^/;/g" boot_package.cfg
			fi
		else
			if [ -f $LINUX_DTBO_FILE ]
			then
				sed -i "s/default.dtbo/$LINUX_DTBO_FILE/g" boot_package.cfg
			else
				line_num=`sed -n -e "/default.dtbo/=" boot_package.cfg`
				if [ "x$line_num" != "x" ]; then
					sed -i "$line_num s/^/;/g" boot_package.cfg
				fi
			fi
		fi

			echo "pack boot package"
			maybe_busybox unix2dos boot_package.cfg
			dragonsecboot -pack boot_package.cfg

		if [ $? -ne 0 ]
		then
			pack_error "dragon pack run error"
			exit 1
		fi
	fi

	echo 2:LICHEE_REDUNDANT_ENV_SIZE:$LICHEE_REDUNDANT_ENV_SIZE
	if [ "x${PACK_FUNC}" = "xprvt" ] ; then
		if [ "x${LICHEE_REDUNDANT_ENV_SIZE}" != "x" ]; then
			echo "--mkenvimage create redundant env data!--"
			echo "--redundant env data size ${LICHEE_REDUNDANT_ENV_SIZE}---"
			mkenvimage -r -p 0x00 -s ${LICHEE_REDUNDANT_ENV_SIZE} -o env.fex env_burn.cfg
		else
			generate_env_for_uboot env_burn.cfg env.fex
		fi
	else
		if [ "x${LICHEE_REDUNDANT_ENV_SIZE}" != "x" ]; then
			echo "--mkenvimage create redundant env data!--"
			echo "--redundant env data size ${LICHEE_REDUNDANT_ENV_SIZE}---"
			mkenvimage -r -p 0x00 -s ${LICHEE_REDUNDANT_ENV_SIZE} -o env.fex env.cfg
		else
			generate_env_for_uboot env.cfg env.fex
		fi
	fi

	dmverity_deal clean

}

function do_finish()
{
	# Yeah, it should contain all files into full_img.fex for spinor
	# Because, as usually, spinor image size is very small.
	# If fail to create full_img.fex, we should fake it empty.

	# WTF, it is so ugly!!! It must be sunxi_mbr.fex & sys_partition.bin,
	# not sunxi_mbr_xxx.fex & sys_partition_xxx.bin. In order to advoid this
	# loathsome thing, we need to backup & copy files. Check whether
	# sys_partition_nor.bin is exist, and create sunxi_mbr.fex for Nor.
	local max_toc_size=2097152

	local IMG_NAME="${PACK_IC}_${PACK_TYPE}${PACK_PLATFORM_VERSION}_${PACK_BOARD}_${PACK_DEBUG}"
	if [ "x${PACK_MODE}" = "xdump" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_MODE}"
	fi

	if [ "x${PACK_FUNC}" = "xprvt" ]; then
		IMG_NAME="${IMG_NAME}_${PACK_FUNC}"
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_SECURE}"
	fi

	if [ "x${PACK_FUNC}" = "xprev_refurbish" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_FUNC}"
	fi

	if [ "x${PACK_NOR}" = "xnor" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_NOR}"
	fi

	if [ "x${PACK_SECURE}" != "xnone" ]; then
		local MAIN_VERION=$(readcfg dragon_toc.cfg rollback_ver ver)
		if [ ! -n "${MAIN_VERION}" ]; then
			local MAIN_VERION="$(echo '__unique:;@echo ${MAIN_VERSION}' | make -f - -f ${LICHEE_PACK_OUT_DIR}/version_base.mk --no-print-directory __unique)"
		fi
		IMG_NAME="${IMG_NAME}_v${MAIN_VERION}.img"
	else
		IMG_NAME="${IMG_NAME}.img"
	fi

	local IMG_PROGRAMMER_NAME="${IMG_NAME%.*}_programmer.img"

	echo "imagename = $IMG_NAME" >> ${LICHEE_PACK_OUT_DIR}/image.cfg
	echo "" >> ${LICHEE_PACK_OUT_DIR}/image.cfg

	local imagesize
	local toc_size
	local max_toc_size=3883264

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		toc_size=`stat toc1.fex --format="%s"`
	else
		toc_size=`stat boot_package.fex --format="%s"`
	fi

	if [ "$LICHEE_CHIP" == "sun55iw3p1" ]; then
		max_toc_size=3883264
	fi

	if [ ${toc_size} -gt ${max_toc_size} ];then
		pack_error "boot_package.fex/toc1.fex More than ${max_toc_size} bytes limit too large!!!"
		exit 1
	fi

	if [ "x${PACK_NOR}" = "xnor" ] ; then
		NOR_LOGIC_START=2016
		NOR_UBOOT_START=128
		NOR_FLASH_SIZE=65536 #32M
		NOR_LOGIC_START_KB=`expr ${NOR_LOGIC_START} / 2`
		NOR_UBOOT_START_KB=`expr ${NOR_UBOOT_START} / 2`

		local uboot_dts=""
		if [ -n "${LICHEE_BRANDY_UBOOT_VER}" ] && [ ${LICHEE_BRANDY_UBOOT_VER} -ge 2023 ]; then
			uboot_dts="${LICHEE_BOARD_CONFIG_DIR}/uboot-${LICHEE_BRANDY_UBOOT_VER}/uboot-board.dts"
		else
			uboot_dts="${LICHEE_BOARD_CONFIG_DIR}/uboot-board.dts"
		fi

		if [ -f ${uboot_dts} ] && [ x"$(grep "nor_map" ${uboot_dts})" != x"" ]; then
			echo "get flashmap from ${uboot_dts}"
			NOR_FLASH_SIZE=$(awk '/nor_map {/,/}/ {print NR ": " $0}' ${uboot_dts} \
				| grep  "\bflash_size\b" | grep -oP "(?<=\<)\d+(?=\>)")

			NOR_LOGIC_START=$(awk '/nor_map {/,/}/ {print NR ": " $0}' ${uboot_dts} \
				| grep  "\blogic_offset\b" | grep -oP "(?<=\<)\d+(?=\>)")

			NOR_UBOOT_START=$(awk '/nor_map {/,/}/ {print NR ": " $0}' ${uboot_dts} \
				| grep  "\buboot_start\b" | grep -oP "(?<=\<)\d+(?=\>)")

			[ x"${NOR_FLASH_SIZE}" = x"" -o x"${NOR_LOGIC_START}" = x"" -o x"${NOR_UBOOT_START}" = x"" ] && {
				pack_warn "flash_size,logic_offset,uboot_start maybe not set in uboot-board.dts"
				NOR_LOGIC_START=2016
				NOR_UBOOT_START=128
				NOR_FLASH_SIZE=65536 #32M
			}

			NOR_LOGIC_START_KB=`expr ${NOR_LOGIC_START} / 2`
			NOR_UBOOT_START_KB=`expr ${NOR_UBOOT_START} / 2`
			echo "flash size:${NOR_FLASH_SIZE}, logic start:${NOR_LOGIC_START}, uboot start:${NOR_UBOOT_START}"
		fi

		update_mbr sys_partition_nor.bin 1 sunxi_mbr_nor.fex dlinfo.fex \
				${NOR_FLASH_SIZE} ${NOR_LOGIC_START} 1

		if [ $? -ne 0 ]; then
			pack_error "update_mbr failed"
			exit 1
		fi
		echo '----------programmer nor image is full_img.fex ----------'
		if [ "x${PACK_KERN}" = "xlinux-3.4" ] ; then
		#when use devicetree, the size of uboot+dtb is larger then 256K
			#BOOT1_FILE=u-boot-spinor.fex
			#LOGIC_START=240 #240+16=256K
			#merge_package full_img.fex boot0_spinor.fex \
			#        u-boot-spinor.fex sunxi_mbr_nor.fex sys_partition_nor.bin
			merge_full_img --out full_img.fex --boot0 boot0_spinor.fex --boot1 u-boot-spinor.fex \
							--mbr sunxi_mbr_nor.fex  --partition sys_partition_nor.bin \
							--logic_start 240 > /dev/null
		else
			merge_full_img --out full_img.fex --boot0 boot0_spinor.fex --boot1 boot_package_nor.fex \
				--mbr sunxi_gpt.fex --partition sys_partition_nor.bin \
				--logic_start ${NOR_LOGIC_START_KB} --uboot_start ${NOR_UBOOT_START_KB} > /dev/null
		fi

		if [ $? -ne 0 ]; then
			pack_error "merge_full_img failed"
			exit 1
		fi
		mv sys_partition_nor.fex sys_partition.fex
	fi

	if [ ! -f sys_partition_nor.bin ]; then
		update_mbr          sys_partition.bin 4
		if [ $? -ne 0 ]; then
			pack_error "update_mbr failed"
			exit 1
		fi

		#15269888 is from emmc datasheet, sec_count in Extended CSD is 0xe90000 = 15269888.
		#40960 is the mbr location for emmc
		#0  is emmc/nand ; 1 is spinor
		update_mbr sys_partition.bin 4 sunxi_mbr.fex dlinfo.fex 15269888 40960 0
		if [ $? -ne 0 ]; then
			pack_error "update_mbr_gpt failed"
			exit 1
		fi
	fi

	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		echo "===================================="
		echo "show sys_partition.fex message"
		show_partition_message sys_partition.fex
	fi

	local e cfgadd cfgget lastcfgline localfile filename
	local imgcfg_add_list=(
		# localfile             filename-in-cfg        maintype  subtype
		'vmlinux.fex            vmlinux.fex            12345678  123456789VMLINUX'
		'vendor_boot-debug.fex  vendor_boot-debug.fex  RFSFAT16  VENDOR_BOOTDEBUG'
		'dragon_toc.cfg         dragon_toc.fex         12345678  12345678DGTOCCFG'
		)

	for e in "${imgcfg_add_list[@]}"; do
		localfile="$(awk '{print $1}' <<< $e)"
		filename="$(awk '{print $2}' <<< $e)"
		maintype="$(awk '{print $3}' <<< $e)"
		subtype="$(awk '{print $4}' <<< $e)"
		cfgget="$(sed -n '/^\s*{\s*filename\s*=\s*"'$filename'"\s*,/p' image.cfg)"
		lastcfgline="$(sed -n '/^\s*{\s*filename\s*=/=' image.cfg | tail -1)"

		[ ! -f "$localfile" -o -n "$cfgget" -o -z "$lastcfgline" ] && continue
		[ "$localfile" != "$filename" ] && ln -sf $localfile $filename
		cfgadd='    {filename = "'$filename'",'
		cfgadd+='     maintype = "'$maintype'",'
		cfgadd+='     subtype  = "'$subtype'",},'
		sed -i -e  ''"${lastcfgline}"'a\' -e "$cfgadd" image.cfg
	done

	dragon image.cfg    sys_partition.fex
	if [ $? -eq 0 ]; then
		if [ -e ${IMG_NAME} ]; then
			mv ${IMG_NAME} $LICHEE_OUT_DIR/$LICHEE_IC/$LICHEE_BOARD/$LICHEE_LINUX_DEV/${IMG_NAME}
			rm -f $LICHEE_OUT_DIR/${IMG_NAME}
			ln -f $LICHEE_OUT_DIR/$LICHEE_IC/$LICHEE_BOARD/$LICHEE_LINUX_DEV/${IMG_NAME}  $LICHEE_OUT_DIR/${IMG_NAME}
			imagesize=$(du --apparent-size -sh $LICHEE_OUT_DIR/$LICHEE_IC/$LICHEE_BOARD/$LICHEE_LINUX_DEV/${IMG_NAME} | awk '{print $1}')
			echo '----------image is at----------'
			echo -e '\033[0;31;1m'
			echo -e "$imagesize\t${LICHEE_OUT_DIR}/${IMG_NAME}"
			echo -e '\033[0m'
		fi
	fi
	cd ..

	if [ "x${PACK_PROGRAMMER}" = "xprogrammer" ]; then
		if [ -f  $LICHEE_PACK_OUT_DIR/super.fex ]; then
			mv $LICHEE_PACK_OUT_DIR/super.fex $LICHEE_PACK_OUT_DIR/super.bak.fex
			simg2img  $LICHEE_PACK_OUT_DIR/super.bak.fex $LICHEE_PACK_OUT_DIR/super.fex
		fi
		echo "waiting to ceate programmer img..."
		img_to_programmer ${IMG_PROGRAMMER_NAME} $LICHEE_OUT_DIR/${LICHEE_IC}/${LICHEE_BOARD}/${LICHEE_LINUX_DEV}/${IMG_NAME}
		if [ $? -eq 0 ]; then
			if [ -e ${IMG_PROGRAMMER_NAME} ]; then
				mv $LICHEE_PACK_OUT_DIR/${IMG_PROGRAMMER_NAME} $LICHEE_OUT_DIR/${LICHEE_IC}/${LICHEE_BOARD}/${LICHEE_LINUX_DEV}/${IMG_PROGRAMMER_NAME}
				imagesize=$(du --apparent-size -sh $LICHEE_OUT_DIR/${LICHEE_IC}/${LICHEE_BOARD}/${LICHEE_LINUX_DEV}/${IMG_PROGRAMMER_NAME} | awk '{print $1}')
				echo '----------programmer image is at----------'
				echo -e '\033[0;31;1m'
				echo -e "$imagesize\t${LICHEE_OUT_DIR}/${IMG_PROGRAMMER_NAME}"
				echo -e '\033[0m'
			fi
		fi
	fi
	cd ..
	do_finish_SATA
	printf "pack finish\n"
	[ -e ${LICHEE_TOP_DIR}/build/.hooks/post-dragon ] &&
		source ${LICHEE_TOP_DIR}/build/.hooks/post-dragon
	return 0
}

function do_finish_SATA()
{
	if [ "x$BUILD_SATA" = "xtrue" ];then
		SATA_TAR=$LICHEE_TOP_DIR/SATA/linux/${LICHEE_CHIP}.tar
		if [ -f $SATA_TAR ];then
			echo '----------SATA is at----------'
			echo -e '\033[0;31;1m'
			echo $SATA_TAR
			echo -e '\033[0m'
		else
			echo PACK SATA failed!
		fi
	fi
}

function dmverity_deal()
{
	local script_name=scripts/build.sh
	local script_path=$LICHEE_KERN_DIR

	if [ ! -x $script_path/$script_name ]; then
		script_path=$LICHEE_BUILD_DIR
		script_name=mkkernel.sh
	fi

	[ ! -x $script_path/$script_name ] && return 255
	[ -z "$(grep "^\s*deal_verity)\s*$" $script_path/$script_name)" ] && return 1

	(cd $script_path && ./$script_name "deal_verity" $@)
}

function dmverity_get_blk_count()
{
	local size=`du --apparent-size -b $1 | awk '{print $1}'`
	local BLK_SIZE=$2

	if [ `expr ${size} % ${BLK_SIZE}` = "0" ]; then
			local blks=`(expr ${size} / ${BLK_SIZE})`
	else
			local blks=`(expr ${size} / ${BLK_SIZE} + 1 )`
	fi

	echo $blks
}

function dmverity_determ_blk_size()
{
	local type_info=`file -L $1`

	#check rootfs file system type to determ block size
	if [ "x""`echo ${type_info}| grep "ext4 filesystem"`" != "x" ];then
		block_size=`tune2fs -l $1|grep "Block size"|awk {'print $3'}`
		echo ${block_size}
	else
		echo "not support file system type"
		return -1
	fi

}
function dmverity_genHashTable()
{
	local fs_name=$1
	local tree_name=$2
	local table_name=$3
	local block_size=`dmverity_determ_blk_size ${fs_name}`
	if [ ${block_size} -lt 0 ];then
		return -1
	fi
	veritysetup format --data-block-size=${block_size} --hash-block-size=${block_size} ${fs_name} ${tree_name} > ${table_name}
	return $?
}

function dmverity_genDownloadFile()
{
	local fs_name=$1
	local sign_name=$2
	local table_name=$3
	local tree_name=$4
	local download_file_name=$5

	local BLK_SIZE=`dmverity_determ_blk_size ${fs_name}`
	if [ ${BLK_SIZE} -lt 0 ];then
		return -1
	fi
	local SIGN_BLK=`dmverity_get_blk_count ${sign_name} ${BLK_SIZE}`
	local TABLE_BLK=`dmverity_get_blk_count ${table_name} ${BLK_SIZE}`
	local TREE_BLK=`dmverity_get_blk_count ${tree_name} ${BLK_SIZE}`

	# 3.1 copy sign
	dd if=${sign_name} of=${download_file_name}"tmp" bs=${BLK_SIZE} count=${SIGN_BLK} >/dev/null 2>&1

	# 3.2 copy table size
	local TABLE_SIZE=`du --apparent-size -b ${table_name} | awk '{print $1}'`
	local HIGH_BYTES=`expr $TABLE_SIZE / 256 `
	local LOW_BYTES=`expr $TABLE_SIZE % 256 `
	if [ $HIGH_BYTES -gt 256 ]; then
		echo "ERROR rootfs_hash_table size should < 64KB"
		return -1
	fi
	local HIGH_BYTES_H=`echo "obase=16;ibase=10;$HIGH_BYTES" | bc`
	local LOW_BYTES_H=`echo "obase=16;ibase=10;$LOW_BYTES" | bc`
	echo -e -n "\x$LOW_BYTES_H\x$HIGH_BYTES_H" >> ${download_file_name}"tmp"

	# 3.3 copy rootfs_hash_table
	dd if=${table_name} of=${download_file_name}"tmp"  bs=${BLK_SIZE} seek=${SIGN_BLK} count=${TABLE_BLK} > /dev/null 2>&1

	# 3.4 copy rootfs_hash_tree.bin
	dd if=${tree_name} of=${download_file_name}"tmp"  bs=${BLK_SIZE} seek=`expr ${SIGN_BLK} + ${TABLE_BLK}` count=${TREE_BLK} > /dev/null 2>&1

	dd of=${download_file_name} if=${download_file_name}"tmp" bs=${BLK_SIZE} count=`expr ${SIGN_BLK} + ${TABLE_BLK} + ${TREE_BLK}`>/dev/null 2>&1
	rm ${download_file_name}"tmp"
}

function do_signature_dsp()
{
	local DSP0_BIN=${LICHEE_PACK_OUT_DIR}/amp_dsp0.fex;
	local DSP1_BIN=${LICHEE_PACK_OUT_DIR}/amp_dsp1.fex;
	local CFG_FILE=${LICHEE_CHIP_CONFIG_DIR}/configs/default/image_header_secure.cfg;

	if [ -f ${CFG_FILE} ] ; then
		cp -v ${CFG_FILE} image_header_secure.cfg
	else
		printf "can not found image_header_secure cfg\n"
		return 1
	fi

	if [ -f ${DSP0_BIN} ] ; then
		mkimage_header -C 5 -c image_header_secure.cfg -s rsa -k $CFG_KEY_DIR
		if [ $? -ne 0 ]
		then
			pack_error "mkimage_header signature dsp error\n"
			exit 1
		fi
		mv amp_dsp0.fex.pack amp_dsp0.fex
	else
		printf "can not found amp_dsp0 bin\n"
		return 3
	fi

	if [ -f ${DSP1_BIN} ] ; then
		mv amp_dsp0.fex.pack amp_dsp0.fex
	fi

}

function do_signature_riscv()
{
	local RV0_BIN=${LICHEE_PACK_OUT_DIR}/amp_rv0.fex;
	local RV1_BIN=${LICHEE_PACK_OUT_DIR}/amp_rv1.fex;
	local CFG_FILE=${LICHEE_CHIP_CONFIG_DIR}/configs/default/image_header_secure.cfg;
	local key_type=$(readcfg dragon_toc.cfg key_para key_toc1 | cut -c 1-3)
	if [ x${key_type} == "xecc" ]; then
		sign_alg=ecc
	else
		sign_alg=rsa
	fi

	if [ -f ${CFG_FILE} ] ; then
		cp -v ${CFG_FILE} image_header_secure.cfg
	else
		printf "can not found image_header_secure cfg\n"
		return 1
	fi

	if [ -f ${RV0_BIN} ] ; then
		mkimage_header -C 5 -c image_header_secure.cfg -s $sign_alg -k $CFG_KEY_DIR
		if [ $? -ne 0 ]
		then
			pack_error "mkimage_header signature rv error\n"
			exit 1
		fi
		mv amp_rv0.fex.pack amp_rv0.fex
	else
		printf "can not found amp_rv0 bin\n"
		return 3
	fi

	if [ -f ${RV1_BIN} ] ; then
		mv amp_rv1.fex.pack amp_rv1.fex
	fi

}

function do_signature_ft()
{
	if [ ! -e ${LICHEE_PACK_OUT_DIR}/ft_${PACK_CHIP}.bin ]; then
		printf "can not found ft bin\n"
		return 1
	fi

	if [ -e ${LICHEE_PACK_OUT_DIR}/dragon_toc_ft.cfg ]; then
		printf "can not found dragon_toc_ft cfg\n"
	fi

	printf "prepare for signature for ft bin\n"
	mv ${LICHEE_PACK_OUT_DIR}/ft_${PACK_CHIP}.bin ${LICHEE_PACK_OUT_DIR}/ft.bin
	dragonsecboot -toc0 dragon_toc_ft.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
	if [ $? -ne 0 ]; then
		pack_error "dragon toc0_ft run error\n"
		exit 1
	fi

	mv toc0.fex toc0_ft.fex
}

function do_signature_fel()
{
	printf "prepare for signature for fex tools\n"
	local ROOT_KEY_NAME="";
	local UBOOT_NAME="u-boot";
	local sign_tools=$(readcfg dragon_toc.cfg sign_fel_tools sign_tools)

	if [ -f u-boot-efex.fex ]; then
		UBOOT_NAME="u-boot-efex"
	fi
	echo UBOOT_NAME ${UBOOT_NAME}

	if [ x${sign_tools} == "xdragonsboot" ]; then
		printf "using dragonsboot to sign fel\n"

		if [ -f ${CFG_KEY_DIR}/RootKey_Level_0.pem ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/RootKey_Level_0.pem
		elif [ -f ${CFG_KEY_DIR}/Trustkey.pem ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/Trustkey.pem
		else
			pack_error "can not found root key to sign fex tool"
			exit 1
		fi
		echo rootkeyname ${ROOT_KEY_NAME}

		dragonsecboot -sign fes1.fex ${ROOT_KEY_NAME} ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
		if [ $? -eq 0 ]; then
			dragonsecboot -sign ${UBOOT_NAME}.fex ${ROOT_KEY_NAME} ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
			if [ $? -ne 0 ]
			then
				pack_error "dragonsecboot uboot fail"
			fi
		fi
	else
		printf "using sig_fel_image to sign fel\n"
		if [ -f ${CFG_KEY_DIR}/RootKey_Level_0.bin ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/RootKey_Level_0.bin
		elif [ -f ${CFG_KEY_DIR}/Trustkey.bin ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/Trustkey.bin
		else
			pack_error "can not found root key to sign fex tool"
			exit 1
		fi
		echo rootkeyname ${ROOT_KEY_NAME}

		sig_fel_image --input fes1.fex --rsakey ${ROOT_KEY_NAME} --output fes1_sign.fex --version_base ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "sig_fel_image fes fail"
			exit 1
		fi
		sig_fel_image --input ${UBOOT_NAME}.fex --rsakey ${ROOT_KEY_NAME} --output ${UBOOT_NAME}_sign.fex --version_base ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "sig_fel_image uboot fail"
		fi
	fi

	if [ -f fes1_sign.fex ]; then
		cp fes1_sign.fex fes1.fex
	fi

	if [ -f  ${UBOOT_NAME}_sign.fex ]; then
		cp ${UBOOT_NAME}_sign.fex ${UBOOT_NAME}.fex
	fi
}

function readcfg()
{
	local fid=$1
	local section=$2
	local option=$3

	test ! -f $fid && echo "file not exits:$fid" && exit 1
	if [ $# -eq 3 ] ; then
		local src=$(cat $fid | awk '/\['$section'\]/{f=1;next} /\[*\]/{f=0} f' |
		grep ^$option |
		grep '='     |
		cut -d'=' -f2|
		cut -d'#' -f1|
		cut -d';' -f1|
		awk '{gsub(/^\s+|\s+$/, "");print}')
		echo -n $src
		test ${#src} -eq 0 && return 1 || return 0
	else
		echo "the input parameters should be 3"
		exit 1
	fi
}

function get_item_from_cfg()
{
	name=()
	bin=()
	cert=()
	counts=0

	local toc_cfg=$1
	local field=$2
	local key=$3

	toc1_item_content=$(readcfg ${toc_cfg} ${field} ${key})
	i=0
	IFS=', ' read -r -a parts <<< $toc1_item_content
	for part in "${parts[@]}"; do
		if [ $(($i % 3)) -eq 0 ]; then
			name[counts]=$part
		elif [ $(($i % 3)) -eq 1 ]; then
			bin[counts]=$part
		else
			cert[counts]=$part
			counts=$((counts + 1))
		fi
		i=$((i + 1))
	done
}

function create_toc0()
{
	local toc_cfg=$1
	local key=""
	local cert_type=""
	local key_type=""
	local psck_mode=""

	rm -rf toc0

	if [ ! -d "toc0" ]; then
		mkdir -p toc0
	fi

	if [ ! -d "temp" ]; then
		mkdir -p temp
	fi

	get_item_from_cfg ${toc_cfg} toc0 item

	key=$(readcfg ${toc_cfg} key_toc0 ${name[0]})
	cert_type=$(readcfg ${toc_cfg} cert_type cert_type_toc0)
	key_type=$(readcfg ${toc_cfg} key_para key_toc0 | cut -c 1-3)
	if [ x${key_type} == "xrsa" ]; then
		psck_mode=RSA-PKCS
	elif [ x${key_type} == "xecc" ]; then
		psck_mode=ECDSA
	else
		pack_error "key_toc0 type error"
		exit 1
	fi

	#gen sboot hash
	dragon_securetool hash --mode 256 --in ${bin[0]} --out ./temp/${bin[0]}.hash.out
	if [ $? -ne 0 ]
	then
		pack_error "gen sboot hash error"
		exit 1
	fi

	#req no sign cert, ext is sboot_hash; use pubkey
	dragon_securetool req_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --ext ./temp/${bin[0]}.hash.out --out ./temp/${name[0]}.req
	if [ $? -ne 0 ]
	then
		pack_error "req no sign cert for toc0 error"
		exit 1
	fi

	#gen no sign cert hash, witch is to be signed
	dragon_securetool hash --mode 256 --type ${cert_type} --in ./temp/${name[0]}.req --out ./temp/${name[0]}.req.hash
	if [ $? -ne 0 ]
	then
		pack_error "gen no sign cert hash for toc0 error"
		exit 1
	fi

	#sign cert(to be signed) hash
	if [ "x$SOFTHSM_FLAG" == "x1" ]; then
		local id=$(echo "$key" | md5sum | awk '{print $1}')
		pkcs11-tool --label ${key} --id ${id} -s -p ${PIN} -m ${psck_mode} --module ${MODULES} --input-file ./temp/${name[0]}.req.hash --output-file ./temp/${name[0]}.req.sign
		if [ $? -ne 0 ]
		then
			pack_error "softhsm sign cert(to be signed) hash for toc0 error"
			exit 1
		fi
	else
		dragon_securetool sign --cfg ${toc_cfg} --privatekey ${CFG_KEY_DIR}/${key}.pem --in ./temp/${name[0]}.req.hash --out ./temp/${name[0]}.req.sign
		if [ $? -ne 0 ]
		then
			pack_error "sign cert(to be signed) hash for toc0 error"
			exit 1
		fi
	fi

	#create cert with sign
	dragon_securetool create_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --reqfile ./temp/${name[0]}.req --signfile ./temp/${name[0]}.req.sign --out ./toc0/${cert[0]}
	if [ $? -ne 0 ]
	then
		pack_error "create cert with sign for toc0 error"
		exit 1
	fi

	#create toc0.fex(toc0_head + sboot.crtpt + sboot)
	dragon_securetool create_toc0 --cfg ${toc_cfg} --out ./toc0.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon toc0 run error"
		exit 1
	fi
}

function do_signature_sboot()
{
	local sboot_file=$1;
	local flash_type=$2;

	#dram_param
	if [ -f ${LICHEE_TOOLS_DIR}/pack/pctools/linux/mod_update/update_sboot ]; then
		update_sboot $sboot_file  sys_config.bin  > /dev/null
		if [ $? -ne 0 ]
		then
			pack_error "update sboot run error"
			exit 1
		fi
	fi

	update_chip $sboot_file > /dev/null

	#dragon_toc only load sboot.bin
	[ "$(readlink -f $sboot_file)" != "$(readlink -f sboot.bin)" ] && \
	mv $sboot_file sboot.bin

	#readcfg determines whether the cfg file is legacy or new
	readcfg dragon_toc.cfg key_para key > /dev/null
	if [ $? -ne 0 ]; then
		dragonsecboot -toc0 dragon_toc.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
		if [ $? -ne 0 ]
		then
			pack_error "dragon toc0 run error"
			exit 1
		fi
	else
		create_toc0 dragon_toc.cfg

	fi

	update_toc0  toc0.fex           sys_config.bin
	if [ $? -ne 0 ]
	then
		pack_error "update toc0 run error"
		exit 1
	fi

	[ "$(readlink -f $sboot_file)" != "$(readlink -f sboot.bin)" ] && \
	mv sboot.bin $sboot_file
	if [ -f toc0_$flash_type.fex ]; then
		rm -rf toc0_$flash_type.fex
	fi
	mv toc0.fex toc0_$flash_type.fex
	mv toc0 toc0_$flash_type
}

function do_signature_toc0()
{
	if [ -f sboot.bin ]; then
		do_signature_sboot sboot.bin bak
		mv sboot.bin sboot_bak.bin
	fi

	if [ -f sboot_sdcard.bin ]; then
		if [ -f cardscript.fex ]; then
			sed -i "s/TOC0_00000000000/TOC0_SDCARD00000/g" cardscript.fex
		fi
		do_signature_sboot sboot_sdcard.bin sdcard
	fi

	if [ -f sboot_nand.bin ]; then
		do_signature_sboot sboot_nand.bin nand

	fi

	if [ -f sboot_ufs.bin ]; then
		do_signature_sboot sboot_ufs.bin ufs
	fi

	if [ -f sboot_nor.bin ]; then
		do_signature_sboot sboot_nor.bin nor
	fi

	mv sboot_bak.bin sboot.bin
	mv toc0_bak.fex toc0.fex
	mv toc0_bak toc0
}

function toc1_create_cert_for_per_bin()
{
	local toc_cfg=$1
	local key=""
	local cert_type=""
	local key_type=""
	local psck_mode=""

	cert_type=$(readcfg ${toc_cfg} cert_type cert_type_toc1)
	key_type=$(readcfg ${toc_cfg} key_para key_toc1 | cut -c 1-3)
	if [ x${key_type} == "xrsa" ]; then
		psck_mode=RSA-PKCS
	elif [ x${key_type} == "xecc" ]; then
		psck_mode=ECDSA
	else
		pack_error "key_toc1 type error"
		exit 1
	fi

	for ((count=0; count < counts; count++)); do
		key=$(readcfg ${toc_cfg} key_toc1 ${name[count]})
		#gen ${bin[count]} hash
		dragon_securetool hash --mode 256 --in ${bin[count]} --out temp/${name[count]}_hash.out
		if [ $? -ne 0 ]
		then
			pack_error "gen hash ${name[count]} error"
			exit 1
		fi

		#req no sign cert, ext is sboot_hash; use pubkey
		dragon_securetool req_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/$key.pem.pub --ext temp/${name[count]}_hash.out --out temp/${cert[count]}.req
		if [ $? -ne 0 ]
		then
			pack_error "req no sign cert ${name[count]} error"
			exit 1
		fi

		#gen no sign cert hash, witch is to be signed
		dragon_securetool hash --mode 256 --type ${cert_type} --in temp/${cert[count]}.req --out temp/to_be_signed_${name[count]}_hash.out
		if [ $? -ne 0 ]
		then
			pack_error "gen no sign cert hash ${name[count]} error"
			exit 1
		fi

		#sign cert(to be signed) hash
		if [ "x$SOFTHSM_FLAG" == "x1" ]; then
			local id=$(echo "$key" | md5sum | awk '{print $1}')
			pkcs11-tool --label ${key} --id ${id} -s -p ${PIN} -m ${psck_mode} --module ${MODULES} --input-file temp/to_be_signed_${name[count]}_hash.out --output-file temp/${name[count]}_sign.out
			if [ $? -ne 0 ]
			then
				pack_error "softhsm sign cert(to be signed) hash ${name[count]} error"
				exit 1
			fi
		else
			dragon_securetool sign --cfg ${toc_cfg} --privatekey ${CFG_KEY_DIR}/$key.pem --in temp/to_be_signed_${name[count]}_hash.out --out temp/${name[count]}_sign.out
			if [ $? -ne 0 ]
			then
				pack_error "sign cert(to be signed) hash ${name[count]} error"
				exit 1
			fi
		fi

		#create cert with sign
		dragon_securetool create_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --reqfile temp/${cert[count]}.req --signfile temp/${name[count]}_sign.out --out toc1/cert/${cert[count]}
		if [ $? -ne 0 ]
		then
			pack_error "create cert with sign ${name[count]} error"
			exit 1
		fi
	done
}

function toc1_create_cert_for_rootkey()
{
	local toc_cfg=$1
	local key=""
	local cert_type=""
	local key_type=""
	local psck_mode=""

	cert_type=$(readcfg ${toc_cfg} cert_type cert_type_toc1)
	get_item_from_cfg ${toc_cfg} toc1 rootkey
	key=$(readcfg ${toc_cfg} key_toc0 rootkey)
	key_type=$(readcfg ${toc_cfg} key_para key_toc0 | cut -c 1-3)
	if [ x${key_type} == "xrsa" ]; then
		psck_mode=RSA-PKCS
	elif [ x${key_type} == "xecc" ]; then
		psck_mode=ECDSA
	else
		pack_error "key_toc0 type error"
		exit 1
	fi

	#rootkey no sign cert
	#req no sign rootkey cert, insert extensions in the dragon_toc.cfg; use pubkey
	dragon_securetool req_rootkey_cert --type ${cert_type} --cfg ${toc_cfg} --keypath ${CFG_KEY_DIR} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub
	if [ $? -ne 0 ]
	then
		pack_error "req rootkey cert error"
		exit 1
	fi

	mv toc1/cert/${cert[0]} temp/${cert[0]}.req
	#gen no sign rootkey cert hash, witch is to be signed; Non-x509 certificates do not need to skip 4 bytes
	dragon_securetool hash --mode 256 --type ${cert_type} --in temp/${cert[0]}.req --out temp/to_be_signed_${name[0]}_hash.out
	if [ $? -ne 0 ]
	then
		pack_error "gen no sign rootkey cert hash error"
		exit 1
	fi

	#sign rootkey cert(to be signed) hash
	if [ "x$SOFTHSM_FLAG" == "x1" ]; then
		local id=$(echo "$key" | md5sum | awk '{print $1}')
		pkcs11-tool --label ${key} --id ${id} -s -p ${PIN} -m ${psck_mode} --module ${MODULES} --input-file temp/to_be_signed_${name[0]}_hash.out --output-file temp/${name[0]}_sign.out
		if [ $? -ne 0 ]
		then
			pack_error "softhsm sign rootkey cert(to be signed) hash error"
			exit 1
		fi
	else
		dragon_securetool sign --cfg ${toc_cfg} --privatekey ${CFG_KEY_DIR}/${key}.pem --in temp/to_be_signed_${name[0]}_hash.out --out temp/${name[0]}_sign.out
		if [ $? -ne 0 ]
		then
			pack_error "sign rootkey cert(to be signed) hash error"
			exit 1
		fi
	fi

	#create rootkey cert with sign
	dragon_securetool create_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --reqfile temp/${cert[0]}.req --signfile temp/${name[0]}_sign.out --out toc1/cert/${cert[0]}
	if [ $? -ne 0 ]
	then
		pack_error "create rootkey cert with sign error"
		exit 1
	fi
}

function do_signature_toc1()
{
	rm -rf toc1

	if [ ! -d "toc1/cert" ]; then
		mkdir -p toc1/cert
	fi

	if [ ! -d "temp" ]; then
		mkdir -p temp
	fi

	#create cert for toc1 item
	get_item_from_cfg dragon_toc.cfg toc1 item
	toc1_create_cert_for_per_bin dragon_toc.cfg

	#create cert for toc1 onlykey
	get_item_from_cfg dragon_toc.cfg toc1 onlykey
	toc1_create_cert_for_per_bin dragon_toc.cfg

	toc1_create_cert_for_rootkey dragon_toc.cfg

	#create toc1.fex(toc1_head + rootkey.crtpt + ..)
	dragon_securetool create_toc1 --cfg dragon_toc.cfg --out toc1.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon toc1 run error"
		exit 1
	fi
}

function do_signature()
{
	printf "prepare for signature by openssl\n"
	if [ ! -d $CFG_KEY_DIR ] ; then
		pack_error "No key exist, please run './build/createkeys' to generate keys first."
		exit 1
	fi
	if [ "x${PACK_SIG}" = "xprev_refurbish" ] ; then
		if [ "x${LICHEE_ARCH}" = "xarm64" ] ; then
			cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_a64_no_secureos.cfg dragon_toc.cfg
		else
			cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_no_secureos.cfg dragon_toc.cfg
		fi
	else
		if [ "x${LICHEE_ARCH}" = "xarm64" ] ; then
			if [ -f ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg ] ; then
				cp -v ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg dragon_toc.cfg
			else
				cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_a64.cfg dragon_toc.cfg
			fi
		else
			if [ -f ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg ] ; then
				cp -v ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg dragon_toc.cfg
			else
				cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc.cfg dragon_toc.cfg
			fi
		fi
	fi
	if [ "x${PACK_NOR}" = "xnor" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/dragon_toc_nor.cfg ${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
	fi

	if [ -f ${CFG_KEY_DIR}/softhsm2.cfg ]; then
		# fix tokendir
		tokendir=$(grep tokendir ${CFG_KEY_DIR}/softhsm2.cfg | awk '{print $3}')
		if [ "x$tokendir" != "x${CFG_KEY_DIR}/.token" ]; then
			sed -i "s#${tokendir}#${CFG_KEY_DIR}/.token#g" ${CFG_KEY_DIR}/softhsm2.cfg
		fi

		PIN=1234
		SOPIN=12345678
		SOFTHSM_TOOLS_DIR=${LICHEE_TOOLS_DIR}/pack/pctools/linux/softhsm
		MODULES=${SOFTHSM_TOOLS_DIR}/lib/softhsm/libsofthsm2.so
		export LD_LIBRARY_PATH=${SOFTHSM_TOOLS_DIR}/lib:${SOFTHSM_TOOLS_DIR}/lib/softhsm:${LIB_LIBRARY_PATH}
		export PATH=${SOFTHSM_TOOLS_DIR}/bin:$PATH
		export SOFTHSM2_CONF=${CFG_KEY_DIR}/softhsm2.cfg

		SOFTHSM_FLAG=1
	fi

	if [ $? -ne 0 ]
	then
		pack_error "dragon toc config file is not exist"
		exit 1
	fi

	rm -f cardscript.fex
	mv cardscript_secure.fex cardscript.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon cardscript_secure.fex file is not exist"
		exit 1
	fi

	if [ ! -f ${LICHEE_PLAT_OUT}/recovery.img ]; then
		printf "recovery img is not exist, remove recovery cert from dragon_toc.cfg\n"
		sed -i '/recovery/d' dragon_toc.cfg > /dev/null
	else
		local recovery_buf=$(grep "recovery" -nr dragon_toc.cfg)
		if [ x"${recovery_buf}" = x"" ]; then
			readcfg dragon_toc.cfg key_para key > /dev/null
				if [ $? -ne 0 ]; then
					sed -i '/^onlykey=boot/a\onlykey=recovery,      recovery.fex,        SCPFirmwareContentCertPK' dragon_toc.cfg
				else
					sed -i '/^boot=/a recovery=NonTrustedFirmwareContentCertPK' dragon_toc.cfg
					sed -i '/^onlykey=boot/a\onlykey=recovery,     recovery.fex,        recovery.crtpt' dragon_toc.cfg
				fi
		fi
	fi

	if [ "x${PACK_VERITY}" = "x${FLAGS_TRUE}" ]; then
		# verity setup for squashfs type filesystem
		if [ x"${PACK_PLATFORM}" = x"openwrt" ] || [ x"${PACK_PLATFORM}" = x"bsp" ] || [ x"${PACK_PLATFORM}" = x"buildroot" ]; then
			rm -rf rootfs.fex
			local link_real_new=$(get_realpath ${LICHEE_PLAT_OUT} ./)

			if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
				cp ${link_real_new}/rootfs.img		rootfs.fex
			else
				cp ${link_real_new}/rootfs.squashfs	rootfs.fex
			fi

			if [ "x${PACK_KERN}" == "xlinux-5.4" \
					-o "x${PACK_KERN}" == "xlinux-5.4-ansc" \
					-o "x${PACK_KERN}" == "xlinux-5.10" \
					-o "x${PACK_KERN}" == "xlinux-5.10-origin" \
					-o "x${PACK_KERN}" == "xlinux-5.15" \
					-o "x${PACK_KERN}" == "xlinux-5.15-origin" ]; then

				squashfs_real_size=`hexdump -s 0x28 -n 4 -e '/4 "%d"' rootfs.fex`
				squashfs_data_blocks=`expr \( ${squashfs_real_size} + 4095 \) / 4096`

				local TEMP=${LC_ALL}
				export LC_ALL=C

				veritysetup --data-blocks=${squashfs_data_blocks} format rootfs.fex hash_tree > raw_table

				export LC_ALL=${TEMP}

				readcfg dragon_toc.cfg key_para key > /dev/null
				if [ $? -ne 0 ]; then
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          hash_tree,        SCPFirmwareContentCertPK' dragon_toc.cfg
				else
					sed -i '/^boot=/a rootfs=NonTrustedFirmwareContentCertPK' dragon_toc.cfg
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          hash_tree,        rootfs.crtpt' dragon_toc.cfg
				fi
			else
				# get sample from squashfs rootfs
				local rootfs_per_MB=`grep "^rootfs_per_MB=" env.cfg | awk -F = '{printf $2}'`
				if [ -z $rootfs_per_MB ]; then
					echo "rootfs_per_MB is not defined in env.cfg, use default value 4096"
					rootfs_per_MB=4096
				fi

				extract_squashfs $rootfs_per_MB rootfs.fex rootfs-extract.fex
				if [ $? -ne 0 ]; then
					echo "extract squashfs error"
					exit 1;
				fi

				readcfg dragon_toc.cfg key_para key > /dev/null
				if [ $? -ne 0 ]; then
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          rootfs-extract.fex,        SCPFirmwareContentCertPK' dragon_toc.cfg
				else
					sed -i '/^boot=/a rootfs=NonTrustedFirmwareContentCertPK' dragon_toc.cfg
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          rootfs-extract.fex,        rootfs.crtpt' dragon_toc.cfg
				fi
			fi
		else
			# generate verity data, suport more different filesystem in the future
			(dmverity_genHashTable rootfs.fex rootfsHashTree.fex rootfsHashTable.fex &&
			openssl dgst -sha256 -binary -sign $CFG_KEY_DIR/SCPFirmwareContentCertPK.pem rootfsHashTable.fex > rootfsHashSign.fex &&
			openssl rsa -in $CFG_KEY_DIR/SCPFirmwareContentCertPK.pem -pubout -out rootfsPubKey.pk &&
			dmverity_genDownloadFile rootfs.fex rootfsHashSign.fex rootfsHashTable.fex rootfsHashTree.fex VerityInfo.fex) ||
			{ pack_error "generate verity data failed"; exit 1; }

			# add partition for verity data
			(add_partition -2 rootfsverityInfo 4096 "VerityInfo.fex" &&
			maybe_busybox unix2dos sys_partition.fex &&
			script  sys_partition.fex > /dev/null) ||
			{ pack_error "add verity info part failed"; exit 1; }

			# add verity tools into ramdisk
			local rootfsPath=`readlink -f rootfs.fex`
			local keyPath=`readlink -f rootfsPubKey.pk`
			local blockSize=`dmverity_determ_blk_size ${rootfsPath}`
			dmverity_deal $blockSize rootfsverityInfo ext4 $keyPath ||
			{ pack_error "deal verity utils failed"; exit 1; }
		fi
	fi

	if [ "x${PACK_SIGNFEL}" = "x${FLAGS_TRUE}" ]; then
		do_signature_fel
	fi

	do_signature_ft

	do_signature_toc0

	#readcfg determines whether the cfg file is legacy or new
	readcfg dragon_toc.cfg key_para key > /dev/null
	if [ $? -ne 0 ]; then
		dragonsecboot -toc1 dragon_toc.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/cnf_base.cnf ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "dragon toc1 run error"
			exit 1
		fi
		cert=".der"
	else
		do_signature_toc1
		cert=".crtpt"
	fi

	sigbootimg --image boot.fex --cert toc1/cert/boot${cert} --output boot_sig.fex
	if [ $? -ne 0 ] ; then
		pack_error "Pack cert to image error"
		exit 1
	else
		mv -f boot_sig.fex boot.fex
	fi

	do_signature_dsp

	do_signature_riscv

	if [ "x${PACK_VERITY}" = "x${FLAGS_TRUE}" ]; then
		if [ x"${PACK_PLATFORM}" = x"openwrt" ] || [ x"${PACK_PLATFORM}" = x"bsp" ] || [ x"${PACK_PLATFORM}" = x"buildroot" ]; then
			if [ "x${PACK_KERN}" == "xlinux-5.4" \
					-o "x${PACK_KERN}" == "xlinux-5.4-ansc" \
					-o "x${PACK_KERN}" == "xlinux-5.10" \
					-o "x${PACK_KERN}" == "xlinux-5.10-origin" \
					-o "x${PACK_KERN}" == "xlinux-5.15" \
					-o "x${PACK_KERN}" == "xlinux-5.15-origin" ]; then
				verity_root_hash_str=`grep "Root hash:" raw_table | awk '{print $3}'`
				verity_salt_str=`grep "Salt:" raw_table | awk '{print $2}'`

				update_squashfs_verity -f rootfs.fex -c toc1/cert/rootfs${cert} -t hash_tree -r ${verity_root_hash_str} -s ${verity_salt_str}
				if [ $? -ne 0 ]; then
					pack_error "add verity block error."
					exit 1
				fi
			else
				update_squashfs rootfs.fex toc1/cert/rootfs${cert}
				if [ $? -ne 0 ]
				then
					pack_error "signature squashfs rootfs error."
					exit 1
				fi
			fi
		fi
	fi

	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	local recovery_path=${link_real}/recovery.img

	if [ -f "$recovery_path" ]; then
		sigbootimg --image recovery.fex --cert toc1/cert/recovery${cert} --output recovery_sig.fex
		if [ $? -ne 0 ] ; then
			pack_error "Pack cert to image error"
			exit 1
		else
			mv -f recovery_sig.fex recovery.fex
		fi
	fi

	echo "secure signature ok!"
}

function do_android_signature()
{
	if [ "x$LINUX_DTBO_FILE" = "x" ]; then
		echo "do not set LINUX_DTBO_FILE"
		line_num=`sed -n -e "/default.dtbo/=" dragon_toc.cfg`
		if [ "x$line_num" != "x" ]; then
			sed -i "$line_num s/^/;/g" dragon_toc.cfg
		fi
	else
		if [ -f $LINUX_DTBO_FILE ]
		then
			sed -i "s/default.dtbo/$LINUX_DTBO_FILE/g" dragon_toc.cfg
		else
			line_num=`sed -n -e "/default.dtbo/=" dragon_toc.cfg`
			if [ "x$line_num" != "x" ]; then
				sed -i "$line_num s/^/;/g" dragon_toc.cfg
			fi
		fi
	fi

	if [ $? -ne 0 ]
	then
		pack_error "dragon toc config file is not exist"
		exit 1
	fi

	rm -f cardscript.fex
	mv cardscript_secure.fex cardscript.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon cardscript_secure.fex file is not exist"
		exit 1
	fi

	do_signature_ft

	do_signature_toc0

	#readcfg determines whether the cfg file is legacy or new
	readcfg dragon_toc.cfg key_para key > /dev/null
	if [ $? -ne 0 ]; then
		dragonsecboot -toc1 dragon_toc.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/cnf_base.cnf ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "dragon toc1 run error"
			exit 1
		fi
		cert=".der"
	else
		do_signature_toc1
		cert=".crtpt"
	fi

	if [ -e dboot.fex ]; then
		local keyname=$(awk -F, '/^[[:space:]]*onlykey=boot\S*,[[:space:]]*dboot.fex,/{print $1}' dragon_toc.cfg  | awk -F= '{print $2}')
		sigbootimg --image dboot.fex --cert toc1/cert/${keyname}${cert} --output dboot_sig.fex
		[ $? -ne 0 ] && pack_error "Pack cert to image error" && exit 1
		mv -f dboot_sig.fex dboot.fex
	fi

	echo "secure android signature ok!"
}

################################ Tina func ################################
function get_partition_downfile_size()
{
    local downloadfile_name=`echo $1 | awk -F '=' '{print $2}'`
    if [ x${downloadfile_name: 0-4} != x".fex" ]; then
        pack_error "downloadfile format is wrong, it should be end with .fex"
        exit -1
    fi
    if [ ! -f ${downloadfile_name} ]; then
        echo "  file ${downloadfile_name} not find"
    else
        if [ -L ${downloadfile_name} ]; then
            local downloadfile_name_link=`readlink -f ${downloadfile_name}`
            local linkfile_name=${downloadfile_name_link##*/}
            echo "  ${downloadfile_name} -> ${downloadfile_name_link}"
            if [ ! -f ${downloadfile_name_link} ]; then
                echo "  link file ${linkfile_name} not find"
            else
                local linkfile_size=`ls -lh ${downloadfile_name_link} | awk '{print $5}'`
                echo "  ${linkfile_name} size : ${linkfile_size} byte"
            fi
        else
            local downloadfile_size=`ls -lh ${downloadfile_name} | awk '{print $5}'`
            echo "  ${downloadfile_name} size : ${downloadfile_size} byte"
        fi
    fi
}

function get_partition_mbr_size()
{
    local partition_size_name=`echo $1 | awk -F '=' '{print $1}' | sed 's/partition/mbr/g'`
    local partition_size=`echo $1 | awk -F '=' '{print $2}'`
    echo "  ${partition_size_name}  : ${partition_size} Kbyte"
}

function show_partition_message()
{
    grep -c '[mbr]' $1 > /dev/null
    if [ $? -eq 0 ]; then
        cp $1 ./show_sys_partition.tmp;
        sed -i '/^[\r;]/d' ./show_sys_partition.tmp;
        sed -i '/partition_start/d' ./show_sys_partition.tmp;
        sed -i '/user_type/d' ./show_sys_partition.tmp;
        sed -i 's/\[partition\]/------------------------------------/g' ./show_sys_partition.tmp;
        sed -i 's/[ "\r]//g' ./show_sys_partition.tmp;
        sed -i '/^[;]/d' ./show_sys_partition.tmp;
        sed -i 's/name/partition_name/g' ./show_sys_partition.tmp;
        sed -i 's/size/partition_size/g' ./show_sys_partition.tmp;
        echo "------------------------------------"
        while read line
        do
            if [ "$line" == "------------------------------------" ];then
                echo "$line"
            else
                echo "  $line" | sed 's/=/  : /g'
                echo "  $line" | grep "mbr" >> /dev/null
                if [ $? -eq 0 ]; then
                    read line
                    get_partition_mbr_size $line
                fi
                echo "$line" | grep "downloadfile" >> /dev/null
                if [ $? -eq 0 ]; then
                    get_partition_downfile_size $line
                fi
            fi
        done < ./show_sys_partition.tmp
        echo "------------------------------------"
        rm ./show_sys_partition.tmp
    else
        echo "==========input is not a partition file=========="
    fi
}

function sparse_ext4()
{
    local img=$1
    local sparse_img=$2

    if file $img | grep -q ext4 ;then
        echo "now make sparse ext4 img: $img"
    else
        echo "$img is not ext4 img"
        file $img
        return
    fi

    img2simg $img $sparse_img
}

# pack user resources to a vfat filesystem
# To use this, please add a folder "user-resource" in configs to save files, and add a partition to sys_partition.fex/sys_partition_nor.fex like this:
# [partition]
#   name         = user-res
#   size         = 1024	//size should be 32 aligned
#   downloadfile = "user-resource.fex"
#   user_type    = 0x8000
function make_user_res()
{
    printf "make user resource for : $1\n"
    local USER_RES_SYS_PARTITION=$1
    local USER_RES_PART_NAME=user-res
    local USER_RES_FILE=user-resource

    printf "handle partition ${USER_RES_PART_NAME}\n"
    local USER_RES_PART_DOWNLOAD_FILE=user-resource.fex
    local USER_RES_PART_SIZE=`sed -n "/${USER_RES_PART_NAME}/{N;p}" ${USER_RES_SYS_PARTITION} | awk '$0~"size"{print $3/2}'`
    local USER_RES_FILE_PATH=$CFG_TOP_DIR/${PACK_PLATFORM}/target/$PACK_IC/$PACK_IC-${PACK_BOARD}/configs/${USER_RES_FILE}

    if [ x"${USER_RES_PART_DOWNLOAD_FILE}" != x"" -a  x"${USER_RES_PART_SIZE}" != x"" ]; then
        rm -f ${LICHEE_PACK_OUT_DIR}/user-resource.fex
        mkfs.vfat ${LICHEE_PACK_OUT_DIR}/user-resource.fex -C ${USER_RES_PART_SIZE}
        if [ -d ${USER_RES_FILE_PATH} ]; then
            USER_RES_FILE_SIZE=`du --apparent-size --summarize "${USER_RES_FILE_PATH}" | awk '{print $1}'`
            printf "file size: ${USER_RES_FILE_SIZE}\n"
            printf "partition size: ${USER_RES_PART_SIZE}\n"
            if [ ${USER_RES_PART_SIZE} -le ${USER_RES_FILE_SIZE} ]; then
                printf "file size is larger than partition size, please check your configuration\n"
                printf "please enlarge size of ${USER_RES_PART_NAME} in sys_partition or remove some files in $USER_RES_FILE_PATH\n"
                exit -1
            fi
            mcopy -s -v -i ${LICHEE_PACK_OUT_DIR}/${USER_RES_PART_DOWNLOAD_FILE} ${USER_RES_FILE_PATH}/* ::
            if [ $? -ne 0 ]; then
                printf "mcopy file fail, exit\n"
                exit -1
            fi
        else
            printf "can not find ${USER_RES_FILE_PATH}, ignore it\n"
        fi
    else
        printf "no user resource partitions\n"
    fi
}

#[partition]
#    name         = app
#    size         = 10080
#    downloadfile = "app.fex"
#    user_type    = 0x8000
function make_app_res()
{
    local APP_PART_NAME=app
    cp $1 sys_partition_tmp_app.fex

    sed -i '/^[ \t]*downloadfile/d' sys_partition_tmp_app.fex
    maybe_busybox unix2dos sys_partition_tmp_app.fex
    script  sys_partition_tmp_app.fex > /dev/null
    update_mbr sys_partition_tmp_app.bin 1 sunxi_mbr_tmp_app.fex > /dev/null

    local APP_PART_DOWNLOAD_FILE=app.fex
    local APP_PART_FILE_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/build_dir/target/app
    local APP_PART_SIZE_IN_SECTOR=`parser_mbr sunxi_mbr_tmp_app.fex get_size_by_name ${APP_PART_NAME}`
	local TINA_TOOLS_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/staging_dir/host/bin

    if [ x${APP_PART_DOWNLOAD_FILE} != x'' -a  x${APP_PART_SIZE_IN_SECTOR} != x'' ]; then
        let APP_PART_SIZE_IN_K=$APP_PART_SIZE_IN_SECTOR/2
        echo "APP_PART_DOWNLOAD_FILE = ${LICHEE_PACK_OUT_DIR}/${APP_PART_DOWNLOAD_FILE}"
        rm -f ${LICHEE_PACK_OUT_DIR}/${APP_PART_DOWNLOAD_FILE}
        ${TINA_TOOLS_PATH}/make_ext4fs -l ${APP_PART_SIZE_IN_K}k -b 1024 -m 0 -j 1024 ${LICHEE_PACK_OUT_DIR}/${APP_PART_DOWNLOAD_FILE}  ${APP_PART_FILE_PATH}
    else
        printf "no app resource partitions\n"
    fi
}

#[partition]
#    name         = data
#    size         = 10080
#    downloadfile = "data.fex"
#    user_type    = 0x8000
function make_data_res()
{
    local DATA_PART_NAME=data
    cp $1 sys_partition_tmp_data.fex

    sed -i '/^[ \t]*downloadfile/d' sys_partition_tmp_data.fex
    maybe_busybox unix2dos sys_partition_tmp_data.fex
    script  sys_partition_tmp_data.fex > /dev/null
    update_mbr sys_partition_tmp_data.bin 1 sunxi_mbr_tmp_data.fex > /dev/null

    local DATA_PART_DOWNLOAD_FILE=data.fex
    local DATA_PART_DOWNLOAD_FILE_SPARSE=data_s.fex
    local DATA_PART_FILE_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/build_dir/target/data
    local DATA_PART_SIZE_IN_SECTOR=`parser_mbr sunxi_mbr_tmp_data.fex get_size_by_name ${DATA_PART_NAME}`
	local TINA_TOOLS_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/staging_dir/host/bin

    if [ x${DATA_PART_DOWNLOAD_FILE} != x'' -a  x${DATA_PART_SIZE_IN_SECTOR} != x'0' ]; then
        let DATA_PART_SIZE_IN_K=$DATA_PART_SIZE_IN_SECTOR/2
        echo "DATA_PART_DOWNLOAD_FILE = ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE}"
        rm -f ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE}
        rm -f ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE_SPARSE}
        ${TINA_TOOLS_PATH}/make_ext4fs -l ${DATA_PART_SIZE_IN_K}k -b 1024 -m 0 -j 1024 ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE}  ${DATA_PART_FILE_PATH}
        sparse_ext4 ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE} ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE_SPARSE}
    else
        printf "no data resource partitions\n"
    fi
}

################################ Platform func ################################
function do_pack_android()
{
	local localpath=$(readlink -f $(pwd))
	local androidout=$(readlink -f ${ANDROID_IMAGE_OUT})
	local link_real=$(get_realpath $androidout $localpath)

	printf "packing for android\n"

	if [ -z "${ANDROID_IMAGE_OUT}" ] ; then
		pack_error "please specify ANDROID_IMAGE_OUT env"
		exit 1
	fi

	local fex_list=($(\gawk '$0~"^[[:space:]]*downloadfile[[:space:]]*="{print $NF}' sys_partition.fex | sed 's/[",\r,\n]//g'))
	fex_list+=(vendor_boot-debug.fex)

	local img_name=""
	for fex_name in ${fex_list[@]}; do
		img_name=${fex_name%\.fex}.img
		if [ -f ${ANDROID_IMAGE_OUT}/${img_name} ]; then
			ln -sf ${link_real}/${img_name} ${fex_name}
			echo "link ${img_name} -> ${fex_name}"
		fi
	done

	if [ -e $androidout/vmlinux ]; then
		export PATH=$PATH:${LICHEE_TOP_DIR}/build/bin
		local vmlinuxpath=$(dirname $(readlink -f $androidout/vmlinux))
		local vmlinuxname=$(basename $(readlink -f $androidout/vmlinux))
		(cd $vmlinuxpath && tar cf $localpath/vmlinux.tar.bz2 --use-compress-prog=lbzip2 $vmlinuxname)
		rm -rf vmlinux.fex
		ln -sf vmlinux.tar.bz2 vmlinux.fex
	fi

	if [ -n "${PACK_BOOT_PATH}" ] && [ "x${PACK_BOOT_PATH}" != "xnone" ]; then
		ln -sf $PACK_BOOT_PATH boot.fex
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		echo "secure"
		do_android_signature
	else
		echo "normal"
	fi
}

function prepare_mixed_androiddragonboard()
{
	local mixed_fw_type

	if [ "${PACK_TYPE}" != "android" ] || [ -z "$PACK_MIXED_FIRMWARE" ]; then
		return 0
	fi

	case "$PACK_MIXED_FIRMWARE" in
		dragonboard|dragonabts)
			mixed_fw_type="$PACK_MIXED_FIRMWARE"
			pack_info "${FUNCNAME[0]}: mixed firmware type: $mixed_fw_type"
			;;
		*)
			echo "Unsupport mixed firmware type: $PACK_MIXED_FIRMWARE"
			return 1
	esac

	(
		cd ${LICHEE_PACK_OUT_DIR}

		local localpath=$(readlink -f $(pwd))
		local mixedboardout=$(readlink -f ${CFG_PLAT_OUT}/../$mixed_fw_type)
		if [ ! -d $mixedboardout ]; then
			pack_error "${FUNCNAME[0]}: cannot find out path for $mixed_fw_type"
			exit 1
		fi

		local envpath=($LICHEE_BOARD_CONFIG_DIR/$mixed_fw_type $LICHEE_CHIP_CONFIG_DIR/configs/default)
		local partition=(bootloader_b:boot-resource.fex env_b:denv.fex
					boot_b:dboot.fex vendor_boot_b:vendor_boot.fex media_data)

		local item name linenum nstart nend nmax file

		for item in ${partition[@]}; do
			name=${item/:*}
			linenum=$(sed -n "/^\s*name\s*=\s*$name/=" sys_partition.fex)
			if [ -z "$linenum" ]; then
				pack_error "${FUNCNAME[@]}: leak neccery partition $name in sys_partition.fex"
				exit 1
			fi
		done

		for item in ${envpath[@]}; do
			if [ -e $item/env.cfg ]; then
				cp $item/env.cfg denv.cfg
				sed -i '/^\s*boot_normal=/s/\<boot\>/boot_b/g' denv.cfg
				generate_env_for_uboot denv.cfg $mixedboardout/env.img
				rm -rf denv.cfg
				break
			fi
		done

		if  [ ! -e $mixedboardout/env.img  ] || \
			[ ! -e $mixedboardout/boot.img ] || \
			[ ! -e $mixedboardout/rootfs.ext4 ] || \
			[ ! -e $LICHEE_BOARD_CONFIG_DIR/$mixed_fw_type/test_config.fex ]; then
			pack_error "${FUNCNAME[@]}: leak neccery img/fex for $mixed_fw_type"
			exit 1
		fi

		printf "prepare for mixed android/$mixed_fw_type packing...\n"
		for item in ${partition[@]}; do
			name=${item/:*}
			linenum=$(sed -n "/^\s*name\s*=\s*$name/=" sys_partition.fex)
			nstart=$linenum
			nend=$linenum
			nmax=$(wc -l sys_partition.fex | awk '{print $1}')
			while [ $nstart -gt 1 ]; do
				nstart=$((nstart-1))
				if [ -n "$(sed -n "$nstart p" sys_partition.fex | grep "^\s*\[\S\+\]")" ]; then
					break;
				fi
			done

			while [ $nend -lt $nmax ]; do
				nend=$((nend+1))
				if [ -n "$(sed -n "$nend p" sys_partition.fex | grep "^\s*\[\S\+\]")" ]; then
					break;
				fi
			done
			[ $nend -ne $nmax ] && nend=$((nend-1))

			file="$(sed -n "${nstart},${nend}p" sys_partition.fex | \
					awk -F= '/^[[:space:]]*downloadfile[[:space:]]*=/{print $2}')"
			dlfile=${e#*:}
			case $name in
				bootloader_b|env_b|boot_b|vendor_boot_b)
					if [ -z "$file" ]; then
						sed -i "$linenum a\ \ \ \ downloadfile = \"${item#*:}\"" sys_partition.fex
					fi
					;;
				media_data)
					local cmd="$nstart i"
					local size=$(stat $mixedboardout/rootfs.ext4 --format="%s")

					size=$(((size+32*1024*1024-1)/(16*1024*1024)*16))  # at least size + 16M, and 16M align

					if [ -z "$(grep "^\s*name\s*=\s*rootfs" sys_partition.fex)" ]; then
						cmd+="[partition]\n"
						cmd+="    name         = rootfs\n"
						cmd+="    size         = ${size}M\n"
						cmd+="    downloadfile = \"drootfs.fex\"\n"
						cmd+="    user_type    = 0x8000\n"
						cmd+="\n"
					fi
					[ "$cmd" != "$nstart i" ] && sed -i "$cmd" sys_partition.fex
					;;
			esac
		done

		# Delete "^M" under Windows
		sed -i 's|
||g' sys_partition.fex

		readcfg dragon_toc.cfg key_para key > /dev/null
		if [ $? -ne 0 ]; then
			[ -z "$(grep "^\s*onlykey=boot_b,\s*dboot.fex," dragon_toc.cfg)" ] && \
			sed -i 's|^\(\s*onlykey=boot_b,\s*\)\S*,|\1dboot.fex,|g'    dragon_toc.cfg

			[ -z "$(grep "^\s*onlykey=boot_b,\s*dboot.fex," dragon_toc.cfg)" ] && \
			echo "onlykey=boot_b,dboot.fex,SCPFirmwareContentCertPK" >> dragon_toc.cfg
		else
			if [ -z "$(grep "^\s*onlykey=boot_b,\s*dboot.fex," dragon_toc.cfg)" ]; then
				sed -i '/^optee=/a boot_b=SCPFirmwareContentCertPK' dragon_toc.cfg
				sed -i '/^item=optee/a\onlykey=boot_b,dboot.fex,boot_b.crtpt' dragon_toc.cfg
			fi
		fi

		cp $LICHEE_BOARD_CONFIG_DIR/$mixed_fw_type/test_config.fex .
		maybe_busybox dos2unix test_config.fex
		cp test_config.fex boot-resource/
		script test_config.fex > /dev/null
		cp test_config.bin boot-resource/

		cp $mixedboardout/env.img denv.fex
		cp $mixedboardout/boot.img dboot.fex
		cp $mixedboardout/rootfs.ext4 drootfs.fex
		echo "android:$PACK_MIXED_FIRMWARE" > mixed-image-type.txt
	)
	if [ $? -ne 0 ]; then
		pack_error "${FUNCNAME[0]} fail"
		return 1
	fi
	return 0
}

function do_pack_dragonboard()
{
	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	printf "packing for dragonboard\n"

	ln -sf ${link_real}/boot.img boot.fex
	ln -sf ${link_real}/rootfs.ext4 rootfs.fex
	ln -sf ${link_real}/rootfs.ubifs rootfs-ubifs.fex

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		do_signature
	else
		echo "normal"
	fi
}

function do_pack_dragonabts()
{
	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	printf "packing for dragonabts\n"

	ln -sf ${link_real}/boot.img boot.fex
	ln -sf ${link_real}/rootfs.ext4 rootfs.fex
	ln -sf ${link_real}/rootfs.ubifs rootfs-ubifs.fex

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		do_signature
	else
		echo "normal"
	fi
}

function do_pack_linux()
{
	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	local recovery_path=${link_real}/recovery.img

	printf "packing for linux\n"

	do_fit_image
	if [ $? -eq 0 ]; then
		[ -f kernel.itb ] && mv kernel.itb   kernel.fex
		[ -f kernel-dtb.itb ] && mv kernel-dtb.itb   kernel-dtb.fex
	else
		[ -f ${link_real}/bootB.img ] && ln -sf ${link_real}/bootB.img bootB.fex
		ln -sf ${link_real}/boot.img        boot.fex

		# Those files is ready for SPINor.
		ln -sf ${link_real}/uImage          kernel.fex
		if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
			ln -sf ${link_real}/rootfs.img rootfs_nor.fex
		else
			ln -sf ${link_real}/rootfs.squashfs rootfs_nor.fex
		fi
	fi

	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		ln -sf ${link_real}/rootfs.img     rootfs.fex
	else
		ln -sf ${link_real}/rootfs.ext4     rootfs.fex
	fi

	ln -sf ${link_real}/rootfs.ubifs     rootfs-ubifs.fex

	if [ -f "$recovery_path" ]; then
		ln -sf ${recovery_path}     recovery.fex
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		echo "secure"
		do_signature
	else
		echo "normal"
	fi
}

function create_kernel_fit_image()
{
	local its_name=$1

	printf "create_kernel_fit_image\n"

	if [ ! -f ${LICHEE_PACK_OUT_DIR}/${its_name}.its ]; then
		printf "can not found ${its_name}.its\n"
		return 1
	fi

	mkimage -f ${its_name}.its ${its_name}.itb
	if [ $? -ne 0 ]; then
		pack_error "mkimage ${its_name}.itb error\n"
		exit 1
	fi
}

function do_fit_image()
{
	printf "do_fit_image\n"

	create_kernel_fit_image kernel
	if [ $? -ne 0 ]; then
		return 1
	fi

	create_kernel_fit_image kernel-dtb
	if [ $? -ne 0 ]; then
		return 1
	fi
}

function main()
{
	local output_resources=${FLAGS_output_resources:-false}
	local from_resources=${FLAGS_from_resources}

	local support_secure_type
	case x$LICHEE_PACK_SECURE_TYPE in
		xnone|xsecure|xany)
			support_secure_type=$LICHEE_PACK_SECURE_TYPE
			;;
		x)
			support_secure_type=any
			;;
		*)
			pack_error "Unsupport pack secure type: $LICHEE_PACK_SECURE_TYPE"
			return 1
			;;
	esac

	if [ "$support_secure_type" != "any" ] && [ "$support_secure_type" != "$PACK_SECURE" ]; then
		pack_error "This platform only support secure type [$support_secure_type], but current using [$PACK_SECURE], please check!!!"
		pack_error "Now, we try using secure type [$support_secure_type]!!!"
		PACK_SECURE=$support_secure_type
	fi

	if [ "$output_resources" == "false" ] && [ -z "$from_resources" ]; then
		do_prepare
		do_ini_to_dts
		do_common
		do_pack_${PACK_TYPE}
		do_finish
		return $?
	fi

	if [ "$output_resources" == "true" ]; then
		do_prepare
		do_ini_to_dts
	elif [ -n "$from_resources" ]; then
		if [ ! -d $from_resources ]; then
			pack_error "Cannot find resources path: $from_resources"
			return 1
		fi

		local count=0
		while [ -e ${LICHEE_PACK_OUT_DIR} -a  $count -lt 20 ]; do
			rm -rf ${LICHEE_PACK_OUT_DIR}
			count=$((count+1))
		done
		cp -rax $from_resources ${LICHEE_PACK_OUT_DIR}
		(
			cd $LICHEE_OUT_DIR
			if [ "${LICHEE_PACK_OUT_DIR}" != "$LICHEE_OUT_DIR/pack_out" ]; then
				rm -rf pack_out
				ln -sf ${LICHEE_IC}/${LICHEE_BOARD}/pack_out pack_out
			fi
		)

		if [ "${PACK_PLATFORM}" == "android" ] && [ -n "$PACK_MIXED_FIRMWARE" ]; then
			local resource_type="$(cat ${LICHEE_PACK_OUT_DIR}/mixed-image-type.txt)"
			local mixed_fw_type="android:$PACK_MIXED_FIRMWARE"
			if [ "$resource_type" != "android:$PACK_MIXED_FIRMWARE" ]; then
				pack_error "mixed firmware type [$mixed_fw_type] but resource type [$resource_type]"
				exit 1
			fi
			pack_info "mixed firmware type [$mixed_fw_type]"
		fi

		cd ${LICHEE_PACK_OUT_DIR}
		do_common
		do_pack_${PACK_TYPE}
		do_finish
	fi
	return $?
}

main "$@"

longan/build/pack 修改后:

#!/bin/bash
#
# pack/pack
# (c) Copyright 2013
# Allwinner Technology Co., Ltd. <www.allwinnertech.com>
# James Deng <csjamesdeng@allwinnertech.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

############################ Notice #####################################
# a. Some config files priority is as follows:
#    - xxx_${platform}.{cfg|fex} > xxx.{cfg|fex}
#    - ${chip}/${board}/*.{cfg|fex} > ${chip}/default/*.{cfg|fex}
#    - ${chip}/default/*.cfg > ${LICHEE_COMMON_CONFIG_DIR}/imagecfg/*.cfg
#    - ${chip}/default/*.fex > ${LICHEE_COMMON_CONFIG_DIR}/partition/*.fex
#  e.g. sun8iw7p1/configs/perf/image_linux.cfg > sun8iw7p1/configs/default/image_linux.cfg
#       > ${LICHEE_COMMON_CONFIG_DIR}/imagecfg/image_linux.cfg > sun8iw7p1/configs/perf/image.cfg
#       > sun8iw7p1/configs/default/image.cfg > ${LICHEE_COMMON_CONFIG_DIR}/imagecfg/image.cfg
#
# b. Support Nor storages rule:
#    - Need to create sys_partition_nor.fex or sys_partition_nor_${platform}.fex
#    - Add "{filename = "full_img.fex",     maintype = "12345678", \
#      subtype = "FULLIMG_00000000",}" to image[_${platform}].cfg
#
# c. Switch uart port
#    - Need to add your chip configs into ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin
#    - Call pack with 'debug' parameters

#if you want to debug pack, set vlaue to 1. use pause func in the place where you want to stop
enable_pause=0

function get_char()
{
	SAVEDSTTY=`stty -g`
	stty -echo
	stty cbreak
	dd if=/dev/tty bs=1 count=1 2> /dev/null
	stty -raw
	stty echo
	stty $SAVEDSTTY
}

function pause()
{
	if [ "x$1" != "x" ] ;then
		echo "$1"
	fi
	if [ $enable_pause -eq 1 ] ; then
		echo "Press any key to continue!"
		char=`get_char`
	fi
}

function pack_error()
{
	echo -e "\033[47;31mERROR: $*\033[0m"
}

function pack_warn()
{
	echo -e "\033[47;34mWARN: $*\033[0m"
}

function pack_info()
{
	echo -e "\033[47;30mINFO: $*\033[0m"
}

localpath=$(cd $(dirname $0) && pwd)
. $localpath/shflags

# define option, format:
#   'long option' 'default value' 'help message' 'short option'
DEFINE_string 'chip' '' 'chip to build, e.g. sun7i' 'c'
DEFINE_string 'ic' '' 'ic to build, e.g. a50' 'i'
DEFINE_string 'addition' '' 'additional config files, e.g. xx.fex' 'a'
DEFINE_string 'platform' '' 'platform to build, e.g. linux, android' 'p'
DEFINE_string 'platform_version' '' 'platform version to build' 'V'
DEFINE_string 'board' '' 'board to build, e.g. evb' 'b'
DEFINE_string 'kernel' '' 'kernel to build, e.g. linux-3.4, linux-3.10' 'k'
DEFINE_string 'debug_mode' 'uart0' 'config debug mode, e.g. uart0, card0' 'd'
DEFINE_string 'signture' 'none' 'pack boot signture to do secure boot' 's'
DEFINE_string 'secure' 'none' 'pack secure boot with -v arg' 'v'
DEFINE_string 'mode' 'normal' 'pack dump firmware' 'm'
DEFINE_string 'function' 'android' 'pack private firmware' 'f'
DEFINE_string 'vsp' '' 'pack firmware for vsp' 't'
DEFINE_string 'programmer' '' 'creat programmer img or not' 'w'
DEFINE_string 'key_path' '' 'the path of keys' 'P'
DEFINE_string 'nor' 'none' 'pack nor image' 'n'
DEFINE_boolean 'verity' false 'if enable dm-verity' ''
DEFINE_boolean 'signfel' false 'if enable fel signing' ''
DEFINE_string 'boot_path' '' 'the path of gki boot.img' 'B'
DEFINE_string 'output_resources' '' 'only output resources to pack-out' ''
DEFINE_string 'from_resources' '' 'pack from resources path' ''

# parse the command-line
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"

PACK_CHIP=${FLAGS_chip}
PACK_IC=${FLAGS_ic}
PACK_PLATFORM=${FLAGS_platform}
PACK_PLATFORM_VERSION=${FLAGS_platform_version}
PACK_BOARD=${FLAGS_board}
PACK_KERN=${FLAGS_kernel}
PACK_DEBUG=${FLAGS_debug_mode}
PACK_SIG=${FLAGS_signture}
PACK_SECURE=${FLAGS_secure}
PACK_MODE=${FLAGS_mode}
PACK_FUNC=${FLAGS_function}
PACK_VSP=${FLAGS_vsp}
PACK_PROGRAMMER=${FLAGS_programmer}
PACK_NOR=${FLAGS_nor}
PACK_PRODUCT=${FLAGS_product}
PACK_VERITY=${FLAGS_verity}
PACK_SIGNFEL=${FLAGS_signfel}
PACK_ADD_FILES=(${FLAGS_addition})
PACK_KEY_PATH=${FLAGS_key_path}
PACK_BOOT_PATH=${FLAGS_boot_path}

CFG_TOP_DIR=$(cd $localpath/../ && pwd)
CFG_PLAT_OUT=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM
CFG_KEY_DIR=$CFG_TOP_DIR/out/$PACK_IC/common/keys

if [ ! -z "${PACK_KEY_PATH}" ]; then
    CFG_KEY_DIR=${PACK_KEY_PATH}
fi
pack_info "${CFG_KEY_DIR}"

if [ ! -d ${CFG_PLAT_OUT} ] || \
   [ ! -f $CFG_PLAT_OUT/.buildconfig ]; then
	pack_error "config & build lichee before you pack"
	exit 1
fi

source $CFG_PLAT_OUT/.buildconfig

if [ -z "${PACK_KERN}" ]; then
	pack_info "No kernel param, parse it from .buildconfig"
	PACK_KERN=$LICHEE_KERN_VER
	if [ -z "${PACK_KERN}" ]; then
		pack_error "Failed to parse kernel param from .buildconfig"
		exit 1
	fi
fi

PACK_TYPE=""
case "x${PACK_PLATFORM}" in
	"xandroid")
		PACK_TYPE="android"
		;;
	"xdragonboard")
		PACK_TYPE="dragonboard"
		;;
	"xdragonabts")
		PACK_TYPE="dragonabts"
		;;
	"xbsp"|"xsata"|"xbuildroot"|"xopenwrt"|"xdebian")
		PACK_TYPE="linux"
		;;
	*)
		pack_error "Unsupport PACK_PLATFORM: ${PACK_PLATFORM}"
		exit 1
		;;
esac

export PATH=${LICHEE_TOOLS_DIR}/pack/pctools/linux/mod_update:${LICHEE_TOOLS_DIR}/pack/pctools/linux/openssl:${LICHEE_TOOLS_DIR}/pack/pctools/linux/eDragonEx:${LICHEE_TOOLS_DIR}/pack/pctools/linux/fsbuild200:${LICHEE_TOOLS_DIR}/pack/pctools/linux/android:$PATH
export LD_LIBRARY_PATH=${LICHEE_TOOLS_DIR}/pack/pctools/linux/softhsm/lib/:$LD_LIBRARY_PATH

tools_file_list=(
${LICHEE_COMMON_CONFIG_DIR}/tools/split_xxxx.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/split_xxxx.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool_test.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool_crash.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/usbtool_test.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript_secure.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/cardscript.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/cardscript_secure.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/cardtool.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/cardtool.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/usbtool.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool_crash.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/usbtool_crash.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/aultls32.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/aultls32.fex
${LICHEE_COMMON_CONFIG_DIR}/tools/aultools.fex
${LICHEE_CHIP_CONFIG_DIR}/tools/aultools.fex
)

configs_file_list=(
${LICHEE_COMMON_CONFIG_DIR}/toc/toc1.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_sdcard.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_nand.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_ufs.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/toc0_ft.fex
${LICHEE_COMMON_CONFIG_DIR}/toc/boot_package.fex
${LICHEE_COMMON_CONFIG_DIR}/hdcp/esm.fex
${LICHEE_COMMON_CONFIG_DIR}/dtb/sunxi.fex
${LICHEE_COMMON_CONFIG_DIR}/imagecfg/*.cfg
${LICHEE_COMMON_CONFIG_DIR}/partition/sys_partition_dump.fex
${LICHEE_COMMON_CONFIG_DIR}/partition/sys_partition_private.fex
${LICHEE_COMMON_CONFIG_DIR}/version/version_base.mk
${LICHEE_CHIP_CONFIG_DIR}/configs/default/*
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/*.fex
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/boot_package*.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${LICHEE_KERN_VER}/*.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/version_base.mk
${LICHEE_CHIP_CONFIG_DIR}/dtbo/*
${LICHEE_BOARD_CONFIG_DIR}/dtbo/*
${LICHEE_CHIP_CONFIG_DIR}/${BIN_PATH}/ft_${PACK_CHIP}.bin
${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_ft.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc_ft.cfg
${LICHEE_COMMON_CONFIG_DIR}/sign_config/cnf_base.cnf
${LICHEE_PLAT_OUT}/.buildconfig
)

product_configs_file_list=(
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${PACK_PLATFORM}/*.fex
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${PACK_PLATFORM}/*.cfg
)

boot_resource_list=(
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource:${LICHEE_PACK_OUT_DIR}
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource.ini:${LICHEE_PACK_OUT_DIR}
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/*.bmp:${LICHEE_PACK_OUT_DIR}/boot-resource/
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/bootlogo.bmp:${LICHEE_PACK_OUT_DIR}/bootlogo.bmp
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/wavefile/*:${LICHEE_PACK_OUT_DIR}/boot-resource/wavefile/
${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${PACK_TYPE}/*.bmp:${LICHEE_PACK_OUT_DIR}/boot-resource/
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource/bat/bempty.bmp:${LICHEE_PACK_OUT_DIR}/bempty.bmp
${LICHEE_CHIP_CONFIG_DIR}/boot-resource/boot-resource/bat/battery_charge.bmp:${LICHEE_PACK_OUT_DIR}/battery_charge.bmp
)
#${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_nand.fex
#${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
#${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_ufs.fex
#${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_${LICHEE_BOOT0_BIN_NAME}_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex
#${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_nandfastboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_nandfastboot_${PACK_CHIP}.fex
#${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/boot0_spinor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_spinor.fex
boot_file_list=(
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/fes1_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/fes1_uart_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1_uart.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-${LICHEE_EFEX_BIN_NAME}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-${LICHEE_EFEX_BIN_NAME}.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-crashdump-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-crash.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-crashdump-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-crash.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/bl31.bin:${LICHEE_PACK_OUT_DIR}/monitor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/bl31_${PACK_BOARD}.bin:${LICHEE_PACK_OUT_DIR}/monitor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/scp.bin:${LICHEE_PACK_OUT_DIR}/scp.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_dsp0.bin:${LICHEE_PACK_OUT_DIR}/amp_dsp0.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_dsp1.bin:${LICHEE_PACK_OUT_DIR}/amp_dsp1.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_arm64.bin:${LICHEE_PACK_OUT_DIR}/amp_arm64.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_rv0.bin:${LICHEE_PACK_OUT_DIR}/amp_rv0.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/video.bin:${LICHEE_PACK_OUT_DIR}/video.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/optee.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}-monitor.bin:${LICHEE_PACK_OUT_DIR}/optee-monitor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/opensbi_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/opensbi.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/u-boot-spinor-secure-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-secure.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/*.fex:${LICHEE_PACK_OUT_DIR}/
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/*.dtb:${LICHEE_PACK_OUT_DIR}/
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/*.bin:${LICHEE_PACK_OUT_DIR}/
)

#${LICHEE_PLAT_OUT}/boot0_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_nand.fex
#${LICHEE_PLAT_OUT}/boot0_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
#${LICHEE_PLAT_OUT}/boot0_${LICHEE_BOOT0_BIN_NAME}_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex
#${LICHEE_PLAT_OUT}/boot0_spinor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/boot0_spinor.fex
boot_file_list_2=(
${LICHEE_PLAT_OUT}/arisc:${LICHEE_PACK_OUT_DIR}/arisc.fex
${LICHEE_PLAT_OUT}/sunxi.dtb:${LICHEE_PACK_OUT_DIR}/sunxi.fex
${LICHEE_PLAT_OUT}/fes1_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1.fex
${LICHEE_PLAT_OUT}/fes1_uart_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/fes1_uart.fex
${LICHEE_PLAT_OUT}/sboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot.bin
${LICHEE_PLAT_OUT}/sboot_nor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nor.bin
${LICHEE_PLAT_OUT}/sboot_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_sdcard.bin
${LICHEE_PLAT_OUT}/sboot_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nand.bin
${LICHEE_PLAT_OUT}/sboot_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_ufs.bin
${LICHEE_PLAT_OUT}/u-boot-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot.fex
${LICHEE_PLAT_OUT}/u-boot-${LICHEE_EFEX_BIN_NAME}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-${LICHEE_EFEX_BIN_NAME}.fex
${LICHEE_PLAT_OUT}/u-boot-crashdump-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-crash.fex
${LICHEE_PLAT_OUT}/u-boot-crashdump-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-crash.fex
${LICHEE_PLAT_OUT}/scp.bin:${LICHEE_PACK_OUT_DIR}/scp.fex
${LICHEE_PLAT_OUT}/u-boot-spinor-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor.fex
${LICHEE_PLAT_OUT}/u-boot-spinor-secure-${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/u-boot-spinor-secure.fex
${LICHEE_PLAT_OUT}/vmlinux.tar.bz2:${LICHEE_PACK_OUT_DIR}/vmlinux.fex
)

arm_boot_file_secure=(
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/semelis_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/semelis.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/optee.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nor.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_sdcard.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nand.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_ufs.bin
${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
)

arm64_boot_file_secure=(
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/optee_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/optee.fex
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nor_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nor.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_sdcard_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_sdcard.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_nand_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_nand.bin
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/sboot_ufs_${PACK_CHIP}.bin:${LICHEE_PACK_OUT_DIR}/sboot_ufs.bin
${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_a64_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc_android.cfg:${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
${LICHEE_CHIP_CONFIG_DIR}/\${BIN_PATH}/amp_rv0.bin:${LICHEE_PACK_OUT_DIR}/amp_rv0.fex
)

#
# This function can get the realpath between $SRC and $DST
#
function get_realpath()
{
	local src=$(cd $1; pwd);
	local dst=$(cd $2; pwd);
	local res="./";
	local tmp="$dst"

	while [ "${src##*$tmp}" == "${src}" ]; do
		tmp=${tmp%/*};
		res=$res"../"
	done
	res="$res${src#*$tmp/}"

	printf "%s" $res
}

function show_boards()
{
	printf "\nAll avaiable chips, platforms and boards:\n\n"
	printf "Chip            Board\n"
	for chipdir in $(find chips/ -mindepth 1 -maxdepth 1 -type d) ; do
		chip=`basename ${chipdir}`
		printf "${chip}\n"
		for boarddir in $(find chips/${chip}/configs/${platform} \
			-mindepth 1 -maxdepth 1 -type d) ; do
			board=`basename ${boarddir}`
			printf "                ${board}\n"
		done
	done
	printf "\nFor Usage:\n"
	printf "     $(basename $0) -h\n\n"
}

function uart_switch()
{
	rm -rf ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	touch ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	TX=`awk  '$0~"'$PACK_CHIP'"{print $2}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	RX=`awk  '$0~"'$PACK_CHIP'"{print $3}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	PORT=`awk  '$0~"'$PACK_CHIP'"{print $4}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	MS=`awk  '$0~"'$PACK_CHIP'"{print $5}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	CK=`awk  '$0~"'$PACK_CHIP'"{print $6}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	DO=`awk  '$0~"'$PACK_CHIP'"{print $7}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`
	DI=`awk  '$0~"'$PACK_CHIP'"{print $8}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_pin`

	BOOT_UART_ST=`awk  '$0~"'$PACK_CHIP'"{print $2}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	BOOT_PORT_ST=`awk  '$0~"'$PACK_CHIP'"{print $3}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	BOOT_TX_ST=`awk  '$0~"'$PACK_CHIP'"{print $4}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	BOOT_RX_ST=`awk  '$0~"'$PACK_CHIP'"{print $5}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_ST=`awk  '$0~"'$PACK_CHIP'"{print $6}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_USED_ST=`awk  '$0~"'$PACK_CHIP'"{print $7}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_PORT_ST=`awk  '$0~"'$PACK_CHIP'"{print $8}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_TX_ST=`awk  '$0~"'$PACK_CHIP'"{print $9}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART0_RX_ST=`awk  '$0~"'$PACK_CHIP'"{print $10}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	UART1_ST=`awk  '$0~"'$PACK_CHIP'"{print $11}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	JTAG_ST=`awk  '$0~"'$PACK_CHIP'"{print $12}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	MS_ST=`awk  '$0~"'$PACK_CHIP'"{print $13}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	CK_ST=`awk  '$0~"'$PACK_CHIP'"{print $14}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	DO_ST=`awk  '$0~"'$PACK_CHIP'"{print $15}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	DI_ST=`awk  '$0~"'$PACK_CHIP'"{print $16}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	MMC0_ST=`awk  '$0~"'$PACK_CHIP'"{print $17}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`
	MMC0_USED_ST=`awk  '$0~"'$PACK_CHIP'"{print $18}' ${LICHEE_COMMON_CONFIG_DIR}/debug/card_debug_string`

	if [ -z "$TX" ] || [ -z "$BOOT_UART_ST" ]; then
		pack_error "$FUNCNAME: $PACK_CHIP not configured in card_debug_pin/card_debug_string!"
		exit 1
	fi

	echo '$0!~";" && $0~"'$BOOT_TX_ST'"{if(C)$0="'$BOOT_TX_ST' = '$TX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$BOOT_RX_ST'"{if(C)$0="'$BOOT_RX_ST' = '$RX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$BOOT_PORT_ST'"{if(C)$0="'$BOOT_PORT_ST' = '$PORT'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	if [ "`grep "auto_print_used" "${LICHEE_PACK_OUT_DIR}/sys_config.fex" | grep "1"`" ]; then
		echo '$0!~";" && $0~"'$MMC0_USED_ST'"{if(A)$0="'$MMC0_USED_ST' = 1";A=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	else
	echo '$0!~";" && $0~"'$MMC0_USED_ST'"{if(A)$0="'$MMC0_USED_ST' = 0";A=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	fi
	echo '$0!~";" && $0~"\\['$MMC0_ST'\\]"{A=1}  \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$UART0_TX_ST'"{if(B)$0="'$UART0_TX_ST' = '$TX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$UART0_RX_ST'"{if(B)$0="'$UART0_RX_ST' = '$RX'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$UART0_ST'\\]"{B=1} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$UART0_USED_ST'"{if(B)$0="'$UART0_USED_ST' = 1"}  \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '/^'$UART0_PORT_ST'/{next} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$UART1_ST'\\]"{B=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$BOOT_UART_ST'\\]"{C=1} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"\\['$JTAG_ST'\\]"{C=0} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$MS_ST'"{$0="'$MS_ST' = '$MS'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$CK_ST'"{$0="'$CK_ST' = '$CK'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$DO_ST'"{$0="'$DO_ST' = '$DO'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '$0!~";" && $0~"'$DI_ST'"{$0="'$DI_ST' = '$DI'"} \' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0
	echo '1' >> ${LICHEE_PACK_OUT_DIR}/awk_debug_card0

	if [ "`grep "auto_print_used" "${LICHEE_PACK_OUT_DIR}/sys_config.fex" | grep "1"`" ]; then
		sed -i -e '/^uart0_rx/a\pinctrl-1=' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i -e '/^uart0_rx/a\pinctrl-0=' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	awk -f ${LICHEE_PACK_OUT_DIR}/awk_debug_card0 ${LICHEE_PACK_OUT_DIR}/sys_config.fex > ${LICHEE_PACK_OUT_DIR}/sys_config_debug.fex
	rm -f ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	mv ${LICHEE_PACK_OUT_DIR}/sys_config_debug.fex ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	echo "uart -> card0"
}

function add_lzma_header()
{
	lzma_file=$1
	original_file=$2
	file_size=$(printf "%.8x\n" `stat -c%s ${lzma_file}`)
	original_file_size=$(printf "%.8x\n" `stat -c%s ${original_file}`)

	bin_str=""

	file_size_len=${#file_size}

	#"LZMA"+size+origin_size
	bin_str="\x4c\x5a\x4d\x41\x${file_size:6:2}\x${file_size:4:2}\x${file_size:2:2}\x${file_size:0:2}"
	bin_str+="\x${original_file_size:6:2}\x${original_file_size:4:2}\x${original_file_size:2:2}\x${original_file_size:0:2}"


	printf "%b" ${bin_str} > tempbin

	cat ${lzma_file} >> tempbin

	mv tempbin "${lzma_file}.head"
}

function partition_size_handle()
{
	echo "handle partition_size"
	local filename=${LICHEE_PACK_OUT_DIR}/sys_partition.fex
	local size
	local number
	local dimension
	local blocks
	local line
	local m
	local index=0
	while read line; do
		let "index++"
		size=$(echo $line | awk -F= '/^[[:space:]]*size[[:space:]]*=/{print $2}' | sed 's|\s\+||g')
		if [ -n "$size" ]; then
			dimension=$(echo $size | sed 's|^[0-9,.]\+||g')
			[ -z "$dimension" ] && continue
			case $dimension in
				B|b)
					m=1
					;;
				K|k)
					m=1024
					;;
				M|m)
					m=1048576
					;;
				G|g)
					m=1073741824
					;;
				*)
					pack_error "ERROR Dimension($dimension)!"
					return 1
					;;
			esac
			number=$(echo $size | sed 's|[a-z,A-Z]*$||g')
			blocks=$(echo "$number * $m / 512" | bc | awk -F. '{print $1}')
			printf "sys_partition.fex: size %6s => %7d Blocks\n" "${number}${dimension}" "${blocks}"
			size="$(echo "$line" | sed "s|=.*$|= $blocks|g")"
			sed -i "${index}s|$line|$size|g" $filename
		fi
	done < $filename
	return 0
}

function do_prepare()
{
	local runinfo=($(lsof 2>/dev/null | awk '$9~"'$LICHEE_TOP_DIR/tools/build/buildserver'"{print $2}'))
	local possible_bin_path="${LICHEE_POSSIBLE_BIN_PATH}"

	if [ ${#runinfo[@]} -lt 2 ]; then
		pack_error "something is incorrect:please <./build.sh config>."
	fi

	if [ -z "${PACK_CHIP}" -o -z "${PACK_TYPE}" -o -z "${PACK_BOARD}" ] ; then
		pack_error "Invalid parameters Chip: ${PACK_CHIP}, \
			Platform: ${PACK_TYPE}, Board: ${PACK_BOARD}"
		show_boards
		exit 1
	fi

	if [ ! -d ${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD} ] ; then
		pack_error "Board's directory \
			\"${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}\" is not exist."
		show_boards
		exit 1
	fi

	# Cleanup
#	if [ "x" != "x${LICHEE_PACK_OUT_DIR}" ]; then
#		rm -rf ${LICHEE_PACK_OUT_DIR}
#	fi
	mkdir -p ${LICHEE_PACK_OUT_DIR}

	(
		cd $LICHEE_OUT_DIR
		if [ "${LICHEE_PACK_OUT_DIR}" != "$LICHEE_OUT_DIR/pack_out" ]; then
#			rm -rf pack_out
			ln -sf ${LICHEE_IC}/${LICHEE_BOARD}/pack_out pack_out
		fi
	)

	printf "copying tools file\n"
	for file in ${tools_file_list[@]} ; do
		cp -f $file ${LICHEE_PACK_OUT_DIR} 2> /dev/null
	done

	if [ "x${PACK_KERN}" = "xlinux-3.4" ]; then
		cp -f ${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript.fex ${LICHEE_PACK_OUT_DIR} 2> /dev/null
	fi

	printf "copying configs file\n"
	for file in ${configs_file_list[@]} ; do
		cp -f $file ${LICHEE_PACK_OUT_DIR} 2> /dev/null
	done

	printf "copying product configs file\n"
	for file in ${product_configs_file_list[@]}; do
		cp -f $file ${LICHEE_PACK_OUT_DIR} 2>/dev/null
	done

	if [ x"${PACK_PLATFORM}" != x"android" ]; then
		printf "linux copying boardt&linux_kernel_version configs file\n"
		local possible_env_path=(
			configs/default
			configs/${LICHEE_BOARD}
			configs/${LICHEE_BOARD}/${LICHEE_KERN_VER}
			configs/${LICHEE_BOARD}/${PACK_PLATFORM}
		)
		local possible_env_list=(
			env.cfg
			env-$(echo ${LICHEE_KERN_VER} | awk -F '-' '{print $2}').cfg
		)
		local copy_env_file=''

		for d in ${possible_env_path[@]}; do
			[ ! -d ${LICHEE_CHIP_CONFIG_DIR}/$d ] && continue
			for file in ${possible_env_list[@]} ; do
				if [ -e "${LICHEE_CHIP_CONFIG_DIR}/$d/$file" ]; then
					copy_env_file=${LICHEE_CHIP_CONFIG_DIR}/$d/$file
				fi
			done
		done
		echo "Use u-boot env file: ${copy_env_file}"
		if [[ ! -f ${copy_env_file} ]]
		then
			echo -e "\e[33mWarning: u-boot env file '${copy_env_file}' not exist! use file in default directory other than '${PACK_BOARD}' directory\e[0m"
		fi

		cp -f ${copy_env_file} ${LICHEE_PACK_OUT_DIR}/env.cfg 2>/dev/null

		cp -f ${LICHEE_CHIP_CONFIG_DIR}/configs/${PACK_BOARD}/${LICHEE_KERN_VER}/sys_* ${LICHEE_PACK_OUT_DIR} 2>/dev/null
	fi

	# If platform config files exist, we will cover the default files
	# For example, mv pack_out/image_linux.cfg pack_out/image.cfg
	if [ ${PACK_PLATFORM} != "android" ]; then
		cp -f ${LICHEE_BOARD_CONFIG_DIR}/${PACK_PLATFORM}/* ${LICHEE_PACK_OUT_DIR} 2> /dev/null
		if [ ${PACK_PLATFORM} = "bsp" -o "x${PACK_PLATFORM}" = "xsata" ] ; then
			find ${LICHEE_PACK_OUT_DIR}/* -type f -a \( -name "*.fex" -o -name "*.cfg" \) -print | \
			sed "s#\(.*\)_linux\(\..*\)#mv -fv & \1\2#e"
		else
			find ${LICHEE_PACK_OUT_DIR}/* -type f -a \( -name "*.fex" -o -name "*.cfg" \) -print | \
			sed "s#\(.*\)_${PACK_PLATFORM}\(\..*\)#mv -fv & \1\2#e"
		fi
	else
		find ${LICHEE_PACK_OUT_DIR}/* -type f -a \( -name "*.fex" -o -name "*.cfg" \) -print | \
			sed "s#\(.*\)_${PACK_TYPE}\(\..*\)#mv -fv & \1\2#e"
	fi

	if [ "x${PACK_MODE}" = "xdump" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/sys_partition_dump.fex ${LICHEE_PACK_OUT_DIR}/sys_partition.fex
		cp -vf ${LICHEE_PACK_OUT_DIR}/usbtool_test.fex ${LICHEE_PACK_OUT_DIR}/usbtool.fex
	elif [ "x${PACK_FUNC}" = "xprvt" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/sys_partition_private.fex ${LICHEE_PACK_OUT_DIR}/sys_partition.fex
	fi

	printf "copying boot resource\n"
	for file in ${boot_resource_list[@]} ; do
		cp -rf $(echo $file | sed -e 's/:/ /g') 2>/dev/null
	done

	# openwrt use these logo files
	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		rm -rf ${LICHEE_PACK_OUT_DIR}/boot-resource
		cp -rf $CFG_TOP_DIR/${PACK_PLATFORM}/target/$PACK_IC/$PACK_IC-common/boot-resource/boot-resource ${LICHEE_PACK_OUT_DIR}
		cp -rf $CFG_TOP_DIR/${PACK_PLATFORM}/target/$PACK_IC/$PACK_IC-common/boot-resource/boot-resource.ini ${LICHEE_PACK_OUT_DIR}/boot-resource.ini
	fi

	if [ ! -f ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp ]; then
		cp ${LICHEE_PACK_OUT_DIR}/boot-resource/bootlogo.bmp ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp
	fi

	lzma -k ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp
	lzma -k ${LICHEE_PACK_OUT_DIR}/bempty.bmp
	lzma -k ${LICHEE_PACK_OUT_DIR}/battery_charge.bmp

	if [ -f ${LICHEE_PACK_OUT_DIR}/bootlogo.bmp.lzma ]; then
		add_lzma_header "${LICHEE_PACK_OUT_DIR}/bootlogo.bmp.lzma" "${LICHEE_PACK_OUT_DIR}/bootlogo.bmp"
		(cd ${LICHEE_PACK_OUT_DIR}; ln -sf bootlogo.bmp.lzma.head  bootlogo.fex)
	fi

	printf "copying boot file\n"
	for d in ${possible_bin_path[@]}; do
		[ ! -d ${LICHEE_CHIP_CONFIG_DIR}/$d ] && continue
		BIN_PATH=$d
		for file in ${boot_file_list[@]} ; do
			eval cp -v -f $(echo $file | sed -e 's/:/ /g') 2>/dev/null
		done
	done
	printf "copying boot file 2.0\n"
	for file in ${boot_file_list_2[@]} ; do
		eval cp -v -f $(echo $file | sed -e 's/:/ /g') 2>/dev/null
	done
	if [[ ${LICHEE_BOARD} == *fastboot*spinand* ]] ; then
		mv -v ${LICHEE_PACK_OUT_DIR}/boot0_nandfastboot_${PACK_CHIP}.fex ${LICHEE_PACK_OUT_DIR}/boot0_nand.fex
	fi

	if ! [ -z ${LICHEE_BOOT0_BIN_NAME} ]; then
	    echo 1111111111111111111111111111111111111
                # nand fastboot
#                cp -v -f ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_nand.fex

#		if [[ ${LICHEE_FLASH} == default ]] ; then
#			mv -v ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
#		elif [[ ${LICHEE_FLASH} == nor ]] ; then
#			mv -v ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_spinor.fex
#		else
#			echo "invalid LICHEE_FLASH, default choose sdcard!"
#			mv -v ${LICHEE_PACK_OUT_DIR}/boot0_${LICHEE_BOOT0_BIN_NAME}.fex ${LICHEE_PACK_OUT_DIR}/boot0_sdcard.fex
#		fi
	fi

	[ -z "${BIN_PATH}" ] &&
	pack_error "No BIN_PATH found!" && exit 1

	printf "copying $LICHEE_ARCH secure boot file\n"
	for d in ${possible_bin_path[@]}; do
		[ ! -d ${LICHEE_CHIP_CONFIG_DIR}/$d ] && continue
		BIN_PATH=$d
		for file in $(eval echo '$'"{${LICHEE_ARCH}_boot_file_secure[@]}"); do
			eval cp -f $(echo $file | sed -e 's/:/ /g') 2>/dev/null
		done
	done

	# If platform config use
	if [ -f ${LICHEE_CHIP_CONFIG_DIR}/tools/plat_config.sh ] ; then
		${LICHEE_CHIP_CONFIG_DIR}/tools/plat_config.sh
	fi

	if [ "x${PACK_NOR}" = "xnor" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/image_nor.cfg ${LICHEE_PACK_OUT_DIR}/image.cfg
		cp -vf ${LICHEE_PACK_OUT_DIR}/sboot_nor.bin ${LICHEE_PACK_OUT_DIR}/sboot.bin
		cp -vf ${LICHEE_PACK_OUT_DIR}/dragon_toc_nor.cfg ${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
	fi

	if [ "x${PACK_VSP}" = "xvsp" ] ; then
		printf "change usb_port_type to device...\n"
		printf "disable usb_serial_unique...\n"
		printf "change usb_serial_number to ${PACK_TYPE}_android...\n"
		sed -i 's/^usb_port_type.*/usb_port_type = 0/g' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i 's/^usb_serial_unique.*/usb_serial_unique = 0/g' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i 's/^usb_serial_number.*/usb_serial_number = "'"${PACK_CHIP}"'_android"/g' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	printf "copying additional files\n"
	for file in ${PACK_ADD_FILES[@]}; do
		cp -vf $(echo $file | sed -e 's/:/ /g') 2>/dev/null
	done

	if [ "x${PACK_PLATFORM}" == "xandroid" ] && [ "x$TARGET_BUILD_VARIANT" == "xuser" ]; then
		pack_info "change kernel loglevel to 3 for android user build"
		sed -i 's|^\s*loglevel=[0-9]\s*$|loglevel=3|g' ${LICHEE_PACK_OUT_DIR}/env.cfg
		if [ "${ENABLE_VENDOR_ADB}" == "true" ]; then
			pack_info "enable vendor adb for android user build"
			sed -i 's|^init_rc=.*$|init_rc=/vendor/etc/init/hw/init.aw.rc|g' ${LICHEE_PACK_OUT_DIR}/env.cfg
		fi
	fi

	if [ "x${PACK_PROGRAMMER}" = "xprogrammer" ]; then
		printf "add programmer img info target in sys config\n"
		sed -i -e '/^\[target\]/a\programmer=1' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	sed -i 's/\\boot-resource/\/boot-resource/g' ${LICHEE_PACK_OUT_DIR}/boot-resource.ini
	sed -i 's/\\\\/\//g' ${LICHEE_PACK_OUT_DIR}/image.cfg
	sed -i 's/^imagename/;imagename/g' ${LICHEE_PACK_OUT_DIR}/image.cfg

	prepare_mixed_androiddragonboard
	[ $? -ne 0 ] && exit 1

	partition_size_handle
	[ $? -ne 0 ] && exit 1

	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		cd ${LICHEE_PACK_OUT_DIR}/
		echo "vmlinux" > ${LICHEE_PACK_OUT_DIR}/vmlinux.fex
		if [ "x${PACK_NOR}" = "xnor" ] ; then
			make_user_res sys_partition_nor.fex
			make_app_res sys_partition_nor.fex
			make_data_res sys_partition_nor.fex
		else
			make_user_res sys_partition.fex
			make_app_res sys_partition.fex
			make_data_res sys_partition.fex
		fi
		cd - > /dev/null
	fi
}

function img_to_programmer()
{
	local out_img=$1
	local in_img=$2

	cd ${LICHEE_PACK_OUT_DIR}/

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		if [ -f toc0_sdcard.fex ] ; then
			programmer_img toc0_sdcard.fex toc1.fex ${out_img} > /dev/null
		elif [ -f toc0_nand.fex ] ; then
			programmer_img toc0_nand.fex toc1.fex ${out_img} > /dev/null
		else
			programmer_img toc0.fex toc1.fex ${out_img} > /dev/null
		fi
	else
		programmer_img boot0_sdcard.fex boot_package.fex ${out_img} > /dev/null
	fi

	if [ -f sunxi_gpt.fex ] ; then
		#create_img for sunxi_gpt.fex
		programmer_img sys_partition.bin sunxi_mbr.fex ${out_img} ${in_img} sunxi_gpt.fex > /dev/null
	else
		#create_img for sunxi_mbr.fex
		programmer_img sys_partition.bin sunxi_mbr.fex ${out_img} ${in_img} > /dev/null
	fi

}

function uboot_ini_to_dts()
{
	local TARGET_UBOOT
	local PLATFORM_ADDR
	local SOC_ADDR
	local DTC_FLAGS=""

	if [ x${LICHEE_BRANDY_UBOOT_VER} == x2023 ]; then
		pack_info "skip split fdt"
		return
	fi

	if [ "x${PACK_NOR}" == "xnor" ]; then
		TARGET_UBOOT=${LICHEE_PACK_OUT_DIR}/u-boot-spinor.fex
	else
		TARGET_UBOOT=${LICHEE_PACK_OUT_DIR}/u-boot.fex
	fi
	sunxi_ubootools split ${TARGET_UBOOT} > /dev/null
	if [ $? -ne 0 ]
	then
		pack_warn "split uboot and fdt failed!!"
		return
	fi

	[ "$(readlink -f .)" != "$(readlink -f ${LICHEE_PACK_OUT_DIR})" ] && {
		mv temp_fdt.dtb  ${LICHEE_PACK_OUT_DIR}
		mv temp_ubootnodtb.bin  ${LICHEE_PACK_OUT_DIR}
	}

	# to dts
	$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb  2>/dev/null

	PLATFORM_ADDR=`grep -Po "(?<=platform@)(\w+)(?=\s*{)" ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp | head -1`
	SOC_ADDR=`grep -Po "(?<=soc@)(\w+)(?=\s*{)" ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp | head -1`

	if [ "x${PACK_TYPE}" = "xdragonboard" -o "x${PACK_TYPE}" = "xdragonabts" ] ; then
		cat <<- EOF >> ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp
		/{
			soc@${SOC_ADDR} {
				platform@${PLATFORM_ADDR} {
				dragonboard_test = <1>;
				};
			};
		};
		EOF
	fi

	# to dtb
	$DTC_COMPILER ${DTC_FLAGS} -I dts -O dtb -o ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp  2>/dev/null

	# get update_to_ubootfdt value from sysconfig
	sunxi_ubootools subkey_value sys_config.bin sunxi_ubootools update_to_ubootfdt > /dev/null
	if [ $? -eq 1 ]; then
		echo "uboot ini to dts"
		$DTC_COMPILER -p 2048 ${DTC_FLAGS} -@ -O dtb -o ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb	\
			-b 0			\
			-i ${LICHEE_PACK_OUT_DIR}	\
			-F $DTC_INI_FILE \
			-d ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb ${LICHEE_PACK_OUT_DIR}/.uboot.dtb.dts.tmp 2>/dev/null
	else
		mv ${LICHEE_PACK_OUT_DIR}/temp_fdt.dtb  ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb
	fi

	sunxi_ubootools merge ${LICHEE_PACK_OUT_DIR}/temp_ubootnodtb.bin ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb > /dev/null
	cp -vf ${LICHEE_PACK_OUT_DIR}/temp_ubootnodtb.bin ${TARGET_UBOOT}
	# .uboot.dts is the last dts of uboot
	$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PACK_OUT_DIR}/.uboot.dts ${LICHEE_PACK_OUT_DIR}/new_fdt.dtb 2>/dev/null
}

function do_ini_to_dts()
{
	cd ${LICHEE_PACK_OUT_DIR}/

	maybe_busybox unix2dos sys_config.fex
	script  sys_config.fex > /dev/null

	local DTC_SRC_PATH=${LICHEE_PLAT_OUT}
	local DTC_COMPILER=${LICHEE_PLAT_OUT}/dtc
	local DTC_FLAGS=""

	uboot_ini_to_dts

	if [ "x${PACK_KERN}" == "xlinux-3.4" \
			-o "x${PACK_KERN}" == "xlinux-3.10" \
			-o "x${PACK_KERN}" == "xlinux-4.4" \
			-o "x${PACK_KERN}" == "xlinux-5.4" \
			-o "x${PACK_KERN}" == "xlinux-5.4-ansc" \
			-o "x${PACK_KERN}" == "xlinux-5.10" \
			-o "x${PACK_KERN}" == "xlinux-5.10-origin" \
			-o "x${PACK_KERN}" == "xlinux-5.15" \
			-o "x${PACK_KERN}" == "xlinux-5.15-origin" ] || [[  ${PACK_KERN/linux-} > 5.15 ]]; then
		# For debug: sunxi.dtb -> .sunxi.dts
		$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PLAT_OUT}/.sunxi.dts ${LICHEE_PLAT_OUT}/sunxi.dtb 2>/dev/null
		return
	fi

	local dtc_file_list=(
		.board.dtb.d.dtc.tmp:.board.dtb.dts.tmp
		.${PACK_CHIP}-${PACK_BOARD}.dtb.d.dtc.tmp:.${PACK_CHIP}-${PACK_BOARD}.dtb.dts.tmp
		.${PACK_CHIP}-${LICHEE_BUSSINESS}.dtb.d.dtc.tmp:.${PACK_CHIP}-${LICHEE_BUSSINESS}.dtb.dts.tmp
		.${PACK_CHIP}-soc.dtb.d.dtc.tmp:.${PACK_CHIP}-soc.dtb.dts.tmp)

	local DTC_INI_FILE_BASE=${LICHEE_PACK_OUT_DIR}/sys_config.fex
	local DTC_INI_FILE=${LICHEE_PACK_OUT_DIR}/sys_config_fix.fex

	cp $DTC_INI_FILE_BASE $DTC_INI_FILE
	sed -i "s/\(\[dram\)_para\(\]\)/\1\2/g" $DTC_INI_FILE
	sed -i "s/\(\[nand[0-9]\)_para\(\]\)/\1\2/g" $DTC_INI_FILE

	if [ ! -f $DTC_COMPILER ]; then
		pack_error "Script_to_dts: Can not find dtc compiler.\n"
		exit 1
	fi

	local DTC_DEP_FILE DTC_SRC_FILE
	for e in ${dtc_file_list[@]}; do
		DTC_DEP_FILE=$DTC_SRC_PATH/${e/:*}
		if [ -f $DTC_DEP_FILE ]; then
			DTC_SRC_FILE=$DTC_SRC_PATH/${e#*:}
			break
		fi
	done

	echo "sunxi_dtb create"
	$DTC_COMPILER -p 2048 ${DTC_FLAGS} -@ -O dtb -o ${LICHEE_PLAT_OUT}/sunxi.dtb	\
		-b 0			\
		-i $DTC_SRC_PATH	\
		-F $DTC_INI_FILE	\
		-d $DTC_DEP_FILE $DTC_SRC_FILE 2>/dev/null

	if [ $? -ne 0 ]; then
		pack_error "Conver script to dts failed"
		exit 1
	fi

	#restore the orignal dtsi
	if [ "x${PACK_TYPE}" = "xdragonboard" \
		-o "x${PACK_TYPE}" = "xdragonmat" ]; then
		local DTS_PATH=${LICHEE_KERN_DIR}/arch/${LICHEE_ARCH}/boot/dts
		[ "x${LICHEE_ARCH}" = "xarm64" ] && DTS_PATH=${LICHEE_KERN_DIR}/arch/${LICHEE_ARCH}/boot/dts/sunxi
		if [ -f ${DTS_PATH}/${PACK_CHIP}_bak.dtsi ];then
			rm -f ${DTS_PATH}/${PACK_CHIP}.dtsi
			mv  ${DTS_PATH}/${PACK_CHIP}_bak.dtsi  ${DTS_PATH}/${PACK_CHIP}.dtsi
		fi
	fi

	printf "Conver script to dts ok.\n"

	# It'is used for debug dtb
	$DTC_COMPILER ${DTC_FLAGS} -I dtb -O dts -o ${LICHEE_PLAT_OUT}/.sunxi.dts ${LICHEE_PLAT_OUT}/sunxi.dtb 2>/dev/null

	return
}

function maybe_busybox()
{
	if [ "x$(which busybox)" == "x" ]; then
		pack_error "Tool busybox does not exist!"
		exit 1
	fi

	busybox $@ || $@
}

function generate_env_for_uboot()
{
	printf "$1 Conver to $2.\n"
	printf "LICHEE_BRANDY_UBOOT_VER : ${LICHEE_BRANDY_UBOOT_VER}\n"
	if [ -n "${LICHEE_BRANDY_UBOOT_VER}" ] && [ ${LICHEE_BRANDY_UBOOT_VER} -ge 2023 ]; then
		printf "create env.fex for uboot2023 or later, size 128K\n"
		# mkenvimage -p 0x00 -s 0x20000 -o env.fex env.cfg
		mkenvimage -p 0x00 -s 0x20000 -o $2 $1
	else
		# u_boot_env_gen env_nor.cfg env_nor.fex >/dev/null
		u_boot_env_gen $1 $2 >/dev/null
	fi
}

function do_common()
{
	cd ${LICHEE_PACK_OUT_DIR}/

	echo $(date -d "$ts" +"%Y-%m-%d %H:%M:%S") > ${LICHEE_PACK_OUT_DIR}/sunxi_version.fex

	# Here, we can switch uart to card or normal
	if [ "x${PACK_DEBUG}" = "xcard0" -a "x${PACK_MODE}" != "xdump" \
		-a "x${PACK_FUNC}" != "xprvt" ] ; then \
		uart_switch
	else
		sed -i -e '/^auto_print_used/s\1\0\' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		printf "add burn_secure_mode in target in sys config\n"
		sed -i -e '/^\[target\]/a\burn_secure_mode=1' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i -e '/^\[platform\]/a\secure_without_OS=0' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		if [ -f ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex ]; then
			rm -f ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex
		fi
	else
		sed -i '/^burn_secure_mod/d' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		sed -i '/^secure_without_OS/d' ${LICHEE_PACK_OUT_DIR}/sys_config.fex
		if [ -f ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex ]; then
			mv -v ${LICHEE_PACK_OUT_DIR}/optee-monitor.fex ${LICHEE_PACK_OUT_DIR}/optee.fex
		fi
	fi

	if [ ! -f board_config.fex ]; then
		echo "[empty]" > board_config.fex
	fi

	maybe_busybox unix2dos sys_config.fex
	maybe_busybox unix2dos board_config.fex
	script  sys_config.fex > /dev/null
	cp -f   sys_config.bin config.fex
	script  board_config.fex > /dev/null
	cp -f board_config.bin board.fex

	maybe_busybox unix2dos sys_partition.fex
	script  sys_partition.fex > /dev/null


	if [ "x${PACK_TYPE}" = "xdragonboard" ] ; then
		maybe_busybox dos2unix test_config.fex
		cp test_config.fex boot-resource/
		maybe_busybox unix2dos test_config.fex
		script test_config.fex > /dev/null
		cp test_config.bin boot-resource/
	fi

	if [ "x${PACK_TYPE}" = "xdragonabts" ] ; then
		maybe_busybox dos2unix test_config.fex
		cp test_config.fex boot-resource/
		maybe_busybox unix2dos test_config.fex
		script test_config.fex > /dev/null
		cp test_config.bin boot-resource/
	fi
	# Those files for SpiNor. We will try to find sys_partition_nor.fex
	if [ "x${PACK_NOR}" = "xnor" ] ; then

		if [ ! -f sys_partition_nor.fex ];  then
			echo "sys partition for nor not exist"
			exit 1
		fi

		if [ ! -f ${LICHEE_CHIP_CONFIG_DIR}/tools/arisc_config_parse.sh ]; then
			if [ -f "scp.fex" ]; then
				echo "update scp"
				update_scp scp.fex sunxi.fex >/dev/null
			fi
		fi

		# Here, will create sys_partition_nor.bin
		maybe_busybox unix2dos sys_partition_nor.fex
		script  sys_partition_nor.fex > /dev/null
		update_boot0 boot0_spinor.fex   sys_config.bin SPINOR_FLASH > /dev/null
		update_chip boot0_spinor.fex   > /dev/null
		update_fes1  fes1.fex           sys_config.bin > /dev/null

		if [ "x${PACK_KERN}" = "xlinux-3.4" ] ; then
			update_uboot -merge u-boot-spinor.fex  sys_config.bin > /dev/null
		else
			update_uboot -no_merge u-boot-spinor.fex  sys_config.bin > /dev/null
			update_uboot -no_merge u-boot-spinor-secure.fex  sys_config.bin > /dev/null
			[ -f u-boot-efex.fex ] && {
				update_uboot -no_merge u-boot-efex.fex  sys_config.bin > /dev/null
			}
		fi

		while read line
		do
			compress_name=(`echo $line | awk '($1 !~ ";" && ($2 ~ "lzma" || $2 ~ "lz4" || $2 ~ "gz")) {print $2}'`)
			source_name=(`echo $compress_name | cut -d \.  -f 1,2 | cut -d \  -f 2`)
			compress_type=(`echo $compress_name | cut -d \.  -f 3 | cut -d \  -f 2`)
			[ -z "$compress_name" ] && continue
			case $compress_type in
			"gz")
				[ -f $source_name ] && gzip -c $source_name > $compress_name || echo "no exist $source_name"
				echo "compress name: $compress_name"
				;;
			"lzma")
				[ -f $source_name ] && lzma -k $source_name || echo "no exist $source_name"
				mv $source_name.lzma $compress_name >/dev/null 2<&1
				echo "compress name: $compress_name"
				;;
			"lz4")
				[ -f $source_name ] && lz4 -f $source_name $compress_name || echo "no exist $source_name"
				echo "compress name: $compress_name"
				;;
			*)
				echo "no match compress type"
				;;
			esac
			echo "compress type: $compress_type"
		done < boot_package_nor.cfg

		if [ -f boot_package_nor.cfg ]; then
			mv u-boot-spinor-crash.fex u-boot-crash.fex
			echo "pack boot package"
			maybe_busybox unix2dos boot_package.cfg
			dragonsecboot -pack boot_package_nor.cfg
			cp boot_package.fex boot_package_nor.fex
		fi
		# Ugly, but I don't have a better way to change it.
		# We just set env's downloadfile name to env_nor.cfg in sys_partition_nor.fex
		# And if env_nor.cfg is not exist, we should copy one.
		if [ ! -f env_nor.cfg ]; then
			cp -f env.cfg env_nor.cfg >/dev/null 2<&1
		fi

		#card sprite
		if [ -f "boot0_sdcard.fex" ]; then
		    echo 22222222222222222222222222222222222222
			#update_boot0 boot0_sdcard.fex   sys_config.bin SDMMC_CARD > /dev/null
			#update_chip boot0_sdcard.fex > /dev/null
		fi

		# Fixup boot mode for SPINor, just can bootm
		sed -i '/^boot_normal/s#\<boota\>#bootm#g' env_nor.cfg

		echo 1:LICHEE_REDUNDANT_ENV_SIZE:$LICHEE_REDUNDANT_ENV_SIZE
		if [ "x${LICHEE_REDUNDANT_ENV_SIZE}" != "x" ]; then
			echo "--mkenvimage create redundant env data!--"
			echo "--redundant nor env data size ${LICHEE_REDUNDANT_ENV_SIZE}---"
			mkenvimage -r -p 0x00 -s ${LICHEE_REDUNDANT_ENV_SIZE} -o env_nor.fex env_nor.cfg
		else
			generate_env_for_uboot env_nor.cfg env_nor.fex
		fi
	else
	echo 333333333333333333333333333333333333333333
		#update_boot0 boot0_nand.fex     sys_config.bin NAND > /dev/null
		#update_boot0 boot0_sdcard.fex   sys_config.bin SDMMC_CARD > /dev/null
		#update_boot0 boot0_ufs.fex   sys_config.bin UFS > /dev/null
		#update_chip boot0_nand.fex >/dev/null
		#update_chip boot0_sdcard.fex >/dev/null
		#update_chip boot0_ufs.fex >/dev/null
	fi

	if [ ! -f "u-boot-crash.fex" ]; then
		touch "u-boot-crash.fex"
		echo "ensure u-boot-crash.fex is not empty" > u-boot-crash.fex
	fi

	if [ -f "sunxi.fex" ]; then
		update_dtb sunxi.fex 4096
	fi

	if [ ! -f ${LICHEE_CHIP_CONFIG_DIR}/tools/arisc_config_parse.sh ]; then
		if [ -f "scp.fex" ]; then
			echo "update scp"
			update_scp scp.fex sunxi.fex >/dev/null
		fi
	fi

	if [ -f "optee.fex" ]; then
		echo "update optee"
		update_optee optee.fex sunxi.fex >/dev/null
	fi

	# Those files for Nand or Card
	if [ "x${PACK_KERN}" = "xlinux-3.4" ] ; then
		update_uboot -merge u-boot.fex sys_config.bin > /dev/null
	else
		update_uboot -no_merge u-boot.fex sys_config.bin > /dev/null
		[ -f u-boot-nodtb.fex ] && {
			update_uboot -no_merge u-boot-nodtb.fex sys_config.bin > /dev/null
		}
		[ -f u-boot-efex.fex ] && {
			update_uboot -no_merge u-boot-efex.fex  sys_config.bin > /dev/null
		}
	fi

	if [ -f "fes1_uart.fex" ]; then
		update_fes1  fes1_uart.fex           sys_config.bin > /dev/null
	fi

	update_fes1  fes1.fex           sys_config.bin > /dev/null
	if [ -f ${LICHEE_TOOLS_DIR}/pack/pctools/linux/mod_update/update_sboot ];then
		update_sboot sboot.bin  sys_config.bin  > /dev/null
		if [ $? -ne 0 ]
		then
			pack_error "update sboot run error"
			exit 1
		fi
	fi
	fsbuild      boot-resource.ini  split_xxxx.fex > /dev/null

	if [ -f boot_package_uartburn.cfg ]; then
		dragonsecboot -pack boot_package_uartburn.cfg
		if [ $? -ne 0 ]
		then
			pack_error "dragon pack boot_package_uartburn run error"
			exit 1
		fi
		mv boot_package.fex boot_package_uartburn.fex
	fi

	if [ -f boot_package.cfg ]; then
		if [ "x$LINUX_DTBO_FILE" = "x" ]; then
			echo "do not set LINUX_DTBO_FILE"
			line_num=`sed -n -e "/default.dtbo/=" boot_package.cfg`
			if [ "x$line_num" != "x" ]; then
				sed -i "$line_num s/^/;/g" boot_package.cfg
			fi
		else
			if [ -f $LINUX_DTBO_FILE ]
			then
				sed -i "s/default.dtbo/$LINUX_DTBO_FILE/g" boot_package.cfg
			else
				line_num=`sed -n -e "/default.dtbo/=" boot_package.cfg`
				if [ "x$line_num" != "x" ]; then
					sed -i "$line_num s/^/;/g" boot_package.cfg
				fi
			fi
		fi

			echo "pack boot package"
			maybe_busybox unix2dos boot_package.cfg
			dragonsecboot -pack boot_package.cfg

		if [ $? -ne 0 ]
		then
			pack_error "dragon pack run error"
			exit 1
		fi
	fi

	echo 2:LICHEE_REDUNDANT_ENV_SIZE:$LICHEE_REDUNDANT_ENV_SIZE
	if [ "x${PACK_FUNC}" = "xprvt" ] ; then
		if [ "x${LICHEE_REDUNDANT_ENV_SIZE}" != "x" ]; then
			echo "--mkenvimage create redundant env data!--"
			echo "--redundant env data size ${LICHEE_REDUNDANT_ENV_SIZE}---"
			mkenvimage -r -p 0x00 -s ${LICHEE_REDUNDANT_ENV_SIZE} -o env.fex env_burn.cfg
		else
			generate_env_for_uboot env_burn.cfg env.fex
		fi
	else
		if [ "x${LICHEE_REDUNDANT_ENV_SIZE}" != "x" ]; then
			echo "--mkenvimage create redundant env data!--"
			echo "--redundant env data size ${LICHEE_REDUNDANT_ENV_SIZE}---"
			mkenvimage -r -p 0x00 -s ${LICHEE_REDUNDANT_ENV_SIZE} -o env.fex env.cfg
		else
			generate_env_for_uboot env.cfg env.fex
		fi
	fi

	dmverity_deal clean

}

function do_finish()
{
	# Yeah, it should contain all files into full_img.fex for spinor
	# Because, as usually, spinor image size is very small.
	# If fail to create full_img.fex, we should fake it empty.

	# WTF, it is so ugly!!! It must be sunxi_mbr.fex & sys_partition.bin,
	# not sunxi_mbr_xxx.fex & sys_partition_xxx.bin. In order to advoid this
	# loathsome thing, we need to backup & copy files. Check whether
	# sys_partition_nor.bin is exist, and create sunxi_mbr.fex for Nor.
	local max_toc_size=2097152

	local IMG_NAME="${PACK_IC}_${PACK_TYPE}${PACK_PLATFORM_VERSION}_${PACK_BOARD}_${PACK_DEBUG}"
	if [ "x${PACK_MODE}" = "xdump" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_MODE}"
	fi

	if [ "x${PACK_FUNC}" = "xprvt" ]; then
		IMG_NAME="${IMG_NAME}_${PACK_FUNC}"
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_SECURE}"
	fi

	if [ "x${PACK_FUNC}" = "xprev_refurbish" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_FUNC}"
	fi

	if [ "x${PACK_NOR}" = "xnor" ] ; then
		IMG_NAME="${IMG_NAME}_${PACK_NOR}"
	fi

	if [ "x${PACK_SECURE}" != "xnone" ]; then
		local MAIN_VERION=$(readcfg dragon_toc.cfg rollback_ver ver)
		if [ ! -n "${MAIN_VERION}" ]; then
			local MAIN_VERION="$(echo '__unique:;@echo ${MAIN_VERSION}' | make -f - -f ${LICHEE_PACK_OUT_DIR}/version_base.mk --no-print-directory __unique)"
		fi
		IMG_NAME="${IMG_NAME}_v${MAIN_VERION}.img"
	else
		IMG_NAME="${IMG_NAME}.img"
	fi

	local IMG_PROGRAMMER_NAME="${IMG_NAME%.*}_programmer.img"

	echo "imagename = $IMG_NAME" >> ${LICHEE_PACK_OUT_DIR}/image.cfg
	echo "" >> ${LICHEE_PACK_OUT_DIR}/image.cfg

	local imagesize
	local toc_size
	local max_toc_size=3883264

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		toc_size=`stat toc1.fex --format="%s"`
	else
		toc_size=`stat boot_package.fex --format="%s"`
	fi

	if [ "$LICHEE_CHIP" == "sun55iw3p1" ]; then
		max_toc_size=3883264
	fi

	if [ ${toc_size} -gt ${max_toc_size} ];then
		pack_error "boot_package.fex/toc1.fex More than ${max_toc_size} bytes limit too large!!!"
		exit 1
	fi

	if [ "x${PACK_NOR}" = "xnor" ] ; then
		NOR_LOGIC_START=2016
		NOR_UBOOT_START=128
		NOR_FLASH_SIZE=65536 #32M
		NOR_LOGIC_START_KB=`expr ${NOR_LOGIC_START} / 2`
		NOR_UBOOT_START_KB=`expr ${NOR_UBOOT_START} / 2`

		local uboot_dts=""
		if [ -n "${LICHEE_BRANDY_UBOOT_VER}" ] && [ ${LICHEE_BRANDY_UBOOT_VER} -ge 2023 ]; then
			uboot_dts="${LICHEE_BOARD_CONFIG_DIR}/uboot-${LICHEE_BRANDY_UBOOT_VER}/uboot-board.dts"
		else
			uboot_dts="${LICHEE_BOARD_CONFIG_DIR}/uboot-board.dts"
		fi

		if [ -f ${uboot_dts} ] && [ x"$(grep "nor_map" ${uboot_dts})" != x"" ]; then
			echo "get flashmap from ${uboot_dts}"
			NOR_FLASH_SIZE=$(awk '/nor_map {/,/}/ {print NR ": " $0}' ${uboot_dts} \
				| grep  "\bflash_size\b" | grep -oP "(?<=\<)\d+(?=\>)")

			NOR_LOGIC_START=$(awk '/nor_map {/,/}/ {print NR ": " $0}' ${uboot_dts} \
				| grep  "\blogic_offset\b" | grep -oP "(?<=\<)\d+(?=\>)")

			NOR_UBOOT_START=$(awk '/nor_map {/,/}/ {print NR ": " $0}' ${uboot_dts} \
				| grep  "\buboot_start\b" | grep -oP "(?<=\<)\d+(?=\>)")

			[ x"${NOR_FLASH_SIZE}" = x"" -o x"${NOR_LOGIC_START}" = x"" -o x"${NOR_UBOOT_START}" = x"" ] && {
				pack_warn "flash_size,logic_offset,uboot_start maybe not set in uboot-board.dts"
				NOR_LOGIC_START=2016
				NOR_UBOOT_START=128
				NOR_FLASH_SIZE=65536 #32M
			}

			NOR_LOGIC_START_KB=`expr ${NOR_LOGIC_START} / 2`
			NOR_UBOOT_START_KB=`expr ${NOR_UBOOT_START} / 2`
			echo "flash size:${NOR_FLASH_SIZE}, logic start:${NOR_LOGIC_START}, uboot start:${NOR_UBOOT_START}"
		fi

		update_mbr sys_partition_nor.bin 1 sunxi_mbr_nor.fex dlinfo.fex \
				${NOR_FLASH_SIZE} ${NOR_LOGIC_START} 1

		if [ $? -ne 0 ]; then
			pack_error "update_mbr failed"
			exit 1
		fi
		echo '----------programmer nor image is full_img.fex ----------'
		if [ "x${PACK_KERN}" = "xlinux-3.4" ] ; then
		#when use devicetree, the size of uboot+dtb is larger then 256K
			#BOOT1_FILE=u-boot-spinor.fex
			#LOGIC_START=240 #240+16=256K
			#merge_package full_img.fex boot0_spinor.fex \
			#        u-boot-spinor.fex sunxi_mbr_nor.fex sys_partition_nor.bin
			merge_full_img --out full_img.fex --boot0 boot0_spinor.fex --boot1 u-boot-spinor.fex \
							--mbr sunxi_mbr_nor.fex  --partition sys_partition_nor.bin \
							--logic_start 240 > /dev/null
		else
			merge_full_img --out full_img.fex --boot0 boot0_spinor.fex --boot1 boot_package_nor.fex \
				--mbr sunxi_gpt.fex --partition sys_partition_nor.bin \
				--logic_start ${NOR_LOGIC_START_KB} --uboot_start ${NOR_UBOOT_START_KB} > /dev/null
		fi

		if [ $? -ne 0 ]; then
			pack_error "merge_full_img failed"
			exit 1
		fi
		mv sys_partition_nor.fex sys_partition.fex
	fi

	if [ ! -f sys_partition_nor.bin ]; then
		update_mbr          sys_partition.bin 4
		if [ $? -ne 0 ]; then
			pack_error "update_mbr failed"
			exit 1
		fi

		#15269888 is from emmc datasheet, sec_count in Extended CSD is 0xe90000 = 15269888.
		#40960 is the mbr location for emmc
		#0  is emmc/nand ; 1 is spinor
		update_mbr sys_partition.bin 4 sunxi_mbr.fex dlinfo.fex 15269888 40960 0
		if [ $? -ne 0 ]; then
			pack_error "update_mbr_gpt failed"
			exit 1
		fi
	fi

	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		echo "===================================="
		echo "show sys_partition.fex message"
		show_partition_message sys_partition.fex
	fi

	local e cfgadd cfgget lastcfgline localfile filename
	local imgcfg_add_list=(
		# localfile             filename-in-cfg        maintype  subtype
		'vmlinux.fex            vmlinux.fex            12345678  123456789VMLINUX'
		'vendor_boot-debug.fex  vendor_boot-debug.fex  RFSFAT16  VENDOR_BOOTDEBUG'
		'dragon_toc.cfg         dragon_toc.fex         12345678  12345678DGTOCCFG'
		)

	for e in "${imgcfg_add_list[@]}"; do
		localfile="$(awk '{print $1}' <<< $e)"
		filename="$(awk '{print $2}' <<< $e)"
		maintype="$(awk '{print $3}' <<< $e)"
		subtype="$(awk '{print $4}' <<< $e)"
		cfgget="$(sed -n '/^\s*{\s*filename\s*=\s*"'$filename'"\s*,/p' image.cfg)"
		lastcfgline="$(sed -n '/^\s*{\s*filename\s*=/=' image.cfg | tail -1)"

		[ ! -f "$localfile" -o -n "$cfgget" -o -z "$lastcfgline" ] && continue
		[ "$localfile" != "$filename" ] && ln -sf $localfile $filename
		cfgadd='    {filename = "'$filename'",'
		cfgadd+='     maintype = "'$maintype'",'
		cfgadd+='     subtype  = "'$subtype'",},'
		sed -i -e  ''"${lastcfgline}"'a\' -e "$cfgadd" image.cfg
	done

	dragon image.cfg    sys_partition.fex
	if [ $? -eq 0 ]; then
		if [ -e ${IMG_NAME} ]; then
			mv ${IMG_NAME} $LICHEE_OUT_DIR/$LICHEE_IC/$LICHEE_BOARD/$LICHEE_LINUX_DEV/${IMG_NAME}
			rm -f $LICHEE_OUT_DIR/${IMG_NAME}
			ln -f $LICHEE_OUT_DIR/$LICHEE_IC/$LICHEE_BOARD/$LICHEE_LINUX_DEV/${IMG_NAME}  $LICHEE_OUT_DIR/${IMG_NAME}
			imagesize=$(du --apparent-size -sh $LICHEE_OUT_DIR/$LICHEE_IC/$LICHEE_BOARD/$LICHEE_LINUX_DEV/${IMG_NAME} | awk '{print $1}')
			echo '----------image is at----------'
			echo -e '\033[0;31;1m'
			echo -e "$imagesize\t${LICHEE_OUT_DIR}/${IMG_NAME}"
			echo -e '\033[0m'
		fi
	fi
	cd ..

	if [ "x${PACK_PROGRAMMER}" = "xprogrammer" ]; then
		if [ -f  $LICHEE_PACK_OUT_DIR/super.fex ]; then
			mv $LICHEE_PACK_OUT_DIR/super.fex $LICHEE_PACK_OUT_DIR/super.bak.fex
			simg2img  $LICHEE_PACK_OUT_DIR/super.bak.fex $LICHEE_PACK_OUT_DIR/super.fex
		fi
		echo "waiting to ceate programmer img..."
		img_to_programmer ${IMG_PROGRAMMER_NAME} $LICHEE_OUT_DIR/${LICHEE_IC}/${LICHEE_BOARD}/${LICHEE_LINUX_DEV}/${IMG_NAME}
		if [ $? -eq 0 ]; then
			if [ -e ${IMG_PROGRAMMER_NAME} ]; then
				mv $LICHEE_PACK_OUT_DIR/${IMG_PROGRAMMER_NAME} $LICHEE_OUT_DIR/${LICHEE_IC}/${LICHEE_BOARD}/${LICHEE_LINUX_DEV}/${IMG_PROGRAMMER_NAME}
				imagesize=$(du --apparent-size -sh $LICHEE_OUT_DIR/${LICHEE_IC}/${LICHEE_BOARD}/${LICHEE_LINUX_DEV}/${IMG_PROGRAMMER_NAME} | awk '{print $1}')
				echo '----------programmer image is at----------'
				echo -e '\033[0;31;1m'
				echo -e "$imagesize\t${LICHEE_OUT_DIR}/${IMG_PROGRAMMER_NAME}"
				echo -e '\033[0m'
			fi
		fi
	fi
	cd ..
	do_finish_SATA
	printf "pack finish\n"
	[ -e ${LICHEE_TOP_DIR}/build/.hooks/post-dragon ] &&
		source ${LICHEE_TOP_DIR}/build/.hooks/post-dragon
	return 0
}

function do_finish_SATA()
{
	if [ "x$BUILD_SATA" = "xtrue" ];then
		SATA_TAR=$LICHEE_TOP_DIR/SATA/linux/${LICHEE_CHIP}.tar
		if [ -f $SATA_TAR ];then
			echo '----------SATA is at----------'
			echo -e '\033[0;31;1m'
			echo $SATA_TAR
			echo -e '\033[0m'
		else
			echo PACK SATA failed!
		fi
	fi
}

function dmverity_deal()
{
	local script_name=scripts/build.sh
	local script_path=$LICHEE_KERN_DIR

	if [ ! -x $script_path/$script_name ]; then
		script_path=$LICHEE_BUILD_DIR
		script_name=mkkernel.sh
	fi

	[ ! -x $script_path/$script_name ] && return 255
	[ -z "$(grep "^\s*deal_verity)\s*$" $script_path/$script_name)" ] && return 1

	(cd $script_path && ./$script_name "deal_verity" $@)
}

function dmverity_get_blk_count()
{
	local size=`du --apparent-size -b $1 | awk '{print $1}'`
	local BLK_SIZE=$2

	if [ `expr ${size} % ${BLK_SIZE}` = "0" ]; then
			local blks=`(expr ${size} / ${BLK_SIZE})`
	else
			local blks=`(expr ${size} / ${BLK_SIZE} + 1 )`
	fi

	echo $blks
}

function dmverity_determ_blk_size()
{
	local type_info=`file -L $1`

	#check rootfs file system type to determ block size
	if [ "x""`echo ${type_info}| grep "ext4 filesystem"`" != "x" ];then
		block_size=`tune2fs -l $1|grep "Block size"|awk {'print $3'}`
		echo ${block_size}
	else
		echo "not support file system type"
		return -1
	fi

}
function dmverity_genHashTable()
{
	local fs_name=$1
	local tree_name=$2
	local table_name=$3
	local block_size=`dmverity_determ_blk_size ${fs_name}`
	if [ ${block_size} -lt 0 ];then
		return -1
	fi
	veritysetup format --data-block-size=${block_size} --hash-block-size=${block_size} ${fs_name} ${tree_name} > ${table_name}
	return $?
}

function dmverity_genDownloadFile()
{
	local fs_name=$1
	local sign_name=$2
	local table_name=$3
	local tree_name=$4
	local download_file_name=$5

	local BLK_SIZE=`dmverity_determ_blk_size ${fs_name}`
	if [ ${BLK_SIZE} -lt 0 ];then
		return -1
	fi
	local SIGN_BLK=`dmverity_get_blk_count ${sign_name} ${BLK_SIZE}`
	local TABLE_BLK=`dmverity_get_blk_count ${table_name} ${BLK_SIZE}`
	local TREE_BLK=`dmverity_get_blk_count ${tree_name} ${BLK_SIZE}`

	# 3.1 copy sign
	dd if=${sign_name} of=${download_file_name}"tmp" bs=${BLK_SIZE} count=${SIGN_BLK} >/dev/null 2>&1

	# 3.2 copy table size
	local TABLE_SIZE=`du --apparent-size -b ${table_name} | awk '{print $1}'`
	local HIGH_BYTES=`expr $TABLE_SIZE / 256 `
	local LOW_BYTES=`expr $TABLE_SIZE % 256 `
	if [ $HIGH_BYTES -gt 256 ]; then
		echo "ERROR rootfs_hash_table size should < 64KB"
		return -1
	fi
	local HIGH_BYTES_H=`echo "obase=16;ibase=10;$HIGH_BYTES" | bc`
	local LOW_BYTES_H=`echo "obase=16;ibase=10;$LOW_BYTES" | bc`
	echo -e -n "\x$LOW_BYTES_H\x$HIGH_BYTES_H" >> ${download_file_name}"tmp"

	# 3.3 copy rootfs_hash_table
	dd if=${table_name} of=${download_file_name}"tmp"  bs=${BLK_SIZE} seek=${SIGN_BLK} count=${TABLE_BLK} > /dev/null 2>&1

	# 3.4 copy rootfs_hash_tree.bin
	dd if=${tree_name} of=${download_file_name}"tmp"  bs=${BLK_SIZE} seek=`expr ${SIGN_BLK} + ${TABLE_BLK}` count=${TREE_BLK} > /dev/null 2>&1

	dd of=${download_file_name} if=${download_file_name}"tmp" bs=${BLK_SIZE} count=`expr ${SIGN_BLK} + ${TABLE_BLK} + ${TREE_BLK}`>/dev/null 2>&1
	rm ${download_file_name}"tmp"
}

function do_signature_dsp()
{
	local DSP0_BIN=${LICHEE_PACK_OUT_DIR}/amp_dsp0.fex;
	local DSP1_BIN=${LICHEE_PACK_OUT_DIR}/amp_dsp1.fex;
	local CFG_FILE=${LICHEE_CHIP_CONFIG_DIR}/configs/default/image_header_secure.cfg;

	if [ -f ${CFG_FILE} ] ; then
		cp -v ${CFG_FILE} image_header_secure.cfg
	else
		printf "can not found image_header_secure cfg\n"
		return 1
	fi

	if [ -f ${DSP0_BIN} ] ; then
		mkimage_header -C 5 -c image_header_secure.cfg -s rsa -k $CFG_KEY_DIR
		if [ $? -ne 0 ]
		then
			pack_error "mkimage_header signature dsp error\n"
			exit 1
		fi
		mv amp_dsp0.fex.pack amp_dsp0.fex
	else
		printf "can not found amp_dsp0 bin\n"
		return 3
	fi

	if [ -f ${DSP1_BIN} ] ; then
		mv amp_dsp0.fex.pack amp_dsp0.fex
	fi

}

function do_signature_riscv()
{
	local RV0_BIN=${LICHEE_PACK_OUT_DIR}/amp_rv0.fex;
	local RV1_BIN=${LICHEE_PACK_OUT_DIR}/amp_rv1.fex;
	local CFG_FILE=${LICHEE_CHIP_CONFIG_DIR}/configs/default/image_header_secure.cfg;
	local key_type=$(readcfg dragon_toc.cfg key_para key_toc1 | cut -c 1-3)
	if [ x${key_type} == "xecc" ]; then
		sign_alg=ecc
	else
		sign_alg=rsa
	fi

	if [ -f ${CFG_FILE} ] ; then
		cp -v ${CFG_FILE} image_header_secure.cfg
	else
		printf "can not found image_header_secure cfg\n"
		return 1
	fi

	if [ -f ${RV0_BIN} ] ; then
		mkimage_header -C 5 -c image_header_secure.cfg -s $sign_alg -k $CFG_KEY_DIR
		if [ $? -ne 0 ]
		then
			pack_error "mkimage_header signature rv error\n"
			exit 1
		fi
		mv amp_rv0.fex.pack amp_rv0.fex
	else
		printf "can not found amp_rv0 bin\n"
		return 3
	fi

	if [ -f ${RV1_BIN} ] ; then
		mv amp_rv1.fex.pack amp_rv1.fex
	fi

}

function do_signature_ft()
{
	if [ ! -e ${LICHEE_PACK_OUT_DIR}/ft_${PACK_CHIP}.bin ]; then
		printf "can not found ft bin\n"
		return 1
	fi

	if [ -e ${LICHEE_PACK_OUT_DIR}/dragon_toc_ft.cfg ]; then
		printf "can not found dragon_toc_ft cfg\n"
	fi

	printf "prepare for signature for ft bin\n"
	mv ${LICHEE_PACK_OUT_DIR}/ft_${PACK_CHIP}.bin ${LICHEE_PACK_OUT_DIR}/ft.bin
	dragonsecboot -toc0 dragon_toc_ft.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
	if [ $? -ne 0 ]; then
		pack_error "dragon toc0_ft run error\n"
		exit 1
	fi

	mv toc0.fex toc0_ft.fex
}

function do_signature_fel()
{
	printf "prepare for signature for fex tools\n"
	local ROOT_KEY_NAME="";
	local UBOOT_NAME="u-boot";
	local sign_tools=$(readcfg dragon_toc.cfg sign_fel_tools sign_tools)

	if [ -f u-boot-efex.fex ]; then
		UBOOT_NAME="u-boot-efex"
	fi
	echo UBOOT_NAME ${UBOOT_NAME}

	if [ x${sign_tools} == "xdragonsboot" ]; then
		printf "using dragonsboot to sign fel\n"

		if [ -f ${CFG_KEY_DIR}/RootKey_Level_0.pem ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/RootKey_Level_0.pem
		elif [ -f ${CFG_KEY_DIR}/Trustkey.pem ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/Trustkey.pem
		else
			pack_error "can not found root key to sign fex tool"
			exit 1
		fi
		echo rootkeyname ${ROOT_KEY_NAME}

		dragonsecboot -sign fes1.fex ${ROOT_KEY_NAME} ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
		if [ $? -eq 0 ]; then
			dragonsecboot -sign ${UBOOT_NAME}.fex ${ROOT_KEY_NAME} ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
			if [ $? -ne 0 ]
			then
				pack_error "dragonsecboot uboot fail"
			fi
		fi
	else
		printf "using sig_fel_image to sign fel\n"
		if [ -f ${CFG_KEY_DIR}/RootKey_Level_0.bin ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/RootKey_Level_0.bin
		elif [ -f ${CFG_KEY_DIR}/Trustkey.bin ]; then
			ROOT_KEY_NAME=${CFG_KEY_DIR}/Trustkey.bin
		else
			pack_error "can not found root key to sign fex tool"
			exit 1
		fi
		echo rootkeyname ${ROOT_KEY_NAME}

		sig_fel_image --input fes1.fex --rsakey ${ROOT_KEY_NAME} --output fes1_sign.fex --version_base ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "sig_fel_image fes fail"
			exit 1
		fi
		sig_fel_image --input ${UBOOT_NAME}.fex --rsakey ${ROOT_KEY_NAME} --output ${UBOOT_NAME}_sign.fex --version_base ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "sig_fel_image uboot fail"
		fi
	fi

	if [ -f fes1_sign.fex ]; then
		cp fes1_sign.fex fes1.fex
	fi

	if [ -f  ${UBOOT_NAME}_sign.fex ]; then
		cp ${UBOOT_NAME}_sign.fex ${UBOOT_NAME}.fex
	fi
}

function readcfg()
{
	local fid=$1
	local section=$2
	local option=$3

	test ! -f $fid && echo "file not exits:$fid" && exit 1
	if [ $# -eq 3 ] ; then
		local src=$(cat $fid | awk '/\['$section'\]/{f=1;next} /\[*\]/{f=0} f' |
		grep ^$option |
		grep '='     |
		cut -d'=' -f2|
		cut -d'#' -f1|
		cut -d';' -f1|
		awk '{gsub(/^\s+|\s+$/, "");print}')
		echo -n $src
		test ${#src} -eq 0 && return 1 || return 0
	else
		echo "the input parameters should be 3"
		exit 1
	fi
}

function get_item_from_cfg()
{
	name=()
	bin=()
	cert=()
	counts=0

	local toc_cfg=$1
	local field=$2
	local key=$3

	toc1_item_content=$(readcfg ${toc_cfg} ${field} ${key})
	i=0
	IFS=', ' read -r -a parts <<< $toc1_item_content
	for part in "${parts[@]}"; do
		if [ $(($i % 3)) -eq 0 ]; then
			name[counts]=$part
		elif [ $(($i % 3)) -eq 1 ]; then
			bin[counts]=$part
		else
			cert[counts]=$part
			counts=$((counts + 1))
		fi
		i=$((i + 1))
	done
}

function create_toc0()
{
	local toc_cfg=$1
	local key=""
	local cert_type=""
	local key_type=""
	local psck_mode=""

	rm -rf toc0

	if [ ! -d "toc0" ]; then
		mkdir -p toc0
	fi

	if [ ! -d "temp" ]; then
		mkdir -p temp
	fi

	get_item_from_cfg ${toc_cfg} toc0 item

	key=$(readcfg ${toc_cfg} key_toc0 ${name[0]})
	cert_type=$(readcfg ${toc_cfg} cert_type cert_type_toc0)
	key_type=$(readcfg ${toc_cfg} key_para key_toc0 | cut -c 1-3)
	if [ x${key_type} == "xrsa" ]; then
		psck_mode=RSA-PKCS
	elif [ x${key_type} == "xecc" ]; then
		psck_mode=ECDSA
	else
		pack_error "key_toc0 type error"
		exit 1
	fi

	#gen sboot hash
	dragon_securetool hash --mode 256 --in ${bin[0]} --out ./temp/${bin[0]}.hash.out
	if [ $? -ne 0 ]
	then
		pack_error "gen sboot hash error"
		exit 1
	fi

	#req no sign cert, ext is sboot_hash; use pubkey
	dragon_securetool req_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --ext ./temp/${bin[0]}.hash.out --out ./temp/${name[0]}.req
	if [ $? -ne 0 ]
	then
		pack_error "req no sign cert for toc0 error"
		exit 1
	fi

	#gen no sign cert hash, witch is to be signed
	dragon_securetool hash --mode 256 --type ${cert_type} --in ./temp/${name[0]}.req --out ./temp/${name[0]}.req.hash
	if [ $? -ne 0 ]
	then
		pack_error "gen no sign cert hash for toc0 error"
		exit 1
	fi

	#sign cert(to be signed) hash
	if [ "x$SOFTHSM_FLAG" == "x1" ]; then
		local id=$(echo "$key" | md5sum | awk '{print $1}')
		pkcs11-tool --label ${key} --id ${id} -s -p ${PIN} -m ${psck_mode} --module ${MODULES} --input-file ./temp/${name[0]}.req.hash --output-file ./temp/${name[0]}.req.sign
		if [ $? -ne 0 ]
		then
			pack_error "softhsm sign cert(to be signed) hash for toc0 error"
			exit 1
		fi
	else
		dragon_securetool sign --cfg ${toc_cfg} --privatekey ${CFG_KEY_DIR}/${key}.pem --in ./temp/${name[0]}.req.hash --out ./temp/${name[0]}.req.sign
		if [ $? -ne 0 ]
		then
			pack_error "sign cert(to be signed) hash for toc0 error"
			exit 1
		fi
	fi

	#create cert with sign
	dragon_securetool create_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --reqfile ./temp/${name[0]}.req --signfile ./temp/${name[0]}.req.sign --out ./toc0/${cert[0]}
	if [ $? -ne 0 ]
	then
		pack_error "create cert with sign for toc0 error"
		exit 1
	fi

	#create toc0.fex(toc0_head + sboot.crtpt + sboot)
	dragon_securetool create_toc0 --cfg ${toc_cfg} --out ./toc0.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon toc0 run error"
		exit 1
	fi
}

function do_signature_sboot()
{
	local sboot_file=$1;
	local flash_type=$2;

	#dram_param
	if [ -f ${LICHEE_TOOLS_DIR}/pack/pctools/linux/mod_update/update_sboot ]; then
		update_sboot $sboot_file  sys_config.bin  > /dev/null
		if [ $? -ne 0 ]
		then
			pack_error "update sboot run error"
			exit 1
		fi
	fi

	update_chip $sboot_file > /dev/null

	#dragon_toc only load sboot.bin
	[ "$(readlink -f $sboot_file)" != "$(readlink -f sboot.bin)" ] && \
	mv $sboot_file sboot.bin

	#readcfg determines whether the cfg file is legacy or new
	readcfg dragon_toc.cfg key_para key > /dev/null
	if [ $? -ne 0 ]; then
		dragonsecboot -toc0 dragon_toc.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/version_base.mk > /dev/null
		if [ $? -ne 0 ]
		then
			pack_error "dragon toc0 run error"
			exit 1
		fi
	else
		create_toc0 dragon_toc.cfg

	fi

	update_toc0  toc0.fex           sys_config.bin
	if [ $? -ne 0 ]
	then
		pack_error "update toc0 run error"
		exit 1
	fi

	[ "$(readlink -f $sboot_file)" != "$(readlink -f sboot.bin)" ] && \
	mv sboot.bin $sboot_file
	if [ -f toc0_$flash_type.fex ]; then
		rm -rf toc0_$flash_type.fex
	fi
	mv toc0.fex toc0_$flash_type.fex
	mv toc0 toc0_$flash_type
}

function do_signature_toc0()
{
	if [ -f sboot.bin ]; then
		do_signature_sboot sboot.bin bak
		mv sboot.bin sboot_bak.bin
	fi

	if [ -f sboot_sdcard.bin ]; then
		if [ -f cardscript.fex ]; then
			sed -i "s/TOC0_00000000000/TOC0_SDCARD00000/g" cardscript.fex
		fi
		do_signature_sboot sboot_sdcard.bin sdcard
	fi

	if [ -f sboot_nand.bin ]; then
		do_signature_sboot sboot_nand.bin nand

	fi

	if [ -f sboot_ufs.bin ]; then
		do_signature_sboot sboot_ufs.bin ufs
	fi

	if [ -f sboot_nor.bin ]; then
		do_signature_sboot sboot_nor.bin nor
	fi

	mv sboot_bak.bin sboot.bin
	mv toc0_bak.fex toc0.fex
	mv toc0_bak toc0
}

function toc1_create_cert_for_per_bin()
{
	local toc_cfg=$1
	local key=""
	local cert_type=""
	local key_type=""
	local psck_mode=""

	cert_type=$(readcfg ${toc_cfg} cert_type cert_type_toc1)
	key_type=$(readcfg ${toc_cfg} key_para key_toc1 | cut -c 1-3)
	if [ x${key_type} == "xrsa" ]; then
		psck_mode=RSA-PKCS
	elif [ x${key_type} == "xecc" ]; then
		psck_mode=ECDSA
	else
		pack_error "key_toc1 type error"
		exit 1
	fi

	for ((count=0; count < counts; count++)); do
		key=$(readcfg ${toc_cfg} key_toc1 ${name[count]})
		#gen ${bin[count]} hash
		dragon_securetool hash --mode 256 --in ${bin[count]} --out temp/${name[count]}_hash.out
		if [ $? -ne 0 ]
		then
			pack_error "gen hash ${name[count]} error"
			exit 1
		fi

		#req no sign cert, ext is sboot_hash; use pubkey
		dragon_securetool req_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/$key.pem.pub --ext temp/${name[count]}_hash.out --out temp/${cert[count]}.req
		if [ $? -ne 0 ]
		then
			pack_error "req no sign cert ${name[count]} error"
			exit 1
		fi

		#gen no sign cert hash, witch is to be signed
		dragon_securetool hash --mode 256 --type ${cert_type} --in temp/${cert[count]}.req --out temp/to_be_signed_${name[count]}_hash.out
		if [ $? -ne 0 ]
		then
			pack_error "gen no sign cert hash ${name[count]} error"
			exit 1
		fi

		#sign cert(to be signed) hash
		if [ "x$SOFTHSM_FLAG" == "x1" ]; then
			local id=$(echo "$key" | md5sum | awk '{print $1}')
			pkcs11-tool --label ${key} --id ${id} -s -p ${PIN} -m ${psck_mode} --module ${MODULES} --input-file temp/to_be_signed_${name[count]}_hash.out --output-file temp/${name[count]}_sign.out
			if [ $? -ne 0 ]
			then
				pack_error "softhsm sign cert(to be signed) hash ${name[count]} error"
				exit 1
			fi
		else
			dragon_securetool sign --cfg ${toc_cfg} --privatekey ${CFG_KEY_DIR}/$key.pem --in temp/to_be_signed_${name[count]}_hash.out --out temp/${name[count]}_sign.out
			if [ $? -ne 0 ]
			then
				pack_error "sign cert(to be signed) hash ${name[count]} error"
				exit 1
			fi
		fi

		#create cert with sign
		dragon_securetool create_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --reqfile temp/${cert[count]}.req --signfile temp/${name[count]}_sign.out --out toc1/cert/${cert[count]}
		if [ $? -ne 0 ]
		then
			pack_error "create cert with sign ${name[count]} error"
			exit 1
		fi
	done
}

function toc1_create_cert_for_rootkey()
{
	local toc_cfg=$1
	local key=""
	local cert_type=""
	local key_type=""
	local psck_mode=""

	cert_type=$(readcfg ${toc_cfg} cert_type cert_type_toc1)
	get_item_from_cfg ${toc_cfg} toc1 rootkey
	key=$(readcfg ${toc_cfg} key_toc0 rootkey)
	key_type=$(readcfg ${toc_cfg} key_para key_toc0 | cut -c 1-3)
	if [ x${key_type} == "xrsa" ]; then
		psck_mode=RSA-PKCS
	elif [ x${key_type} == "xecc" ]; then
		psck_mode=ECDSA
	else
		pack_error "key_toc0 type error"
		exit 1
	fi

	#rootkey no sign cert
	#req no sign rootkey cert, insert extensions in the dragon_toc.cfg; use pubkey
	dragon_securetool req_rootkey_cert --type ${cert_type} --cfg ${toc_cfg} --keypath ${CFG_KEY_DIR} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub
	if [ $? -ne 0 ]
	then
		pack_error "req rootkey cert error"
		exit 1
	fi

	mv toc1/cert/${cert[0]} temp/${cert[0]}.req
	#gen no sign rootkey cert hash, witch is to be signed; Non-x509 certificates do not need to skip 4 bytes
	dragon_securetool hash --mode 256 --type ${cert_type} --in temp/${cert[0]}.req --out temp/to_be_signed_${name[0]}_hash.out
	if [ $? -ne 0 ]
	then
		pack_error "gen no sign rootkey cert hash error"
		exit 1
	fi

	#sign rootkey cert(to be signed) hash
	if [ "x$SOFTHSM_FLAG" == "x1" ]; then
		local id=$(echo "$key" | md5sum | awk '{print $1}')
		pkcs11-tool --label ${key} --id ${id} -s -p ${PIN} -m ${psck_mode} --module ${MODULES} --input-file temp/to_be_signed_${name[0]}_hash.out --output-file temp/${name[0]}_sign.out
		if [ $? -ne 0 ]
		then
			pack_error "softhsm sign rootkey cert(to be signed) hash error"
			exit 1
		fi
	else
		dragon_securetool sign --cfg ${toc_cfg} --privatekey ${CFG_KEY_DIR}/${key}.pem --in temp/to_be_signed_${name[0]}_hash.out --out temp/${name[0]}_sign.out
		if [ $? -ne 0 ]
		then
			pack_error "sign rootkey cert(to be signed) hash error"
			exit 1
		fi
	fi

	#create rootkey cert with sign
	dragon_securetool create_cert --type ${cert_type} --cfg ${toc_cfg} --pubkey ${CFG_KEY_DIR}/${key}.pem.pub --reqfile temp/${cert[0]}.req --signfile temp/${name[0]}_sign.out --out toc1/cert/${cert[0]}
	if [ $? -ne 0 ]
	then
		pack_error "create rootkey cert with sign error"
		exit 1
	fi
}

function do_signature_toc1()
{
	rm -rf toc1

	if [ ! -d "toc1/cert" ]; then
		mkdir -p toc1/cert
	fi

	if [ ! -d "temp" ]; then
		mkdir -p temp
	fi

	#create cert for toc1 item
	get_item_from_cfg dragon_toc.cfg toc1 item
	toc1_create_cert_for_per_bin dragon_toc.cfg

	#create cert for toc1 onlykey
	get_item_from_cfg dragon_toc.cfg toc1 onlykey
	toc1_create_cert_for_per_bin dragon_toc.cfg

	toc1_create_cert_for_rootkey dragon_toc.cfg

	#create toc1.fex(toc1_head + rootkey.crtpt + ..)
	dragon_securetool create_toc1 --cfg dragon_toc.cfg --out toc1.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon toc1 run error"
		exit 1
	fi
}

function do_signature()
{
	printf "prepare for signature by openssl\n"
	if [ ! -d $CFG_KEY_DIR ] ; then
		pack_error "No key exist, please run './build/createkeys' to generate keys first."
		exit 1
	fi
	if [ "x${PACK_SIG}" = "xprev_refurbish" ] ; then
		if [ "x${LICHEE_ARCH}" = "xarm64" ] ; then
			cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_a64_no_secureos.cfg dragon_toc.cfg
		else
			cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_no_secureos.cfg dragon_toc.cfg
		fi
	else
		if [ "x${LICHEE_ARCH}" = "xarm64" ] ; then
			if [ -f ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg ] ; then
				cp -v ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg dragon_toc.cfg
			else
				cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc_a64.cfg dragon_toc.cfg
			fi
		else
			if [ -f ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg ] ; then
				cp -v ${LICHEE_CHIP_CONFIG_DIR}/configs/default/dragon_toc.cfg dragon_toc.cfg
			else
				cp -v ${LICHEE_COMMON_CONFIG_DIR}/sign_config/dragon_toc.cfg dragon_toc.cfg
			fi
		fi
	fi
	if [ "x${PACK_NOR}" = "xnor" ] ; then
		cp -vf ${LICHEE_PACK_OUT_DIR}/dragon_toc_nor.cfg ${LICHEE_PACK_OUT_DIR}/dragon_toc.cfg
	fi

	if [ -f ${CFG_KEY_DIR}/softhsm2.cfg ]; then
		# fix tokendir
		tokendir=$(grep tokendir ${CFG_KEY_DIR}/softhsm2.cfg | awk '{print $3}')
		if [ "x$tokendir" != "x${CFG_KEY_DIR}/.token" ]; then
			sed -i "s#${tokendir}#${CFG_KEY_DIR}/.token#g" ${CFG_KEY_DIR}/softhsm2.cfg
		fi

		PIN=1234
		SOPIN=12345678
		SOFTHSM_TOOLS_DIR=${LICHEE_TOOLS_DIR}/pack/pctools/linux/softhsm
		MODULES=${SOFTHSM_TOOLS_DIR}/lib/softhsm/libsofthsm2.so
		export LD_LIBRARY_PATH=${SOFTHSM_TOOLS_DIR}/lib:${SOFTHSM_TOOLS_DIR}/lib/softhsm:${LIB_LIBRARY_PATH}
		export PATH=${SOFTHSM_TOOLS_DIR}/bin:$PATH
		export SOFTHSM2_CONF=${CFG_KEY_DIR}/softhsm2.cfg

		SOFTHSM_FLAG=1
	fi

	if [ $? -ne 0 ]
	then
		pack_error "dragon toc config file is not exist"
		exit 1
	fi

	rm -f cardscript.fex
	mv cardscript_secure.fex cardscript.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon cardscript_secure.fex file is not exist"
		exit 1
	fi

	if [ ! -f ${LICHEE_PLAT_OUT}/recovery.img ]; then
		printf "recovery img is not exist, remove recovery cert from dragon_toc.cfg\n"
		sed -i '/recovery/d' dragon_toc.cfg > /dev/null
	else
		local recovery_buf=$(grep "recovery" -nr dragon_toc.cfg)
		if [ x"${recovery_buf}" = x"" ]; then
			readcfg dragon_toc.cfg key_para key > /dev/null
				if [ $? -ne 0 ]; then
					sed -i '/^onlykey=boot/a\onlykey=recovery,      recovery.fex,        SCPFirmwareContentCertPK' dragon_toc.cfg
				else
					sed -i '/^boot=/a recovery=NonTrustedFirmwareContentCertPK' dragon_toc.cfg
					sed -i '/^onlykey=boot/a\onlykey=recovery,     recovery.fex,        recovery.crtpt' dragon_toc.cfg
				fi
		fi
	fi

	if [ "x${PACK_VERITY}" = "x${FLAGS_TRUE}" ]; then
		# verity setup for squashfs type filesystem
		if [ x"${PACK_PLATFORM}" = x"openwrt" ] || [ x"${PACK_PLATFORM}" = x"bsp" ] || [ x"${PACK_PLATFORM}" = x"buildroot" ]; then
			rm -rf rootfs.fex
			local link_real_new=$(get_realpath ${LICHEE_PLAT_OUT} ./)

			if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
				cp ${link_real_new}/rootfs.img		rootfs.fex
			else
				cp ${link_real_new}/rootfs.squashfs	rootfs.fex
			fi

			if [ "x${PACK_KERN}" == "xlinux-5.4" \
					-o "x${PACK_KERN}" == "xlinux-5.4-ansc" \
					-o "x${PACK_KERN}" == "xlinux-5.10" \
					-o "x${PACK_KERN}" == "xlinux-5.10-origin" \
					-o "x${PACK_KERN}" == "xlinux-5.15" \
					-o "x${PACK_KERN}" == "xlinux-5.15-origin" ]; then

				squashfs_real_size=`hexdump -s 0x28 -n 4 -e '/4 "%d"' rootfs.fex`
				squashfs_data_blocks=`expr \( ${squashfs_real_size} + 4095 \) / 4096`

				local TEMP=${LC_ALL}
				export LC_ALL=C

				veritysetup --data-blocks=${squashfs_data_blocks} format rootfs.fex hash_tree > raw_table

				export LC_ALL=${TEMP}

				readcfg dragon_toc.cfg key_para key > /dev/null
				if [ $? -ne 0 ]; then
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          hash_tree,        SCPFirmwareContentCertPK' dragon_toc.cfg
				else
					sed -i '/^boot=/a rootfs=NonTrustedFirmwareContentCertPK' dragon_toc.cfg
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          hash_tree,        rootfs.crtpt' dragon_toc.cfg
				fi
			else
				# get sample from squashfs rootfs
				local rootfs_per_MB=`grep "^rootfs_per_MB=" env.cfg | awk -F = '{printf $2}'`
				if [ -z $rootfs_per_MB ]; then
					echo "rootfs_per_MB is not defined in env.cfg, use default value 4096"
					rootfs_per_MB=4096
				fi

				extract_squashfs $rootfs_per_MB rootfs.fex rootfs-extract.fex
				if [ $? -ne 0 ]; then
					echo "extract squashfs error"
					exit 1;
				fi

				readcfg dragon_toc.cfg key_para key > /dev/null
				if [ $? -ne 0 ]; then
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          rootfs-extract.fex,        SCPFirmwareContentCertPK' dragon_toc.cfg
				else
					sed -i '/^boot=/a rootfs=NonTrustedFirmwareContentCertPK' dragon_toc.cfg
					sed -i '/^onlykey=boot/a\onlykey=rootfs,          rootfs-extract.fex,        rootfs.crtpt' dragon_toc.cfg
				fi
			fi
		else
			# generate verity data, suport more different filesystem in the future
			(dmverity_genHashTable rootfs.fex rootfsHashTree.fex rootfsHashTable.fex &&
			openssl dgst -sha256 -binary -sign $CFG_KEY_DIR/SCPFirmwareContentCertPK.pem rootfsHashTable.fex > rootfsHashSign.fex &&
			openssl rsa -in $CFG_KEY_DIR/SCPFirmwareContentCertPK.pem -pubout -out rootfsPubKey.pk &&
			dmverity_genDownloadFile rootfs.fex rootfsHashSign.fex rootfsHashTable.fex rootfsHashTree.fex VerityInfo.fex) ||
			{ pack_error "generate verity data failed"; exit 1; }

			# add partition for verity data
			(add_partition -2 rootfsverityInfo 4096 "VerityInfo.fex" &&
			maybe_busybox unix2dos sys_partition.fex &&
			script  sys_partition.fex > /dev/null) ||
			{ pack_error "add verity info part failed"; exit 1; }

			# add verity tools into ramdisk
			local rootfsPath=`readlink -f rootfs.fex`
			local keyPath=`readlink -f rootfsPubKey.pk`
			local blockSize=`dmverity_determ_blk_size ${rootfsPath}`
			dmverity_deal $blockSize rootfsverityInfo ext4 $keyPath ||
			{ pack_error "deal verity utils failed"; exit 1; }
		fi
	fi

	if [ "x${PACK_SIGNFEL}" = "x${FLAGS_TRUE}" ]; then
		do_signature_fel
	fi

	do_signature_ft

	do_signature_toc0

	#readcfg determines whether the cfg file is legacy or new
	readcfg dragon_toc.cfg key_para key > /dev/null
	if [ $? -ne 0 ]; then
		dragonsecboot -toc1 dragon_toc.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/cnf_base.cnf ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "dragon toc1 run error"
			exit 1
		fi
		cert=".der"
	else
		do_signature_toc1
		cert=".crtpt"
	fi

	sigbootimg --image boot.fex --cert toc1/cert/boot${cert} --output boot_sig.fex
	if [ $? -ne 0 ] ; then
		pack_error "Pack cert to image error"
		exit 1
	else
		mv -f boot_sig.fex boot.fex
	fi

	do_signature_dsp

	do_signature_riscv

	if [ "x${PACK_VERITY}" = "x${FLAGS_TRUE}" ]; then
		if [ x"${PACK_PLATFORM}" = x"openwrt" ] || [ x"${PACK_PLATFORM}" = x"bsp" ] || [ x"${PACK_PLATFORM}" = x"buildroot" ]; then
			if [ "x${PACK_KERN}" == "xlinux-5.4" \
					-o "x${PACK_KERN}" == "xlinux-5.4-ansc" \
					-o "x${PACK_KERN}" == "xlinux-5.10" \
					-o "x${PACK_KERN}" == "xlinux-5.10-origin" \
					-o "x${PACK_KERN}" == "xlinux-5.15" \
					-o "x${PACK_KERN}" == "xlinux-5.15-origin" ]; then
				verity_root_hash_str=`grep "Root hash:" raw_table | awk '{print $3}'`
				verity_salt_str=`grep "Salt:" raw_table | awk '{print $2}'`

				update_squashfs_verity -f rootfs.fex -c toc1/cert/rootfs${cert} -t hash_tree -r ${verity_root_hash_str} -s ${verity_salt_str}
				if [ $? -ne 0 ]; then
					pack_error "add verity block error."
					exit 1
				fi
			else
				update_squashfs rootfs.fex toc1/cert/rootfs${cert}
				if [ $? -ne 0 ]
				then
					pack_error "signature squashfs rootfs error."
					exit 1
				fi
			fi
		fi
	fi

	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	local recovery_path=${link_real}/recovery.img

	if [ -f "$recovery_path" ]; then
		sigbootimg --image recovery.fex --cert toc1/cert/recovery${cert} --output recovery_sig.fex
		if [ $? -ne 0 ] ; then
			pack_error "Pack cert to image error"
			exit 1
		else
			mv -f recovery_sig.fex recovery.fex
		fi
	fi

	echo "secure signature ok!"
}

function do_android_signature()
{
	if [ "x$LINUX_DTBO_FILE" = "x" ]; then
		echo "do not set LINUX_DTBO_FILE"
		line_num=`sed -n -e "/default.dtbo/=" dragon_toc.cfg`
		if [ "x$line_num" != "x" ]; then
			sed -i "$line_num s/^/;/g" dragon_toc.cfg
		fi
	else
		if [ -f $LINUX_DTBO_FILE ]
		then
			sed -i "s/default.dtbo/$LINUX_DTBO_FILE/g" dragon_toc.cfg
		else
			line_num=`sed -n -e "/default.dtbo/=" dragon_toc.cfg`
			if [ "x$line_num" != "x" ]; then
				sed -i "$line_num s/^/;/g" dragon_toc.cfg
			fi
		fi
	fi

	if [ $? -ne 0 ]
	then
		pack_error "dragon toc config file is not exist"
		exit 1
	fi

	rm -f cardscript.fex
	mv cardscript_secure.fex cardscript.fex
	if [ $? -ne 0 ]
	then
		pack_error "dragon cardscript_secure.fex file is not exist"
		exit 1
	fi

	do_signature_ft

	do_signature_toc0

	#readcfg determines whether the cfg file is legacy or new
	readcfg dragon_toc.cfg key_para key > /dev/null
	if [ $? -ne 0 ]; then
		dragonsecboot -toc1 dragon_toc.cfg $CFG_KEY_DIR ${LICHEE_PACK_OUT_DIR}/cnf_base.cnf ${LICHEE_PACK_OUT_DIR}/version_base.mk
		if [ $? -ne 0 ]
		then
			pack_error "dragon toc1 run error"
			exit 1
		fi
		cert=".der"
	else
		do_signature_toc1
		cert=".crtpt"
	fi

	if [ -e dboot.fex ]; then
		local keyname=$(awk -F, '/^[[:space:]]*onlykey=boot\S*,[[:space:]]*dboot.fex,/{print $1}' dragon_toc.cfg  | awk -F= '{print $2}')
		sigbootimg --image dboot.fex --cert toc1/cert/${keyname}${cert} --output dboot_sig.fex
		[ $? -ne 0 ] && pack_error "Pack cert to image error" && exit 1
		mv -f dboot_sig.fex dboot.fex
	fi

	echo "secure android signature ok!"
}

################################ Tina func ################################
function get_partition_downfile_size()
{
    local downloadfile_name=`echo $1 | awk -F '=' '{print $2}'`
    if [ x${downloadfile_name: 0-4} != x".fex" ]; then
        pack_error "downloadfile format is wrong, it should be end with .fex"
        exit -1
    fi
    if [ ! -f ${downloadfile_name} ]; then
        echo "  file ${downloadfile_name} not find"
    else
        if [ -L ${downloadfile_name} ]; then
            local downloadfile_name_link=`readlink -f ${downloadfile_name}`
            local linkfile_name=${downloadfile_name_link##*/}
            echo "  ${downloadfile_name} -> ${downloadfile_name_link}"
            if [ ! -f ${downloadfile_name_link} ]; then
                echo "  link file ${linkfile_name} not find"
            else
                local linkfile_size=`ls -lh ${downloadfile_name_link} | awk '{print $5}'`
                echo "  ${linkfile_name} size : ${linkfile_size} byte"
            fi
        else
            local downloadfile_size=`ls -lh ${downloadfile_name} | awk '{print $5}'`
            echo "  ${downloadfile_name} size : ${downloadfile_size} byte"
        fi
    fi
}

function get_partition_mbr_size()
{
    local partition_size_name=`echo $1 | awk -F '=' '{print $1}' | sed 's/partition/mbr/g'`
    local partition_size=`echo $1 | awk -F '=' '{print $2}'`
    echo "  ${partition_size_name}  : ${partition_size} Kbyte"
}

function show_partition_message()
{
    grep -c '[mbr]' $1 > /dev/null
    if [ $? -eq 0 ]; then
        cp $1 ./show_sys_partition.tmp;
        sed -i '/^[\r;]/d' ./show_sys_partition.tmp;
        sed -i '/partition_start/d' ./show_sys_partition.tmp;
        sed -i '/user_type/d' ./show_sys_partition.tmp;
        sed -i 's/\[partition\]/------------------------------------/g' ./show_sys_partition.tmp;
        sed -i 's/[ "\r]//g' ./show_sys_partition.tmp;
        sed -i '/^[;]/d' ./show_sys_partition.tmp;
        sed -i 's/name/partition_name/g' ./show_sys_partition.tmp;
        sed -i 's/size/partition_size/g' ./show_sys_partition.tmp;
        echo "------------------------------------"
        while read line
        do
            if [ "$line" == "------------------------------------" ];then
                echo "$line"
            else
                echo "  $line" | sed 's/=/  : /g'
                echo "  $line" | grep "mbr" >> /dev/null
                if [ $? -eq 0 ]; then
                    read line
                    get_partition_mbr_size $line
                fi
                echo "$line" | grep "downloadfile" >> /dev/null
                if [ $? -eq 0 ]; then
                    get_partition_downfile_size $line
                fi
            fi
        done < ./show_sys_partition.tmp
        echo "------------------------------------"
        rm ./show_sys_partition.tmp
    else
        echo "==========input is not a partition file=========="
    fi
}

function sparse_ext4()
{
    local img=$1
    local sparse_img=$2

    if file $img | grep -q ext4 ;then
        echo "now make sparse ext4 img: $img"
    else
        echo "$img is not ext4 img"
        file $img
        return
    fi

    img2simg $img $sparse_img
}

# pack user resources to a vfat filesystem
# To use this, please add a folder "user-resource" in configs to save files, and add a partition to sys_partition.fex/sys_partition_nor.fex like this:
# [partition]
#   name         = user-res
#   size         = 1024	//size should be 32 aligned
#   downloadfile = "user-resource.fex"
#   user_type    = 0x8000
function make_user_res()
{
    printf "make user resource for : $1\n"
    local USER_RES_SYS_PARTITION=$1
    local USER_RES_PART_NAME=user-res
    local USER_RES_FILE=user-resource

    printf "handle partition ${USER_RES_PART_NAME}\n"
    local USER_RES_PART_DOWNLOAD_FILE=user-resource.fex
    local USER_RES_PART_SIZE=`sed -n "/${USER_RES_PART_NAME}/{N;p}" ${USER_RES_SYS_PARTITION} | awk '$0~"size"{print $3/2}'`
    local USER_RES_FILE_PATH=$CFG_TOP_DIR/${PACK_PLATFORM}/target/$PACK_IC/$PACK_IC-${PACK_BOARD}/configs/${USER_RES_FILE}

    if [ x"${USER_RES_PART_DOWNLOAD_FILE}" != x"" -a  x"${USER_RES_PART_SIZE}" != x"" ]; then
        rm -f ${LICHEE_PACK_OUT_DIR}/user-resource.fex
        mkfs.vfat ${LICHEE_PACK_OUT_DIR}/user-resource.fex -C ${USER_RES_PART_SIZE}
        if [ -d ${USER_RES_FILE_PATH} ]; then
            USER_RES_FILE_SIZE=`du --apparent-size --summarize "${USER_RES_FILE_PATH}" | awk '{print $1}'`
            printf "file size: ${USER_RES_FILE_SIZE}\n"
            printf "partition size: ${USER_RES_PART_SIZE}\n"
            if [ ${USER_RES_PART_SIZE} -le ${USER_RES_FILE_SIZE} ]; then
                printf "file size is larger than partition size, please check your configuration\n"
                printf "please enlarge size of ${USER_RES_PART_NAME} in sys_partition or remove some files in $USER_RES_FILE_PATH\n"
                exit -1
            fi
            mcopy -s -v -i ${LICHEE_PACK_OUT_DIR}/${USER_RES_PART_DOWNLOAD_FILE} ${USER_RES_FILE_PATH}/* ::
            if [ $? -ne 0 ]; then
                printf "mcopy file fail, exit\n"
                exit -1
            fi
        else
            printf "can not find ${USER_RES_FILE_PATH}, ignore it\n"
        fi
    else
        printf "no user resource partitions\n"
    fi
}

#[partition]
#    name         = app
#    size         = 10080
#    downloadfile = "app.fex"
#    user_type    = 0x8000
function make_app_res()
{
    local APP_PART_NAME=app
    cp $1 sys_partition_tmp_app.fex

    sed -i '/^[ \t]*downloadfile/d' sys_partition_tmp_app.fex
    maybe_busybox unix2dos sys_partition_tmp_app.fex
    script  sys_partition_tmp_app.fex > /dev/null
    update_mbr sys_partition_tmp_app.bin 1 sunxi_mbr_tmp_app.fex > /dev/null

    local APP_PART_DOWNLOAD_FILE=app.fex
    local APP_PART_FILE_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/build_dir/target/app
    local APP_PART_SIZE_IN_SECTOR=`parser_mbr sunxi_mbr_tmp_app.fex get_size_by_name ${APP_PART_NAME}`
	local TINA_TOOLS_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/staging_dir/host/bin

    if [ x${APP_PART_DOWNLOAD_FILE} != x'' -a  x${APP_PART_SIZE_IN_SECTOR} != x'' ]; then
        let APP_PART_SIZE_IN_K=$APP_PART_SIZE_IN_SECTOR/2
        echo "APP_PART_DOWNLOAD_FILE = ${LICHEE_PACK_OUT_DIR}/${APP_PART_DOWNLOAD_FILE}"
        rm -f ${LICHEE_PACK_OUT_DIR}/${APP_PART_DOWNLOAD_FILE}
        ${TINA_TOOLS_PATH}/make_ext4fs -l ${APP_PART_SIZE_IN_K}k -b 1024 -m 0 -j 1024 ${LICHEE_PACK_OUT_DIR}/${APP_PART_DOWNLOAD_FILE}  ${APP_PART_FILE_PATH}
    else
        printf "no app resource partitions\n"
    fi
}

#[partition]
#    name         = data
#    size         = 10080
#    downloadfile = "data.fex"
#    user_type    = 0x8000
function make_data_res()
{
    local DATA_PART_NAME=data
    cp $1 sys_partition_tmp_data.fex

    sed -i '/^[ \t]*downloadfile/d' sys_partition_tmp_data.fex
    maybe_busybox unix2dos sys_partition_tmp_data.fex
    script  sys_partition_tmp_data.fex > /dev/null
    update_mbr sys_partition_tmp_data.bin 1 sunxi_mbr_tmp_data.fex > /dev/null

    local DATA_PART_DOWNLOAD_FILE=data.fex
    local DATA_PART_DOWNLOAD_FILE_SPARSE=data_s.fex
    local DATA_PART_FILE_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/build_dir/target/data
    local DATA_PART_SIZE_IN_SECTOR=`parser_mbr sunxi_mbr_tmp_data.fex get_size_by_name ${DATA_PART_NAME}`
	local TINA_TOOLS_PATH=$CFG_TOP_DIR/out/$PACK_IC/$PACK_BOARD/$PACK_PLATFORM/staging_dir/host/bin

    if [ x${DATA_PART_DOWNLOAD_FILE} != x'' -a  x${DATA_PART_SIZE_IN_SECTOR} != x'0' ]; then
        let DATA_PART_SIZE_IN_K=$DATA_PART_SIZE_IN_SECTOR/2
        echo "DATA_PART_DOWNLOAD_FILE = ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE}"
        rm -f ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE}
        rm -f ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE_SPARSE}
        ${TINA_TOOLS_PATH}/make_ext4fs -l ${DATA_PART_SIZE_IN_K}k -b 1024 -m 0 -j 1024 ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE}  ${DATA_PART_FILE_PATH}
        sparse_ext4 ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE} ${LICHEE_PACK_OUT_DIR}/${DATA_PART_DOWNLOAD_FILE_SPARSE}
    else
        printf "no data resource partitions\n"
    fi
}

################################ Platform func ################################
function do_pack_android()
{
	local localpath=$(readlink -f $(pwd))
	local androidout=$(readlink -f ${ANDROID_IMAGE_OUT})
	local link_real=$(get_realpath $androidout $localpath)

	printf "packing for android\n"

	if [ -z "${ANDROID_IMAGE_OUT}" ] ; then
		pack_error "please specify ANDROID_IMAGE_OUT env"
		exit 1
	fi

	local fex_list=($(\gawk '$0~"^[[:space:]]*downloadfile[[:space:]]*="{print $NF}' sys_partition.fex | sed 's/[",\r,\n]//g'))
	fex_list+=(vendor_boot-debug.fex)

	local img_name=""
	for fex_name in ${fex_list[@]}; do
		img_name=${fex_name%\.fex}.img
		if [ -f ${ANDROID_IMAGE_OUT}/${img_name} ]; then
			ln -sf ${link_real}/${img_name} ${fex_name}
			echo "link ${img_name} -> ${fex_name}"
		fi
	done

	if [ -e $androidout/vmlinux ]; then
		export PATH=$PATH:${LICHEE_TOP_DIR}/build/bin
		local vmlinuxpath=$(dirname $(readlink -f $androidout/vmlinux))
		local vmlinuxname=$(basename $(readlink -f $androidout/vmlinux))
		(cd $vmlinuxpath && tar cf $localpath/vmlinux.tar.bz2 --use-compress-prog=lbzip2 $vmlinuxname)
		rm -rf vmlinux.fex
		ln -sf vmlinux.tar.bz2 vmlinux.fex
	fi

	if [ -n "${PACK_BOOT_PATH}" ] && [ "x${PACK_BOOT_PATH}" != "xnone" ]; then
		ln -sf $PACK_BOOT_PATH boot.fex
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		echo "secure"
		do_android_signature
	else
		echo "normal"
	fi
}

function prepare_mixed_androiddragonboard()
{
	local mixed_fw_type

	if [ "${PACK_TYPE}" != "android" ] || [ -z "$PACK_MIXED_FIRMWARE" ]; then
		return 0
	fi

	case "$PACK_MIXED_FIRMWARE" in
		dragonboard|dragonabts)
			mixed_fw_type="$PACK_MIXED_FIRMWARE"
			pack_info "${FUNCNAME[0]}: mixed firmware type: $mixed_fw_type"
			;;
		*)
			echo "Unsupport mixed firmware type: $PACK_MIXED_FIRMWARE"
			return 1
	esac

	(
		cd ${LICHEE_PACK_OUT_DIR}

		local localpath=$(readlink -f $(pwd))
		local mixedboardout=$(readlink -f ${CFG_PLAT_OUT}/../$mixed_fw_type)
		if [ ! -d $mixedboardout ]; then
			pack_error "${FUNCNAME[0]}: cannot find out path for $mixed_fw_type"
			exit 1
		fi

		local envpath=($LICHEE_BOARD_CONFIG_DIR/$mixed_fw_type $LICHEE_CHIP_CONFIG_DIR/configs/default)
		local partition=(bootloader_b:boot-resource.fex env_b:denv.fex
					boot_b:dboot.fex vendor_boot_b:vendor_boot.fex media_data)

		local item name linenum nstart nend nmax file

		for item in ${partition[@]}; do
			name=${item/:*}
			linenum=$(sed -n "/^\s*name\s*=\s*$name/=" sys_partition.fex)
			if [ -z "$linenum" ]; then
				pack_error "${FUNCNAME[@]}: leak neccery partition $name in sys_partition.fex"
				exit 1
			fi
		done

		for item in ${envpath[@]}; do
			if [ -e $item/env.cfg ]; then
				cp $item/env.cfg denv.cfg
				sed -i '/^\s*boot_normal=/s/\<boot\>/boot_b/g' denv.cfg
				generate_env_for_uboot denv.cfg $mixedboardout/env.img
				rm -rf denv.cfg
				break
			fi
		done

		if  [ ! -e $mixedboardout/env.img  ] || \
			[ ! -e $mixedboardout/boot.img ] || \
			[ ! -e $mixedboardout/rootfs.ext4 ] || \
			[ ! -e $LICHEE_BOARD_CONFIG_DIR/$mixed_fw_type/test_config.fex ]; then
			pack_error "${FUNCNAME[@]}: leak neccery img/fex for $mixed_fw_type"
			exit 1
		fi

		printf "prepare for mixed android/$mixed_fw_type packing...\n"
		for item in ${partition[@]}; do
			name=${item/:*}
			linenum=$(sed -n "/^\s*name\s*=\s*$name/=" sys_partition.fex)
			nstart=$linenum
			nend=$linenum
			nmax=$(wc -l sys_partition.fex | awk '{print $1}')
			while [ $nstart -gt 1 ]; do
				nstart=$((nstart-1))
				if [ -n "$(sed -n "$nstart p" sys_partition.fex | grep "^\s*\[\S\+\]")" ]; then
					break;
				fi
			done

			while [ $nend -lt $nmax ]; do
				nend=$((nend+1))
				if [ -n "$(sed -n "$nend p" sys_partition.fex | grep "^\s*\[\S\+\]")" ]; then
					break;
				fi
			done
			[ $nend -ne $nmax ] && nend=$((nend-1))

			file="$(sed -n "${nstart},${nend}p" sys_partition.fex | \
					awk -F= '/^[[:space:]]*downloadfile[[:space:]]*=/{print $2}')"
			dlfile=${e#*:}
			case $name in
				bootloader_b|env_b|boot_b|vendor_boot_b)
					if [ -z "$file" ]; then
						sed -i "$linenum a\ \ \ \ downloadfile = \"${item#*:}\"" sys_partition.fex
					fi
					;;
				media_data)
					local cmd="$nstart i"
					local size=$(stat $mixedboardout/rootfs.ext4 --format="%s")

					size=$(((size+32*1024*1024-1)/(16*1024*1024)*16))  # at least size + 16M, and 16M align

					if [ -z "$(grep "^\s*name\s*=\s*rootfs" sys_partition.fex)" ]; then
						cmd+="[partition]\n"
						cmd+="    name         = rootfs\n"
						cmd+="    size         = ${size}M\n"
						cmd+="    downloadfile = \"drootfs.fex\"\n"
						cmd+="    user_type    = 0x8000\n"
						cmd+="\n"
					fi
					[ "$cmd" != "$nstart i" ] && sed -i "$cmd" sys_partition.fex
					;;
			esac
		done

		# Delete "^M" under Windows
		sed -i 's|
||g' sys_partition.fex

		readcfg dragon_toc.cfg key_para key > /dev/null
		if [ $? -ne 0 ]; then
			[ -z "$(grep "^\s*onlykey=boot_b,\s*dboot.fex," dragon_toc.cfg)" ] && \
			sed -i 's|^\(\s*onlykey=boot_b,\s*\)\S*,|\1dboot.fex,|g'    dragon_toc.cfg

			[ -z "$(grep "^\s*onlykey=boot_b,\s*dboot.fex," dragon_toc.cfg)" ] && \
			echo "onlykey=boot_b,dboot.fex,SCPFirmwareContentCertPK" >> dragon_toc.cfg
		else
			if [ -z "$(grep "^\s*onlykey=boot_b,\s*dboot.fex," dragon_toc.cfg)" ]; then
				sed -i '/^optee=/a boot_b=SCPFirmwareContentCertPK' dragon_toc.cfg
				sed -i '/^item=optee/a\onlykey=boot_b,dboot.fex,boot_b.crtpt' dragon_toc.cfg
			fi
		fi

		cp $LICHEE_BOARD_CONFIG_DIR/$mixed_fw_type/test_config.fex .
		maybe_busybox dos2unix test_config.fex
		cp test_config.fex boot-resource/
		script test_config.fex > /dev/null
		cp test_config.bin boot-resource/

		cp $mixedboardout/env.img denv.fex
		cp $mixedboardout/boot.img dboot.fex
		cp $mixedboardout/rootfs.ext4 drootfs.fex
		echo "android:$PACK_MIXED_FIRMWARE" > mixed-image-type.txt
	)
	if [ $? -ne 0 ]; then
		pack_error "${FUNCNAME[0]} fail"
		return 1
	fi
	return 0
}

function do_pack_dragonboard()
{
	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	printf "packing for dragonboard\n"

	ln -sf ${link_real}/boot.img boot.fex
	ln -sf ${link_real}/rootfs.ext4 rootfs.fex
	ln -sf ${link_real}/rootfs.ubifs rootfs-ubifs.fex

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		do_signature
	else
		echo "normal"
	fi
}

function do_pack_dragonabts()
{
	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	printf "packing for dragonabts\n"

	ln -sf ${link_real}/boot.img boot.fex
	ln -sf ${link_real}/rootfs.ext4 rootfs.fex
	ln -sf ${link_real}/rootfs.ubifs rootfs-ubifs.fex

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		do_signature
	else
		echo "normal"
	fi
}

function do_pack_linux()
{
	local link_real=$(get_realpath ${LICHEE_PLAT_OUT} ./)
	local recovery_path=${link_real}/recovery.img

	printf "packing for linux\n"

	do_fit_image
	if [ $? -eq 0 ]; then
		[ -f kernel.itb ] && mv kernel.itb   kernel.fex
		[ -f kernel-dtb.itb ] && mv kernel-dtb.itb   kernel-dtb.fex
	else
		[ -f ${link_real}/bootB.img ] && ln -sf ${link_real}/bootB.img bootB.fex
		ln -sf ${link_real}/boot.img        boot.fex

		# Those files is ready for SPINor.
		ln -sf ${link_real}/uImage          kernel.fex
		if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
			ln -sf ${link_real}/rootfs.img rootfs_nor.fex
		else
			ln -sf ${link_real}/rootfs.squashfs rootfs_nor.fex
		fi
	fi

	if [ x"${PACK_PLATFORM}" = x"openwrt" ]; then
		ln -sf ${link_real}/rootfs.img     rootfs.fex
	else
		ln -sf ${link_real}/rootfs.ext4     rootfs.fex
	fi

	ln -sf ${link_real}/rootfs.ubifs     rootfs-ubifs.fex

	if [ -f "$recovery_path" ]; then
		ln -sf ${recovery_path}     recovery.fex
	fi

	if [ "x${PACK_SECURE}" = "xsecure" ]; then
		echo "secure"
		do_signature
	else
		echo "normal"
	fi
}

function create_kernel_fit_image()
{
	local its_name=$1

	printf "create_kernel_fit_image\n"

	if [ ! -f ${LICHEE_PACK_OUT_DIR}/${its_name}.its ]; then
		printf "can not found ${its_name}.its\n"
		return 1
	fi

	mkimage -f ${its_name}.its ${its_name}.itb
	if [ $? -ne 0 ]; then
		pack_error "mkimage ${its_name}.itb error\n"
		exit 1
	fi
}

function do_fit_image()
{
	printf "do_fit_image\n"

	create_kernel_fit_image kernel
	if [ $? -ne 0 ]; then
		return 1
	fi

	create_kernel_fit_image kernel-dtb
	if [ $? -ne 0 ]; then
		return 1
	fi
}

function main()
{
	local output_resources=${FLAGS_output_resources:-false}
	local from_resources=${FLAGS_from_resources}

	local support_secure_type
	case x$LICHEE_PACK_SECURE_TYPE in
		xnone|xsecure|xany)
			support_secure_type=$LICHEE_PACK_SECURE_TYPE
			;;
		x)
			support_secure_type=any
			;;
		*)
			pack_error "Unsupport pack secure type: $LICHEE_PACK_SECURE_TYPE"
			return 1
			;;
	esac

	if [ "$support_secure_type" != "any" ] && [ "$support_secure_type" != "$PACK_SECURE" ]; then
		pack_error "This platform only support secure type [$support_secure_type], but current using [$PACK_SECURE], please check!!!"
		pack_error "Now, we try using secure type [$support_secure_type]!!!"
		PACK_SECURE=$support_secure_type
	fi

	if [ "$output_resources" == "false" ] && [ -z "$from_resources" ]; then
		do_prepare
		do_ini_to_dts
		do_common
		do_pack_${PACK_TYPE}
		do_finish
		return $?
	fi

	if [ "$output_resources" == "true" ]; then
		do_prepare
		do_ini_to_dts
	elif [ -n "$from_resources" ]; then
		if [ ! -d $from_resources ]; then
			pack_error "Cannot find resources path: $from_resources"
			return 1
		fi

		local count=0
		while [ -e ${LICHEE_PACK_OUT_DIR} -a  $count -lt 20 ]; do
			rm -rf ${LICHEE_PACK_OUT_DIR}
			count=$((count+1))
		done
		cp -rax $from_resources ${LICHEE_PACK_OUT_DIR}
		(
			cd $LICHEE_OUT_DIR
			if [ "${LICHEE_PACK_OUT_DIR}" != "$LICHEE_OUT_DIR/pack_out" ]; then
				rm -rf pack_out
				ln -sf ${LICHEE_IC}/${LICHEE_BOARD}/pack_out pack_out
			fi
		)

		if [ "${PACK_PLATFORM}" == "android" ] && [ -n "$PACK_MIXED_FIRMWARE" ]; then
			local resource_type="$(cat ${LICHEE_PACK_OUT_DIR}/mixed-image-type.txt)"
			local mixed_fw_type="android:$PACK_MIXED_FIRMWARE"
			if [ "$resource_type" != "android:$PACK_MIXED_FIRMWARE" ]; then
				pack_error "mixed firmware type [$mixed_fw_type] but resource type [$resource_type]"
				exit 1
			fi
			pack_info "mixed firmware type [$mixed_fw_type]"
		fi

		cd ${LICHEE_PACK_OUT_DIR}
		do_common
		do_pack_${PACK_TYPE}
		do_finish
	fi
	return $?
}

main "$@"

2025-06-01_101035.png

#2 Re: 全志 SOC » 九鼎创展 A733 开发板使用记录 » 昨天 10:03:10

使用这个 img工具 解包之后,用beyondcompare比较,发现boot0*.fex 有差异

_20250601093603.jpg

#3 Re: 全志 SOC » 九鼎创展 A733 开发板使用记录 » 昨天 09:36:47

删除 longan/out/ 目录,重新编译 longan,然而,还是一样的问题

#4 Re: 全志 SOC » 九鼎创展 A733 开发板使用记录 » 2025-05-31 21:32:07

找到一个相关的问题,但是我的这个和命令长度没有关系:


【FAQ3027】 SDK所在目录路径过长引发固件异常无法启动.pdf

1.主题
SDK所在目录路径过长引发固件异常无法启动

2.问题背景
有客户反馈,sdk按如下目录放置,编译出的固件烧写后无法启动,错误如下:

/ibm/ExdroidData/workspace/mynewroot/jenkins/code/dailybuild/androidv/platform/android14

[2024-07-07 01:11:06.834698] [387]phy_dfs_clk3 = 150M
[2024-07-07 01:11:06.837708] [390]phy_dfs_clk0 = 1200M
[2024-07-07 01:11:06.841707] [392]DRAM MDFS VERSION INFO: V0.660
[2024-07-07 01:11:06.844748] [396]DRAM MDFS time =38136 ns
[2024-07-07 01:11:06.851745] [399]DRAM SIZE =4096 MBytes, para1 = 310a, para2 = 10001000, tpr13 = 6065
[2024-07-07 01:11:06.855749] [407]DRAM simple test OK.
[2024-07-07 01:11:06.857749] [410]dram size =4096
[2024-07-07 01:11:06.859749] [412]nsi init 2023-2-23
[2024-07-07 01:11:06.911773] [462]read toc1 from emmc 32800 sector
[2024-07-07 01:11:06.915730] [467]don't have rotpk, skip check
[2024-07-07 01:11:06.917719] [470]OLD version: 0.0
[2024-07-07 01:11:06.919729] [472]NEW version: 0.0
[2024-07-07 01:11:07.031703] [583]monitor entry=0x48000000
[2024-07-07 01:11:07.033702] [585]uboot entry=0x4a000000
[2024-07-07 01:11:07.036642] [588]optee entry=0x48600000
[2024-07-07 01:11:07.038641] [591]opensbi entry=0x0
[2024-07-07 01:11:07.040638] [593]no need rotpk flag
[2024-07-07 01:11:07.044622] [595]tunning data addr:0x4a0003e8
[2024-07-07 01:11:07.049625] [599]sec_mem_map[0]: addr = 0x48000000, size = 0x100000
[2024-07-07 01:11:07.055622] [604]sec_mem_map[1]: addr = 0x48600000, size = 0x100000
[2024-07-07 01:11:07.057653] [610]run out of boot0
[2024-07-07 01:11:07.067667] NOTICE:  BL31: v2.5(debug):55b180a27
[2024-07-07 01:11:07.071665] NOTICE:  BL31: Built : 11:09:52, Sep 18 2023
[2024-07-07 01:11:07.074610] NOTICE:  hardware check error1
[2024-07-07 01:11:07.077657] BACKTRACE: START: bl31_platform_setup
[2024-07-07 01:11:07.079655] 0: EL3: 0x480038a4
[2024-07-07 01:11:07.081653] 1: EL3: 0x48003b40
[2024-07-07 01:11:07.083616] 2: EL3: 0x48003a94
[2024-07-07 01:11:07.085619] 3: EL3: 0x480001e0
[2024-07-07 01:11:07.088622] BACKTRACE: END: bl31_platform_setup
[2024-07-07 01:11:07.089654] PANIC in EL3.
[2024-07-07 01:11:07.093608] x30            = 0x0000000048003b4c
[2024-07-07 01:11:07.096654] x0             = 0x0000000002500000
[2024-07-07 01:11:07.100609] x1             = 0x0000000000000060
[2024-07-07 01:11:07.103654] x2             = 0x0000000000000060
[2024-07-07 01:11:07.106609] x3             = 0x00000000ffffffc8
[2024-07-07 01:11:07.110608] x4             = 0x0000000000000034
[2024-07-07 01:11:07.113667] x5             = 0x0000000000000034
[2024-07-07 01:11:07.116619] x6             = 0x0000000000000004
[2024-07-07 01:11:07.120606] x7             = 0x0000000000000000
[2024-07-07 01:11:07.123654] x8             = 0x000000023fffffff
[2024-07-07 01:11:07.126603] x9             = 0x0000000048600000
[2024-07-07 01:11:07.130611] x10            = 0x0000000000000000
[2024-07-07 01:11:07.133654] x11            = 0x0000000000100000
[2024-07-07 01:11:07.137665] x12            = 0x0000000000000018
[2024-07-07 01:11:07.140618] x13            = 0x0000000000000000
[2024-07-07 01:11:07.143658] x14            = 0x0000000000000000
[2024-07-07 01:11:07.147657] x15            = 0x0000000000000000
[2024-07-07 01:11:07.150611] x16            = 0x0000000000000000
[2024-07-07 01:11:07.153651] x17            = 0x0000000000045400
[2024-07-07 01:11:07.157653] x18            = 0x0000000000000020
[2024-07-07 01:11:07.168273] x19            = 0x000000004800e3f6
[2024-07-07 01:11:07.168345] x20            = 0x0000000000000000
[2024-07-07 01:11:07.168360] x21            = 0x0000000000001890
[2024-07-07 01:11:07.170569] x22            = 0x0000000000000000
[2024-07-07 01:11:07.173624] x23            = 0x0000000000000000
[2024-07-07 01:11:07.177663] x24            = 0x0000000000000000
[2024-07-07 01:11:07.180668] x25            = 0x0000000000000000
[2024-07-07 01:11:07.184671] x26            = 0x0000000000000000
[2024-07-07 01:11:07.187621] x27            = 0x0000000000000000
[2024-07-07 01:11:07.190672] x28            = 0x0000000000000000
[2024-07-07 01:11:07.194658] x29            = 0x00000000480112c0
[2024-07-07 01:11:07.197625] scr_el3        = 0x0000000000000238
[2024-07-07 01:11:07.200677] sctlr_el3      = 0x0000000030cd183f
[2024-07-07 01:11:07.204676] cptr_el3       = 0x0000000000000000
[2024-07-07 01:11:07.207626] tcr_el3        = 0x000000008081351e
[2024-07-07 01:11:07.211638] daif           = 0x00000000000002c0
[2024-07-07 01:11:07.214678] mair_el3       = 0x00000000004404ff
[2024-07-07 01:11:07.217635] spsr_el3       = 0x00000000000001cd
[2024-07-07 01:11:07.221632] elr_el3        = 0x0000000000012ea4
[2024-07-07 01:11:07.224661] ttbr0_el3      = 0x000000004803e381
[2024-07-07 01:11:07.227617] esr_el3        = 0x00000000b2050b37
[2024-07-07 01:11:07.231620] far_el3        = 0x5ad7c3dbfffe3ff9
[2024-07-07 01:11:07.234664] spsr_el1       = 0x00000000000001cd
[2024-07-07 01:11:07.238658] elr_el1        = 0x0000000000000000
[2024-07-07 01:11:07.241683] spsr_abt       = 0x00000000f01f28b9
[2024-07-07 01:11:07.244659] spsr_und       = 0x00000000f0478217
[2024-07-07 01:11:07.248612] spsr_irq       = 0x00000000f00b8ebd
[2024-07-07 01:11:07.251658] spsr_fiq       = 0x00000000f40f6460
[2024-07-07 01:11:07.254613] sctlr_el1      = 0x0000000000c50838
[2024-07-07 01:11:07.258618] actlr_el1      = 0x0000000000000000
[2024-07-07 01:11:07.261660] cpacr_el1      = 0x0000000000000000
[2024-07-07 01:11:07.265661] csselr_el1     = 0x0000000000000000
[2024-07-07 01:11:07.268613] sp_el1         = 0x0000000000000000
[2024-07-07 01:11:07.271659] esr_el1        = 0x00000000b4897f9c
[2024-07-07 01:11:07.274616] ttbr0_el1      = 0x0000f63708ac0ce2
[2024-07-07 01:11:07.278663] ttbr1_el1      = 0x00000bfc5c0958d0
[2024-07-07 01:11:07.281624] mair_el1       = 0x44e048e000098aa4
[2024-07-07 01:11:07.285628] amair_el1      = 0x0000000000000000
[2024-07-07 01:11:07.288657] tcr_el1        = 0x0000000000000000
[2024-07-07 01:11:07.291610] tpidr_el1      = 0x3a0c50eb9150e67b
[2024-07-07 01:11:07.295614] tpidr_el0      = 0xdc178f81ebf9d7ff
[2024-07-07 01:11:07.298664] tpidrro_el0    = 0xfb10d70cdeff6571
[2024-07-07 01:11:07.301621] par_el1        = 0xff00000048000980
[2024-07-07 01:11:07.305628] mpidr_el1      = 0x0000000081000000
[2024-07-07 01:11:07.308625] afsr0_el1      = 0x0000000000000000
[2024-07-07 01:11:07.312624] afsr1_el1      = 0x0000000000000000
[2024-07-07 01:11:07.315625] contextidr_el1 = 0x0000000000000000
[2024-07-07 01:11:07.318667] vbar_el1       = 0x0000000000000000
[2024-07-07 01:11:07.322622] cntp_ctl_el0   = 0x0000000000000000
[2024-07-07 01:11:07.325666] cntp_cval_el0  = 0xff5f39fefd2bd7ce
[2024-07-07 01:11:07.328614] cntv_ctl_el0   = 0x0000000000000000
[2024-07-07 01:11:07.332623] cntv_cval_el0  = 0xd7f5971ac72c673d
[2024-07-07 01:11:07.335660] cntkctl_el1    = 0x0000000000000000
[2024-07-07 01:11:07.338663] sp_el0         = 0x00000000480112c0
[2024-07-07 01:11:07.342662] isr_el1        = 0x0000000000000000
[2024-07-07 01:11:07.345612] dacr32_el2     = 0x0000000000000000
[2024-07-07 01:11:07.348657] ifsr32_el2     = 0x0000000000000217
[2024-07-07 01:11:07.352666] cpuectlr_el1   = 0x000000002808bc00
[2024-07-07 01:11:07.355622] icc_hppir0_el1 = 0x00000000000003ff
[2024-07-07 01:11:07.359625] icc_hppir1_el1 = 0x00000000000003ff
[2024-07-07 01:11:07.362686] icc_ctlr_el3   = 0x0000000000028400
[2024-07-07 01:11:07.366678] gicd_ispendr regs (Offsets 0x200-0x278)
[2024-07-07 01:11:07.367626] Offset			Value
[2024-07-07 01:11:07.370673] 0x200:		 0x0000000000000000
[2024-07-07 01:11:07.373673] 0x208:		 0x0000000000000000
[2024-07-07 01:11:07.375675] 0x210:		 0x0000000000000000
[2024-07-07 01:11:07.378592] 0x218:		 0x0000000000000000
[2024-07-07 01:11:07.380634] 0x220:		 0x0000000000000000
[2024-07-07 01:11:07.383664] 0x228:		 0x0000000000000000
[2024-07-07 01:11:07.386613] 0x230:		 0x0000000000000000
[2024-07-07 01:11:07.388617] 0x238:		 0x0000000000000000
[2024-07-07 01:11:07.391612] 0x240:		 0x0000000000000000
[2024-07-07 01:11:07.394648] 0x248:		 0x0000000000000000
[2024-07-07 01:11:07.396647] 0x250:		 0x0000000000000000
[2024-07-07 01:11:07.399601] 0x258:		 0x0000000000000000
[2024-07-07 01:11:07.401601] 0x260:		 0x0000000000000000
[2024-07-07 01:11:07.404653] 0x268:		 0x0000000000000000
[2024-07-07 01:11:07.407609] 0x270:		 0x0000000000000000
[2024-07-07 01:11:07.409613] 0x278:		 0x0000000000000000

3.原因分析
当前编译工具对路径长度有要求。如果longan所在的路径过长,会引起编译时image异常。当前所支持的bsp的绝对路径长度为83个字符,如android sdk,则为包含longan目录时的长度,如:

/ibm/ExdroidData/workspace/mynewroot/jenkins/code/dailybuild/androidv/platform/android14/longan
长度以及超过83字符限制。

4.解决措施
缩短sdk所在目录长度。

#5 Re: 全志 SOC » 九鼎创展 A733 开发板使用记录 » 2025-05-31 21:24:40

烧录自己编译的固件,出现:

......


[225]HELLO! BOOT0 is starting!
[228]BOOT0 commit : {cfda5fbe}
[237]volume key pressed!
[240][mmc]: mmc driver ver 2024-03-20 10:36
[250][mmc]: Wrong media type 0x0, but host sdc2, try mmc first
[256][mmc]: ***Try MMC card 2***
[278][mmc]: RMCA OK!
[284][mmc]: MMC 5.1
[286][mmc]: HSSDR52/SDR25 8 bit
[289][mmc]: 50000000 Hz
[292][mmc]: 29880 MB
[294][mmc]: ***SD/MMC 2 init OK!!!***
[299]DRAM BOOT DRIVE INFO: V0.599
[304]DRAM_VCC set to 560 mv
[307]DRAM CLK =1800 MHZ
[309]DRAM Type =9 (8:LPDDR4,9:LPDDR5)
[435]Training result is = 7
[438]DRAM Pstate 0 training, frequency is 1800 Mhz
[447]Actual DRAM SIZE =6144 M
[449]DRAM SIZE =6144 MBytes, para1 = a10a, para2 = 18001001, dram_tpr13 = 10061
[464]DRAM simple test OK.
[505]error: dtb not found for scp
[510]tunning data addr:0x4a0003e8
[513]Jump to ATF: monitor_base = 0x48000000, uboot_base = 0x4a000000, optee_base = 0x0
NOTICE:  BL31: OP-TEE 32bit detected
NOTICE:  BL31: U-BOOT 32bit detected
NOTICE:  BL31: v2.5(debug):eec78cd3c
NOTICE:  BL31: Built : 14:02:13, Oct 29 2024
NOTICE:  hardware check error1
BACKTRACE: START: bl31_platform_setup
0: EL3: 0x48003c9c
1: EL3: 0x4800407c
2: EL3: 0x48003f78
3: EL3: 0x480001f0
BACKTRACE: END: bl31_platform_setup
PANIC in EL3.
x30            = 0x0000000048004088
x0             = 0x0000000002500000
x1             = 0x0000000000000060
x2             = 0x0000000000000060
x3             = 0x00000000ffffffc8
x4             = 0x0000000000000034
x5             = 0x0000000000000034
x6             = 0x0000000000000004
x7             = 0x0000000000000000
x8             = 0x000000023fffffff
x9             = 0x0000000048013000
x10            = 0x0000000000000000
x11            = 0x0000000000000000
x12            = 0x0000000000000010
x13            = 0x0000000000000000
x14            = 0x0000000000000000
x15            = 0x0000000000000000
x16            = 0x0000000000000000
x17            = 0x0000000000048c00
x18            = 0x0000000000000020
x19            = 0x000000004800f4b4
x20            = 0x0000000000000000
x21            = 0x0000000000001903
x22            = 0x0000000000000000
x23            = 0x0000000000000000
x24            = 0x0000000000000000
x25            = 0x0000000000000000
x26            = 0x0000000000000000
x27            = 0x0000000000000000
x28            = 0x0000000000000000
x29            = 0x0000000048014280
scr_el3        = 0x0000000000000238
sctlr_el3      = 0x0000000030cd183f
cptr_el3       = 0x0000000000000000
tcr_el3        = 0x000000008081351e
daif           = 0x00000000000002c0
mair_el3       = 0x00000000004404ff
spsr_el3       = 0x00000000000001cd
elr_el3        = 0x0000000000000000
ttbr0_el3      = 0x0000000048041001
esr_el3        = 0x0000000000000000
far_el3        = 0x0000000000000000
spsr_el1       = 0x00000000000001cd
elr_el1        = 0x0000000000000000
spsr_abt       = 0x00000000400bfc0e
spsr_und       = 0x00000000f08378cd
spsr_irq       = 0x0000000034037e06
spsr_fiq       = 0x0000000030077c14
sctlr_el1      = 0x0000000000c50838
actlr_el1      = 0x0000000000000000
cpacr_el1      = 0x0000000000000000
csselr_el1     = 0x0000000000000000
sp_el1         = 0x0000000000000000
esr_el1        = 0x00000000000c0000
ttbr0_el1      = 0x000000003a3f7f7c
ttbr1_el1      = 0x000000080c7f7f7c
mair_el1       = 0x44e048e000098aa4
amair_el1      = 0x0000000000000000
tcr_el1        = 0x0000000000000000
tpidr_el1      = 0x7f3fff00fdff7f00
tpidr_el0      = 0x7f007f8000ff0800
tpidrro_el0    = 0x00000000ff0c0080
par_el1        = 0xff00000048000980
mpidr_el1      = 0x0000000081000000
afsr0_el1      = 0x0000000000000000
afsr1_el1      = 0x0000000000000000
contextidr_el1 = 0x0000000000000000
vbar_el1       = 0x0000000000000000
cntp_ctl_el0   = 0x0000000000000000
cntp_cval_el0  = 0xf6de00005fffeeee
cntv_ctl_el0   = 0x0000000000000000
cntv_cval_el0  = 0xffde00005fffffef
cntkctl_el1    = 0x0000000000000000
sp_el0         = 0x0000000048014280
isr_el1        = 0x0000000000000000
cpuectlr_el1   = 0x000000002808bc00
icc_hppir0_el1 = 0x00000000000003ff
icc_hppir1_el1 = 0x00000000000003ff
icc_ctlr_el3   = 0x0000000000028400
gicd_ispendr regs (Offsets 0x200-0x278)
Offset                  Value
0x200:           0x0000000000000000
0x208:           0x0000000000000000
0x210:           0x0000000000000000
0x218:           0x0000000000000000
0x220:           0x0000000000000000
0x228:           0x0000000000000000
0x230:           0x0000000000000000
0x238:           0x0000000000000000
0x240:           0x0000000000000000
0x248:           0x0000000000000000
0x250:           0x0000000000000000
0x258:           0x0000000000000000
0x260:           0x0000000000000000
0x268:           0x0000000000000000
0x270:           0x0000000000000000
0x278:           0x0000000000000000

_20250531212328.jpg

不勾选任何选项刷出厂固件,可以正常启动。

#8 Re: 全志 SOC » 九鼎创展 A733 开发板使用记录 » 2025-05-31 21:21:43

出厂固件的开机日志:

[11677]Training result is = 7
[11680]DRAM Pstate 0 training, frequency is 1800 Mhz
[11688]Actual DRAM SIZE =6144 M
[11691]DRAM SIZE =6144 MBytes, para1 = a10a, para2 = 18001001, dram_tpr13 = 10061
[11701]DRAM simple test OK.
[11704]rtc[3] value = 0xb00f
[11707]rtc[7] value = 0x2
[11709]init dram ok


U-Boot 2018.07 (Mar 31 2025 - 06:54:43 +0000) Allwinner Technology

[13.838]CPU:   Allwinner Family
[13.841]Model: sun60iw2
I2C:   ready
[13.901]DRAM:  512 MiB
[13.906]Relocation Offset is: 15dac000
[13.956]sunxi_drm_dsi_post_bind:706
[13.960]secure enable bit: 0
[13.963]PMU: AXP8191
[13.965]PMU: AXP8191 VER_A
[13.967]PMU: pmu_axp8191 found
FDT ERROR:fdt_get_regulator_name:get property handle twi-supply error:FDT_ERR_INTERNAL
[13.979]gpio_bias, pc_bias:   -1, pc_supply: not set
[13.984]gpio_bias, pl_bias:   -1, pl_supply: not set
[13.989]BMU: no found
[13.991][AXP8191] onoff status: 0x50 = 0x0, 0x51 = 0x0
[13.996][AXP8191] charge status: 0x4 = 0x0
[14.000]CPU=1014 MHz,PLL6=1200 Mhz,AHB=200 Mhz, APB1=24Mhz  MBus=600Mhz
[14.006]gic: normal mode
[14.008]sunxi flash type@0 not support fast burn key
[14.013]sunxi flash map init
[14.018]init_clocks:finish
[14.020]flash init start
[14.022]workmode = 16,storage type = 0
try card 2
set card number 2
get card number 2
[14.030][mmc]: mmc driver ver uboot2018:2024-10-18 9:01:00
[14.039][mmc]: Is not Boot mode!
[14.041][mmc]: SUNXI SDMMC Controller Version:0x50610
[14.049][mmc]: 200 MHz...
[14.051][mmc]: sample: 23 - 108(ps)
[14.054][mmc]: ds: 23 - 108(ps)
[14.061][mmc]: ************Try SD card 2************
[14.066][mmc]: mmc 2 cmd timeout 100 status 100
[14.070][mmc]: smc 2 err, cmd 8,  RTO
[14.074][mmc]: mmc 2 close bus gating and reset
[14.079][mmc]: mmc 2 cmd timeout 100 status 100
[14.083][mmc]: smc 2 err, cmd 55,  RTO
[14.086][mmc]: mmc 2 close bus gating and reset
[14.090][mmc]: ************Try MMC card 2************
[14.199][mmc]: mmc 2 cmd timeout 100 status 100
[14.203][mmc]: smc 2 err, cmd 8,  RTO
[14.206][mmc]: mmc 2 close bus gating and reset
[14.211][mmc]: mmc 2 cmd timeout 100 status 100
[14.215][mmc]: smc 2 err, cmd 55,  RTO
[14.219][mmc]: mmc 2 close bus gating and reset
[14.234][mmc]: gen_tuning_blk_bus8: total blk 10
[14.239][mmc]: gen_tuning_blk_bus4: total blk 6
[14.243][mmc]: Using 8 bit tuning now
[14.278][mmc]: write_tuning_try_freq: write ok
[14.283][mmc]: Pattern compare ok
[14.286][mmc]: Write tuning pattern ok
[14.289][mmc]: ================== HSSDR52_SDR25...
[14.294][mmc]: skip freq 400000
[14.297][mmc]: skip freq 25000000
[14.300][mmc]: freq: 2-50000000-64-4
[15.069][mmc]: [0-63|64]
[15.071][mmc]: ================== HS200_SDR104...
[15.076][mmc]: skip freq 400000
[15.078][mmc]: skip freq 25000000
[15.081][mmc]: freq: 2-50000000-64-4
[15.840][mmc]: freq: 3-100000000-64-4
[16.539][mmc]: freq: 4-150000000-64-4
[17.157][mmc]: freq: 5-200000000-64-4
[17.756][mmc]: [0-62|63]
[17.759][mmc]: [0-62|63]
[17.761][mmc]: [0-0|1] [7-62|56]
[17.764][mmc]: [0-15|16] [23-61|39]
[17.767][mmc]: ================== HSDDR52_DDR50...
[17.772][mmc]: skip freq 400000
[17.775][mmc]: freq: 1-25000000-64-4
[18.503][mmc]: freq: 2-50000000-64-4
[19.149][mmc]: [0-59|60]
[19.151][mmc]: [0-44|45] [47-59|13]
[19.154][mmc]: ================== HS400...
[19.158][mmc]: skip freq 400000
[19.161][mmc]: skip freq 25000000
[19.164][mmc]: freq: 2-50000000
[19.189][mmc]: freq: 3-100000000
[19.213][mmc]: freq: 4-150000000
[19.235][mmc]: freq: 5-200000000
[19.257][mmc]: speed mode: HS400
[19.260][mmc]: [0-63|64]
[19.262][mmc]: [0-63|64]
[19.265][mmc]: [0-3|4] [7-63|57]
[19.268][mmc]: [0-20|21] [23-63|41]
[19.271][mmc]: skip freq 400000
[19.274][mmc]: skip freq 25000000
[19.277][mmc]: freq: 2-50000000-64-4
[19.963][mmc]: freq: 3-100000000-64-4
[20.400][mmc]: freq: 4-150000000-64-4
[20.679][mmc]: freq: 5-200000000-64-4
[20.888][mmc]: [2-63|62]
[20.890][mmc]: [2-41|40]
[20.892][mmc]: [2-26|25]
[20.895][mmc]: *** hs400 200m: data win=10, delay cell = 108 ***
[20.900][mmc]: [2-19|18]
[20.903][mmc]: DS26/SDR12: 0xffffffff 0xffffffff
[20.907][mmc]: HSSDR52/SDR25: 0xff20ffff 0xffffffff
[20.912][mmc]: HSDDR52/DDR50: 0xff161eff 0xffffffff
[20.916][mmc]: HS200/SDR104: 0x1f1fffff 0xffff2a23
[20.921][mmc]: HS400: 0x1621ffff 0xffff0b0e
[20.925][mmc]: HS400: 0x2020ffff 0xffff2b23
[20.929][mmc]: Best spd md: 4-HS400, freq: 5-200000000, Bus width: 8
[20.935]Loading Environment from SUNXI_FLASH... OK
[20.940]try to burn key
[20.942]out of usb burn from boot: not boot mode
Hit any key to stop autoboot:  0
sunxi work mode=0x10
run usb efex
buf queue page size = 65536
delay time 2500
usb init ok
set address 0xe
set address 0xe ok
set address 0xf
set address 0xf ok
SUNXI_EFEX_ERASE_TAG
erase_flag = 0x12
origin_erase_flag = 0x1
FEX_CMD_fes_verify_status
FEX_CMD_fes_verify last err=0
the 0 mbr table is ok
the 1 mbr table is ok
the 2 mbr table is ok
the 3 mbr table is ok
*************MBR DUMP***************
total mbr part 29

part[0] name      :bootloader_a
part[0] classname :DISK
part[0] addrlo    :0x8000
part[0] lenlo     :0x10000
part[0] user_type :32768
part[0] keydata   :0
part[0] ro        :0

part[1] name      :bootloader_b
part[1] classname :DISK
part[1] addrlo    :0x18000
part[1] lenlo     :0x10000
part[1] user_type :32768
part[1] keydata   :0
part[1] ro        :0

part[2] name      :env_a
part[2] classname :DISK
part[2] addrlo    :0x28000
part[2] lenlo     :0x200
part[2] user_type :32768
part[2] keydata   :0
part[2] ro        :0

part[3] name      :env_b
part[3] classname :DISK
part[3] addrlo    :0x28200
part[3] lenlo     :0x200
part[3] user_type :32768
part[3] keydata   :0
part[3] ro        :0

part[4] name      :boot_a
part[4] classname :DISK
part[4] addrlo    :0x28400
part[4] lenlo     :0x20000
part[4] user_type :32768
part[4] keydata   :0
part[4] ro        :0

part[5] name      :boot_b
part[5] classname :DISK
part[5] addrlo    :0x48400
part[5] lenlo     :0x20000
part[5] user_type :32768
part[5] keydata   :0
part[5] ro        :0

part[6] name      :vendor_boot_a
part[6] classname :DISK
part[6] addrlo    :0x68400
part[6] lenlo     :0x10000
part[6] user_type :32768
part[6] keydata   :0
part[6] ro        :0

part[7] name      :vendor_boot_b
part[7] classname :DISK
part[7] addrlo    :0x78400
part[7] lenlo     :0x10000
part[7] user_type :32768
part[7] keydata   :0
part[7] ro        :0

part[8] name      :init_boot_a
part[8] classname :DISK
part[8] addrlo    :0x88400
part[8] lenlo     :0x4000
part[8] user_type :32768
part[8] keydata   :0
part[8] ro        :0

part[9] name      :init_boot_b
part[9] classname :DISK
part[9] addrlo    :0x8c400
part[9] lenlo     :0x4000
part[9] user_type :32768
part[9] keydata   :0
part[9] ro        :0

part[10] name      :super
part[10] classname :DISK
part[10] addrlo    :0x90400
part[10] lenlo     :0x700000
part[10] user_type :32768
part[10] keydata   :0
part[10] ro        :0

part[11] name      :misc
part[11] classname :DISK
part[11] addrlo    :0x790400
part[11] lenlo     :0x8000
part[11] user_type :32768
part[11] keydata   :0
part[11] ro        :0

part[12] name      :vbmeta_a
part[12] classname :DISK
part[12] addrlo    :0x798400
part[12] lenlo     :0x100
part[12] user_type :32768
part[12] keydata   :0
part[12] ro        :0

part[13] name      :vbmeta_b
part[13] classname :DISK
part[13] addrlo    :0x798500
part[13] lenlo     :0x100
part[13] user_type :32768
part[13] keydata   :0
part[13] ro        :0

part[14] name      :vbmeta_system_a
part[14] classname :DISK
part[14] addrlo    :0x798600
part[14] lenlo     :0x80
part[14] user_type :32768
part[14] keydata   :0
part[14] ro        :0

part[15] name      :vbmeta_system_b
part[15] classname :DISK
part[15] addrlo    :0x798680
part[15] lenlo     :0x80
part[15] user_type :32768
part[15] keydata   :0
part[15] ro        :0

part[16] name      :vbmeta_vendor_a
part[16] classname :DISK
part[16] addrlo    :0x798700
part[16] lenlo     :0x80
part[16] user_type :32768
part[16] keydata   :0
part[16] ro        :0

part[17] name      :vbmeta_vendor_b
part[17] classname :DISK
part[17] addrlo    :0x798780
part[17] lenlo     :0x80
part[17] user_type :32768
part[17] keydata   :0
part[17] ro        :0

part[18] name      :frp
part[18] classname :DISK
part[18] addrlo    :0x798800
part[18] lenlo     :0x400
part[18] user_type :32768
part[18] keydata   :32768
part[18] ro        :0

part[19] name      :empty
part[19] classname :DISK
part[19] addrlo    :0x798c00
part[19] lenlo     :0x7800
part[19] user_type :32768
part[19] keydata   :0
part[19] ro        :0

part[20] name      :metadata
part[20] classname :DISK
part[20] addrlo    :0x7a0400
part[20] lenlo     :0x8000
part[20] user_type :32768
part[20] keydata   :0
part[20] ro        :0

part[21] name      :treadahead
part[21] classname :DISK
part[21] addrlo    :0x7a8400
part[21] lenlo     :0x30000
part[21] user_type :32768
part[21] keydata   :0
part[21] ro        :0

part[22] name      :private
part[22] classname :DISK
part[22] addrlo    :0x7d8400
part[22] lenlo     :0x8000
part[22] user_type :32768
part[22] keydata   :0
part[22] ro        :0

part[23] name      :dtbo_a
part[23] classname :DISK
part[23] addrlo    :0x7e0400
part[23] lenlo     :0x1000
part[23] user_type :32768
part[23] keydata   :0
part[23] ro        :0

part[24] name      :dtbo_b
part[24] classname :DISK
part[24] addrlo    :0x7e1400
part[24] lenlo     :0x1000
part[24] user_type :32768
part[24] keydata   :0
part[24] ro        :0

part[25] name      :media_data
part[25] classname :DISK
part[25] addrlo    :0x7e2400
part[25] lenlo     :0x8000
part[25] user_type :32768
part[25] keydata   :0
part[25] ro        :0

part[26] name      :Reserve0
part[26] classname :DISK
part[26] addrlo    :0x7ea400
part[26] lenlo     :0x20000
part[26] user_type :32768
part[26] keydata   :0
part[26] ro        :0

part[27] name      :pstore
part[27] classname :DISK
part[27] addrlo    :0x80a400
part[27] lenlo     :0x10000
part[27] user_type :32768
part[27] keydata   :0
part[27] ro        :0

part[28] name      :UDISK
part[28] classname :DISK
part[28] addrlo    :0x81a400
part[28] lenlo     :0x0
part[28] user_type :33024
part[28] keydata   :0
part[28] ro        :0

[24.598]erase all part start
need erase flash: 18
[24.603][mmc]: erase from: 0, to: 61194239, cnt: 61194240, erase_group: 1024
[25.101][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x1e9 ms
[25.107]read item0 copy0
[25.117]Item0 (Map) magic is bad
[25.119]the secure storage item0 copy0 magic is bad
[25.131]Item0 (Map) magic is bad
[25.134]the secure storage item0 copy1 magic is bad
[25.138]Item0 (Map) magic is bad
[25.141]the secure storage map is empty
[25.159]erase secure storage: 0 ok
SUNXI_EFEX_MBR_TAG
mbr size = 0x10000
write primary GPT success
write Backup GPT success
[25.173]update partition map
FEX_CMD_fes_verify_status
FEX_CMD_fes_verify last err=0
******Has init
FEX_CMD_fes_verify_value, start 0x8000, size high 0x0:low 0x111d400
FEX_CMD_fes_verify_value 0xa14dbd74
FEX_CMD_fes_verify_value, start 0x28000, size high 0x0:low 0x20000
FEX_CMD_fes_verify_value 0xf00b1936
FEX_CMD_fes_verify_value, start 0x28400, size high 0x0:low 0x4000000
FEX_CMD_fes_verify_value 0x2d9ccd73
FEX_CMD_fes_verify_value, start 0x68400, size high 0x0:low 0x2000000
FEX_CMD_fes_verify_value 0x7435dd4a
FEX_CMD_fes_verify_value, start 0x88400, size high 0x0:low 0x800000
FEX_CMD_fes_verify_value 0xbad6702e
FEX_CMD_fes_verify_value, start 0x790400, size high 0x0:low 0x1000000
FEX_CMD_fes_verify_value 0xb961f417
FEX_CMD_fes_verify_value, start 0x798400, size high 0x0:low 0x2000
FEX_CMD_fes_verify_value 0x81ff878d
FEX_CMD_fes_verify_value, start 0x798600, size high 0x0:low 0x1000
FEX_CMD_fes_verify_value 0xd3178e38
FEX_CMD_fes_verify_value, start 0x798700, size high 0x0:low 0x1000
FEX_CMD_fes_verify_value 0xccfd9b0c
FEX_CMD_fes_verify_value, start 0x7e0400, size high 0x0:low 0x200000
FEX_CMD_fes_verify_value 0x9d9c6d85
FEX_CMD_fes_verify_value, start 0x7ea400, size high 0x0:low 0x1000000
FEX_CMD_fes_verify_value 0x0
bootfile_mode=4
SUNXI_EFEX_BOOT1_TAG
boot1 size = 0x13c000, max size = 0x400000
uboot size = 0x13c000
storage type = 2
FEX_CMD_fes_verify_status
FEX_CMD_fes_verify last err=0
bootfile_mode=4
SUNXI_EFEX_BOOT0_TAG
boot0 size = 0x3c000
[68.943][mmc]: write mmc 2 info ok
storage type = 2
FEX_CMD_fes_verify_status
FEX_CMD_fes_verify last err=0
sunxi_efex_next_action=2
exit usb
next work 2
SUNXI_UPDATE_NEXT_ACTION_REBOOT▒......


[176]HELLO! BOOT0 is starting!
[179]BOOT0 commit : {cfda5fbe}
[188]volume key pressed!
[190][mmc]: mmc driver ver 2024-03-20 10:36
[200][mmc]: Wrong media type 0x0, but host sdc2, try mmc first
[206][mmc]: ***Try MMC card 2***
[228][mmc]: RMCA OK!
[235][mmc]: MMC 5.1
[237][mmc]: HSSDR52/SDR25 8 bit
[240][mmc]: 50000000 Hz
[242][mmc]: 29880 MB
[244][mmc]: ***SD/MMC 2 init OK!!!***
[249]DRAM BOOT DRIVE INFO: V0.599
[254]DRAM_VCC set to 560 mv
[257]DRAM CLK =1800 MHZ
[259]DRAM Type =9 (8:LPDDR4,9:LPDDR5)
[386]Training result is = 7
[388]DRAM Pstate 0 training, frequency is 1800 Mhz
[397]Actual DRAM SIZE =6144 M
[400]DRAM SIZE =6144 MBytes, para1 = a10a, para2 = 18001001, dram_tpr13 = 10061
[414]DRAM simple test OK.
[456]error: dtb not found for scp
[461]tunning data addr:0x4a0003e8
[464]Jump to ATF: monitor_base = 0x48000000, uboot_base = 0x4a000000, optee_base = 0x0
NOTICE:  BL31: OP-TEE 32bit detected
NOTICE:  BL31: U-BOOT 32bit detected
NOTICE:  BL31: v2.5(debug):eec78cd3c
NOTICE:  BL31: Built : 14:02:13, Oct 29 2024
NOTICE:  BL31: No DTB found.
ERROR:   Error initializing runtime service opteed_fast


U-Boot 2018.07 (Mar 31 2025 - 06:54:43 +0000) Allwinner Technology

[00.511]CPU:   Allwinner Family
[00.514]Model: sun60iw2
I2C:   ready
[00.574]DRAM:  6 GiB
[00.578]Relocation Offset is: 75dac000
[00.634]secure enable bit: 0
[00.637]PMU: AXP8191
[00.639]PMU: AXP8191 VER_A
FDT ERROR:fdt_get_regulator_name:get property handle twi-supply error:FDT_ERR_INTERNAL
[00.651][AXP8191] onoff status: 0x50 = 0x0, 0x51 = 0x0
[00.656][AXP8191] charge status: 0x4 = 0x0
[00.660]CPU=1014 MHz,PLL6=1200 Mhz,AHB=200 Mhz, APB1=24Mhz  MBus=600Mhz
[00.666]gic: sec monitor mode
[00.671]flash init start
[00.673]workmode = 0,storage type = 2
[00.677][mmc]: mmc driver ver uboot2018:2024-10-18 9:01:00
[00.685][mmc]: SUNXI SDMMC Controller Version:0x50610
[00.695][mmc]: 200 MHz...
[00.697][mmc]: sample: 23 - 108(ps)
[00.700][mmc]: ds: 23 - 108(ps)
[00.718][mmc]: Best spd md: 4-HS400, freq: 5-200000000, Bus width: 8
[00.724]sunxi flash init ok
[00.740]Loading Environment from SUNXI_FLASH... [00.751]the secure storage item0 copy0 magic is bad
[00.763]the secure storage item0 copy1 magic is bad
erase secure storage failed
OK
[00.827]NOT support bridge yet
[00.829]Warn: no find panel or bridge
[00.837]failed to request regulator(avdd-supply): -22
[00.842]failed to request regulator_vol(avdd-output-voltage): -22
[00.848]failed to request regulator(avee-supply): -22
[00.852]failed to request regulator_vol(avee-output-voltage): -22
** Unrecognized filesystem type **
[00.868]get file(disp_rsl.fex) size from Reserve0 error
dsi0@5506000:  detailed mode clock 50000 kHz, flags[0]
    H: 1024 1174 1194 1344
    V: 0600 0608 0611 0635
bus_format: 0
[00.884]hdmi@5520000 disconnected
[00.887]bad framebuffer width 0
[00.904]m:6, m0:1, m1:6, m2:3, m3:12
[01.816]failed to display uboot logo for disp 64
[01.827]the secure storage item0 copy0 magic is bad
[01.838]the secure storage item0 copy1 magic is bad
[01.843]usb burn from boot
delay time 0
[01.849]usb prepare ok
[02.057]usb sof ok
[02.059]usb probe ok
[02.061]usb setup ok
set address 0x10
set address 0x10 ok
set address 0x11
set address 0x11 ok
[02.467]do_burn_from_boot usb : have no handshake
skip update boot_param
List file under ULI/factory
** Unrecognized filesystem type **
[02.481]update part info
[02.485]battery temp is -1
[02.502]update bootcmd
[02.570]change working_fdt 0xbbd5be30 to 0xbbd2be30
ret 0
[02.690]no battery, disabled battery functons
[02.696]update dts
Hit any key to stop autoboot:  0
Android's image name: arm64
kernel  addr 0x40080000 0x4289a000 exceed boot_a scope
boot_a  addr 0x4007f000 0x4289a000
ERROR: reserving fdt memory region failed (addr=bbe31000 size=258000)
[03.033]Starting kernel ...

[03.036]total: 3036 ms

[03.038][mmc]: mmc exit start
[03.055][mmc]: mmc 2 exit ok
NOTICE:  [SCP] :wait arisc ready....
NOTICE:  [SCP] :arisc version: [c82a3c8d0b638500aa1ffe037d00fa24cf20a903-dirty]
NOTICE:  [SCP] :arisc startup ready
NOTICE:  [SCP] :arisc startup notify message feedback
NOTICE:  [SCP] :sunxi-arisc driver is starting
NOTICE:  BL3-1: Next image address = 0x40080000
NOTICE:  BL3-1: Next image spsr = 0x3c5
[    0.000000][    T0] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[    0.000000][    T0] Linux version 5.15.119-gc82a3c8d0b63-dirty (xtx@ubuntu-201) (Android (8490178, based on r450784d) clang version 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0cca074e9238af8b4106c30add4418f6), LLD 14.0.6) #13 SMP PREEMPT Mon Mar 31 06:56:51 UTC 2025
[    0.000000][    T0] Machine model: sun60iw2
[    0.000000][    T0] Stack Depot is disabled
[    0.000000][    T0] KVM is not available. Ignoring kvm-arm.mode
[    0.000000][    T0] earlycon: uart8250 at MMIO32 0x0000000002500000 (options '')
[    0.000000][    T0] printk: bootconsole [uart8250] enabled
[    0.000000][    T0] efi: UEFI not found.
[    0.000000][    T0] [Firmware Bug]: Kernel image misaligned at boot, please fix your bootloader!
[    0.000000][    T0] OF: reserved mem: 0x0000000048000000..0x0000000048ffffff (16384 KiB) map non-reusable bl31
[    0.000000][    T0] Zone ranges:
[    0.000000][    T0]   DMA32    [mem 0x0000000040000000-0x00000000ffffffff]
[    0.000000][    T0]   Normal   [mem 0x0000000100000000-0x00000001bfffffff]
[    0.000000][    T0] Movable zone start for each node
[    0.000000][    T0] Early memory node ranges
[    0.000000][    T0]   node   0: [mem 0x0000000040000000-0x00000001bfffffff]
[    0.000000][    T0] Initmem setup node 0 [mem 0x0000000040000000-0x00000001bfffffff]
[    0.000000][    T0] cma: Reserved 8 MiB at 0x00000000ff800000
[    0.000000][    T0] psci: probing for conduit method from DT.
[    0.000000][    T0] psci: PSCIv1.1 detected in firmware.
[    0.000000][    T0] psci: Using standard PSCI v0.2 function IDs
[    0.000000][    T0] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000][    T0] psci: SMC Calling Convention v1.2
[    0.000000][    T0] Load bootconfig: 810 bytes 50 nodes
[    0.000000][    T0] percpu: Embedded 29 pages/cpu s81752 r8192 d28840 u118784
[    0.000000][    T0] pcpu-alloc: s81752 r8192 d28840 u118784 alloc=29*4096
[    0.000000][    T0] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 [0] 4 [0] 5 [0] 6 [0] 7
[    0.000000][    T0] Detected VIPT I-cache on CPU0
[    0.000000][    T0] CPU features: SYS_ID_AA64MMFR1_EL1[11:8]: forced to 0
[    0.000000][    T0] CPU features: detected: GIC system register CPU interface
[    0.000000][    T0] CPU features: kernel page table isolation forced ON by KASLR
[    0.000000][    T0] CPU features: detected: Kernel page table isolation (KPTI)
[    0.000000][    T0] CPU features: detected: Qualcomm erratum 1009, or ARM erratum 1286807, 2441009
[    0.000000][    T0] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[    0.000000][    T0] Built 1 zonelists, mobility grouping on.  Total pages: 1548288
[    0.000000][    T0] Kernel command line: stack_depot_disable=on kasan.stacktrace=off kvm-arm.mode=protected cgroup_disable=pressure rcutree.rcu_idle_gp_delay=1 cpufreq.default_governor=performance earlycon=uart8250,mmio32,0x02500000 clk_ignore_unused= initcall_debug=0 console=ttyAS0,115200 loglevel=8 root=/dev/mmcblk0p4 init=/init init_rc= cma=8M slub_min_objects=8 snum=7c00161172014741e8d mac_addr= wifi_mac= bt_mac= specialstr= gpt=1 sn2= deferred_probe_timeout=10 boot_type=2 gpt=1 uboot_message=2018.07(03/31/2025-06:54:43) bootreason=button uboot_backup=ubootA  loop.max_part=4 mmcblk.perdev_minors=16 firmware_class.path=/vendor/etc/firmware bootconfig buildvariant=userdebug
[    0.000000][    T0] cgroup: Disabling pressure control group feature
[    0.000000][    T0] Unknown kernel command line parameters "init_rc= snum=7c00161172014741e8d mac_addr= wifi_mac= bt_mac= specialstr= sn2= boot_type=2 uboot_message=2018.07(03/31/2025-06:54:43) bootreason=button uboot_backup=ubootA buildvariant=userdebug", will be passed to user space.
[    0.000000][    T0] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
[    0.000000][    T0] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000][    T0] mem auto-init: stack:all(zero), heap alloc:on, heap free:off
[    0.000000][    T0] software IO TLB: mapped [mem 0x00000000fb800000-0x00000000ff800000] (64MB)
[    0.000000][    T0] Memory: 6008524K/6291456K available (18432K kernel code, 2214K rwdata, 18820K rodata, 1472K init, 614K bss, 274740K reserved, 8192K cma-reserved)
[    0.000000][    T0] SLUB: HWalign=64, Order=0-3, MinObjects=8, CPUs=8, Nodes=1
[    0.000000][    T0] trace event string verifier disabled
[    0.000000][    T0] rcu: Preemptible hierarchical RCU implementation.
[    0.000000][    T0] rcu:     RCU event tracing is enabled.
[    0.000000][    T0] rcu:     RCU dyntick-idle grace-period acceleration is enabled.
[    0.000000][    T0] rcu:     RCU restricting CPUs from NR_CPUS=32 to nr_cpu_ids=8.
[    0.000000][    T0] rcu:     RCU priority boosting: priority 1 delay 500 ms.
[    0.000000][    T0]  Trampoline variant of Tasks RCU enabled.
[    0.000000][    T0]  Tracing variant of Tasks RCU enabled.
[    0.000000][    T0] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000][    T0] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=8
[    0.000000][    T0] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000][    T0] GICv3: 256 SPIs implemented
[    0.000000][    T0] GICv3: 0 Extended SPIs implemented
[    0.000000][    T0] GICv3: Distributor has no Range Selector support
[    0.000000][    T0] Root IRQ handler: gic_handle_irq.10d7cf410c142aff6d31b6303c3f9f87.cfi_jt
[    0.000000][    T0] GICv3: 16 PPIs implemented
[    0.000000][    T0] GICv3: CPU0: found redistributor 0 region 0:0x0000000003460000
[    0.000000][    T0] ITS: No ITS available, not enabling LPIs
[    0.000000][    T0] rcu:     Offload RCU callbacks from CPUs: (none).
[    0.000000][    T0] kfence: initialized - using 524288 bytes for 63 objects at 0x(____ptrval____)-0x(____ptrval____)
[    0.000000][    T0] arch_timer: cp15 timer(s) running at 24.00MHz (virt).
[    0.000000][    T0] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000001][    T0] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.011206][    T0] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=96000)
[    0.023251][    T0] pid_max: default: 32768 minimum: 301
[    0.029401][    T0] LSM: Security Framework initializing
[    0.035321][    T0] SELinux:  Initializing.
[    0.040291][    T0] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.049394][    T0] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.062026][    T1] rcu: Hierarchical SRCU implementation.
[    0.069177][    T1] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build
[    0.079182][    T1] EFI services will not be available.
[    0.085811][    T1] smp: Bringing up secondary CPUs ...
[    0.092555][    T0] Detected VIPT I-cache on CPU1
[    0.092593][    T0] GICv3: CPU1: found redistributor 100 region 0:0x0000000003480000
[    0.092646][    T0] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
[    0.093765][    T0] Detected VIPT I-cache on CPU2
[    0.093797][    T0] GICv3: CPU2: found redistributor 200 region 0:0x00000000034a0000
[    0.093835][    T0] CPU2: Booted secondary processor 0x0000000200 [0x412fd050]
[    0.094846][    T0] Detected VIPT I-cache on CPU3
[    0.094873][    T0] GICv3: CPU3: found redistributor 300 region 0:0x00000000034c0000
[    0.094904][    T0] CPU3: Booted secondary processor 0x0000000300 [0x412fd050]
[    0.095934][    T0] Detected VIPT I-cache on CPU4
[    0.095962][    T0] GICv3: CPU4: found redistributor 400 region 0:0x00000000034e0000
[    0.095991][    T0] CPU4: Booted secondary processor 0x0000000400 [0x412fd050]
[    0.097035][    T0] Detected VIPT I-cache on CPU5
[    0.097063][    T0] GICv3: CPU5: found redistributor 500 region 0:0x0000000003500000
[    0.097091][    T0] CPU5: Booted secondary processor 0x0000000500 [0x412fd050]
[    0.098117][    T0] CPU features: detected: Spectre-v4
[    0.098122][    T0] CPU features: detected: Spectre-BHB
[    0.098126][    T0] Detected PIPT I-cache on CPU6
[    0.098142][    T0] GICv3: CPU6: found redistributor 600 region 0:0x0000000003520000
[    0.098160][    T0] CPU6: Booted secondary processor 0x0000000600 [0x414fd0b1]
[    0.099144][    T0] Detected PIPT I-cache on CPU7
[    0.099164][    T0] GICv3: CPU7: found redistributor 700 region 0:0x0000000003540000
[    0.099183][    T0] CPU7: Booted secondary processor 0x0000000700 [0x414fd0b1]
[    0.099267][    T1] smp: Brought up 1 node, 8 CPUs
[    0.266949][    T1] SMP: Total of 8 processors activated.
[    0.272877][    T1] CPU features: detected: 32-bit EL0 Support
[    0.279280][    T1] CPU features: detected: Data cache clean to the PoU not required for I/D coherence
[    0.289499][    T1] CPU features: detected: Common not Private translations
[    0.297149][    T1] CPU features: detected: CRC32 instructions
[    0.303563][    T1] CPU features: detected: RCpc load-acquire (LDAPR)
[    0.310640][    T1] CPU features: detected: LSE atomic instructions
[    0.317523][    T1] CPU features: detected: Privileged Access Never
[    0.324403][    T1] CPU features: detected: RAS Extension Support
[    0.331093][    T1] CPU features: detected: Speculative Store Bypassing Safe (SSBS)
[    0.375725][    T1] CPU: All CPU(s) started at EL1
[    0.381083][   T19] alternatives: patching kernel code
[    0.425590][    T1] Registered cp15_barrier emulation handler
[    0.431914][    T1] Registered setend emulation handler
[    0.437644][    T1] KASLR disabled due to lack of seed
[    0.443388][    T1] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.454558][    T1] futex hash table entries: 2048 (order: 5, 131072 bytes, linear)
[    0.463257][    T1] pinctrl core: initialized pinctrl subsystem
[    0.470425][    T1] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.480071][    T1] DMA: preallocated 1024 KiB GFP_KERNEL pool for atomic allocations
[    0.489149][    T1] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.498686][    T1] audit: initializing netlink subsys (disabled)
[    0.505553][   T80] audit: type=2000 audit(0.328:1): state=initialized audit_enabled=0 res=1
[    0.505817][    T1] thermal_sys: Registered thermal governor 'step_wise'
[    0.514825][    T1] thermal_sys: Registered thermal governor 'user_space'
[    0.522174][    T1] thermal_sys: Registered thermal governor 'power_allocator'
[    0.530251][    T1] cpuidle: using governor menu
[    0.543389][    T1] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    0.551779][    T1] ASID allocator initialised with 32768 entries
[    0.558547][    T1] Serial: AMBA PL011 UART driver
[    0.578553][    T1] platform 5501000.tcon0: Fixing up cyclic dependency with 5000000.de
[    0.587564][    T1] platform 5506000.dsi0: Fixing up cyclic dependency with 5501000.tcon0
[    0.596791][    T1] platform 5730000.tcon3: Fixing up cyclic dependency with 5000000.de
[    0.605712][    T1] platform 5731000.tcon4: Fixing up cyclic dependency with 5000000.de
[    0.614648][    T1] platform 5520000.hdmi: Fixing up cyclic dependency with 5730000.tcon3
[    0.631804][    T1] iommu: Default domain type: Translated
[    0.637948][    T1] iommu: DMA domain TLB invalidation policy: strict mode
[    0.645969][    T1] SCSI subsystem initialized
[    0.650927][    T1] usbcore: registered new interface driver usbfs
[    0.657722][    T1] usbcore: registered new interface driver hub
[    0.664321][    T1] usbcore: registered new device driver usb
[    0.670697][    T1] mc: Linux media interface: v0.10
[    0.676093][    T1] videodev: Linux video capture interface: v2.00
[    0.682916][    T1] EDAC MC: Ver: 3.0.0
[    0.687831][    T1] Advanced Linux Sound Architecture Driver Initialized.
[    0.695569][    T1] Bluetooth: Core ver 2.22
[    0.700127][    T1] NET: Registered PF_BLUETOOTH protocol family
[    0.706131][    T1] Bluetooth: HCI device and connection manager initialized
[    0.713862][    T1] Bluetooth: HCI socket layer initialized
[    0.719988][    T1] Bluetooth: L2CAP socket layer initialized
[    0.726239][    T1] Bluetooth: SCO socket layer initialized
[    0.732435][    T1] nfc: nfc_init: NFC Core ver 0.1
[    0.737798][    T1] NET: Registered PF_NFC protocol family
[    0.744146][    T1] clocksource: Switched to clocksource arch_sys_counter
[    0.773471][    T1] VFS: Disk quotas dquot_6.6.0
[    0.778592][    T1] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.787374][    T1] NET: Registered PF_INET protocol family
[    0.793795][    T1] IP idents hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    0.805406][    T1] tcp_listen_portaddr_hash hash table entries: 4096 (order: 4, 65536 bytes, linear)
[    0.815696][    T1] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.824962][    T1] TCP established hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.834814][    T1] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes, linear)
[    0.844505][    T1] TCP: Hash tables configured (established 65536 bind 65536)
[    0.852583][    T1] UDP hash table entries: 4096 (order: 5, 131072 bytes, linear)
[    0.860990][    T1] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes, linear)
[    0.869178][    T1] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.876174][    T1] NET: Registered PF_XDP protocol family
[    0.882197][    T1] PCI: CLS 0 bytes, default 64
[    0.887640][    T8] Trying to unpack rootfs image as initramfs...
[    0.894583][    T1] hw perfevents: enabled with armv8_pmuv3 PMU driver, 7 counters available
[    0.904250][    T1] kvm [1]: HYP mode not available
[    0.910328][    T1] Initialise system trusted keyrings
[    0.916089][    T1] workingset: timestamp_bits=46 max_order=21 bucket_order=0
[    0.928051][    T1] fuse: init (API version 7.36)
[    0.960477][    T1] Key type asymmetric registered
[    0.965693][    T1] Asymmetric key parser 'x509' registered
[    0.971889][    T1] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 241)
[    0.980720][    T1] io scheduler mq-deadline registered
[    0.986368][    T1] io scheduler kyber registered
[    0.991598][    T1] io scheduler bfq registered
[    0.999925][   T22] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    1.010986][    T1] brd: module loaded
[    1.022092][    T1] loop: module loaded
[    1.028304][    T1] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
[    1.037626][    T1] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
[    1.040110][    T8] Freeing initrd memory: 22396K
[    1.049267][    T1] MACsec IEEE 802.1AE
[    1.058637][    T1] tun: Universal TUN/TAP device driver, 1.6
[    1.064988][    T1] CAN device driver interface
[    1.069955][    T1] PPP generic driver version 2.4.2
[    1.075436][    T1] PPP BSD Compression module registered
[    1.081356][    T1] PPP Deflate Compression module registered
[    1.087669][    T1] PPP MPPE Compression module registered
[    1.093684][    T1] NET: Registered PF_PPPOX protocol family
[    1.099732][    T1] PPTP driver version 0.8.5
[    1.104757][    T1] usbcore: registered new interface driver rtl8150
[    1.111749][    T1] usbcore: registered new interface driver r8152
[    1.118544][    T1] usbcore: registered new interface driver asix
[    1.124655][    T1] usbcore: registered new interface driver ax88179_178a
[    1.132110][    T1] usbcore: registered new interface driver cdc_ether
[    1.139278][    T1] usbcore: registered new interface driver cdc_eem
[    1.146267][    T1] usbcore: registered new interface driver cdc_ncm
[    1.152958][    T1] usbcore: registered new interface driver aqc111
[    1.159839][    T1] usbcore: registered new interface driver r8153_ecm
[    1.167381][    T1] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.174594][    T1] ehci-pci: EHCI PCI platform driver
[    1.180240][    T1] ehci-platform: EHCI generic platform driver
[    1.187024][    T1] usbcore: registered new interface driver cdc_acm
[    1.193967][    T1] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[    1.203530][    T1] usbcore: registered new interface driver uas
[    1.210138][    T1] usbcore: registered new interface driver usb-storage
[    1.217634][    T1] usbcore: registered new interface driver xpad
[    1.224279][    T1] usbcore: registered new interface driver uvcvideo
[    1.231343][    T1] gspca_main: v2.14.0 registered
[    1.236769][    T1] device-mapper: uevent: version 1.0.3
[    1.242710][    T1] device-mapper: ioctl: 4.45.0-ioctl (2021-03-22) initialised: dm-devel@redhat.com
[    1.252697][    T1] Bluetooth: HCI UART driver ver 2.3
[    1.258198][    T1] Bluetooth: HCI UART protocol H4 registered
[    1.264602][    T1] Bluetooth: HCI UART protocol LL registered
[    1.271034][    T1] Bluetooth: HCI UART protocol Broadcom registered
[    1.278008][    T1] Bluetooth: HCI UART protocol QCA registered
[    1.285541][    T1] mmcblk: using 16 minors per device
[    1.291191][    T1] sdhci: Secure Digital Host Controller Interface driver
[    1.298729][    T1] sdhci: Copyright(c) Pierre Ossman
[    1.304265][    T1] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.311390][    T1] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[    1.319243][    T1] hid: raw HID events driver (C) Jiri Kosina
[    1.326126][    T1] usbcore: registered new interface driver usbhid
[    1.333001][    T1] usbhid: USB HID core driver
[    1.338099][    T1] ashmem: initialized
[    1.342479][    T1] gnss: GNSS driver registered with major 509
[    1.349344][    T1] usbcore: registered new interface driver snd-usb-audio
[    1.357177][    T1] GACT probability NOT on
[    1.361548][    T1] Mirror/redirect action on
[    1.366332][    T1] netem: version 1.3
[    1.370334][    T1] u32 classifier
[    1.374060][    T1]     input device check on
[    1.378836][    T1]     Actions configured
[    1.385137][    T1] xt_time: kernel timezone is -0000
[    1.390815][    T1] ipip: IPv4 and MPLS over IPv4 tunneling driver
[    1.397847][    T1] gre: GRE over IPv4 demultiplexor driver
[    1.403961][    T1] ip_gre: GRE over IPv4 tunneling driver
[    1.410455][    T1] IPv4 over IPsec tunneling driver
[    1.415866][    T1] Initializing XFRM netlink socket
[    1.421344][    T1] IPsec XFRM device driver
[    1.426317][    T1] NET: Registered PF_INET6 protocol family
[    1.433706][    T1] Segment Routing with IPv6
[    1.438519][    T1] In-situ OAM (IOAM) with IPv6
[    1.443665][    T1] mip6: Mobile IPv6
[    1.448024][    T1] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    1.455708][    T1] ip6_gre: GRE over IPv6 tunneling driver
[    1.462024][    T1] NET: Registered PF_PACKET protocol family
[    1.468352][    T1] NET: Registered PF_KEY protocol family
[    1.474434][    T1] can: controller area network core
[    1.480042][    T1] NET: Registered PF_CAN protocol family
[    1.486074][    T1] can: raw protocol
[    1.490097][    T1] can: broadcast manager protocol
[    1.495448][    T1] can: netlink gateway - max_hops=1
[    1.501195][    T1] Bluetooth: RFCOMM TTY layer initialized
[    1.507323][    T1] Bluetooth: RFCOMM socket layer initialized
[    1.513734][    T1] Bluetooth: RFCOMM ver 1.11
[    1.518610][    T1] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    1.525214][    T1] Bluetooth: HIDP socket layer initialized
[    1.531430][    T1] l2tp_core: L2TP core driver, V2.0
[    1.536974][    T1] l2tp_ppp: PPPoL2TP kernel driver, V2.0
[    1.542987][    T1] 8021q: 802.1Q VLAN Support v1.8
[    1.548348][    T1] tipc: Activated (version 2.0.0)
[    1.553793][    T1] NET: Registered PF_TIPC protocol family
[    1.559972][    T1] tipc: Started in single node mode
[    1.565627][    T1] NET: Registered PF_IEEE802154 protocol family
[    1.572443][    T1] NET: Registered PF_VSOCK protocol family
[    1.579433][    T1] registered taskstats version 1
[    1.584703][    T1] Loading compiled-in X.509 certificates
[    1.591081][  T108] cryptomgr_probe (108) used greatest stack depth: 14016 bytes left
[    1.592666][    T1] Loaded X.509 cert 'Build time autogenerated kernel key: ce4e882886e7b069224779dcae2c567271036ca1'
[    1.612155][    T1] page_owner is disabled
[    1.616371][    T1] Key type .fscrypt registered
[    1.621437][    T1] Key type fscrypt-provisioning registered
[    1.629066][    T1] clk: Not disabling unused clocks
[    1.634535][    T1] ALSA device list:
[    1.638551][    T1]   No soundcards found.
[    1.643107][    T1] Warning: unable to open an initial console.
[    1.650156][    T1] Freeing unused kernel memory: 1472K
[    1.660374][    T1] Run /init as init process
[    1.665171][    T1]   with arguments:
[    1.668931][    T1]     /init
[    1.672182][    T1]   with environment:
[    1.676383][    T1]     HOME=/
[    1.679645][    T1]     TERM=linux
[    1.683370][    T1]     init_rc=
[    1.686600][    T1]     snum=7c00161172014741e8d
[    1.691633][    T1]     mac_addr=
[    1.695262][    T1]     wifi_mac=
[    1.698890][    T1]     bt_mac=
[    1.702327][    T1]     specialstr=
[    1.706146][    T1]     sn2=
[    1.709280][    T1]     boot_type=2
[    1.713104][    T1]     uboot_message=2018.07(03/31/2025-06:54:43)
[    1.719879][    T1]     bootreason=button
[    1.724271][    T1]     uboot_backup=ubootA
[    1.728618][    T1]     buildvariant=userdebug
[    1.735151][    T1] init: init first stage started!
[    1.743053][  T109] init: Loading module /lib/modules/zsmalloc.ko with args ''
[    1.743112][  T112] init: Loading module /lib/modules/twi-sunxi.ko with args ''
[    1.743312][  T111] init: Loading module /lib/modules/timer-sun50i.ko with args ''
[    1.743347][  T113] init: Loading module /lib/modules/tee.ko with args ''
[    1.743400][  T110] init: Loading module /lib/modules/sunxi-uart-ng.ko with args ''
[    1.743545][  T114] init: Loading module /lib/modules/sunxi-smc.ko with args ''
[    1.743578][  T111] timer_sun50i: module verification failed: signature and/or required key missing - tainting kernel
[    1.743664][  T115] init: Loading module /lib/modules/sunxi-power-notifier.ko with args ''
[    1.744255][  T116] init: Loading module /lib/modules/sunxi_pd_test.ko with args ''
[    1.816859][  T114] init: Loaded kernel module /lib/modules/sunxi-smc.ko
[    1.831229][  T116] [drm] [DSI-PANEL] panel_dsi_init start
[    1.837444][  T116] [drm] [DSI-PANEL] dsi driver regsiter finsh
[    1.845139][  T113] i2c_dev: i2c /dev entries driver
[    1.845757][  T112] BOOTEVENT:      1845.756325: ON
[    1.846424][  T116] init (116) used greatest stack depth: 12480 bytes left
[    1.852407][  T115] init (115) used greatest stack depth: 12368 bytes left
[    1.864155][  T125] sunxi:ccu-ng:[INFO]: sunxi rtc-ccu version: 0.5.3
[    1.865025][  T124] optee: probing for conduit method.
[    1.865039][  T124] optee: api uid mismatch
[    1.865042][  T124] optee: probe of firmware:optee failed with error -22
[    1.865713][  T118] zram: Added device: zram0
[    1.879489][  T119] AW BSP version: UNKNOWN, 2025-04-28 11:18:30
[    1.883900][  T125] AW BSP version: UNKNOWN, 2025-04-28 11:18:30
[    1.890517][  T119] sunxi:ccu-ng:[INFO]: r_ccu: sunxi ccu init OK
[    1.896699][  T125] sunxi:ccu-ng:[INFO]: rtc_ccu: sunxi ccu init OK
[    1.900534][  T119] sunxi:ccu-ng:[INFO]: sunxi ccu common driver version: 1.2.4
[    1.907682][  T125] init (125) used greatest stack depth: 11920 bytes left
[    1.911549][  T117] sunxi:ccu-ng:[INFO]: cpupll_ccu: sunxi ccu init OK
[    1.911556][  T117] sunxi:ccu-ng:[INFO]: sunxi pll_cpu driver version: 0.0.3
[    1.912364][  T117] sunxi:ccu-ng:[INFO]: ccu will stop clk in init process
[    1.913991][  T119] sunxi:ccu-ng:[INFO]: sunxi ccu driver version: 0.5.4
[    1.954266][  T117] sunxi:ccu-ng:[INFO]: ccu: sunxi ccu init OK
[    1.973165][  T129] [ADDR_MGT] addr_mgt_probe: module version: v1.0.12
[    1.973567][  T133] init (133) used greatest stack depth: 11376 bytes left
[    1.978579][  T117] sunxi:ccu-ng:[INFO]: sunxi ccu driver version: 1.0.13
[    1.986218][  T129] sunxi:sunxi_sidget_soc_ver_regs() +293: Failed to find "soc_bin" in dts.
[    1.993341][  T126] [drm] [TCON] sunxi_tcon_probe start
[    1.993476][  T117] sunxi:ccu_ddr:[ERR]: dram_clk:1800
[    1.993482][  T117] sunxi:ccu_ddr:[ERR]: dram_div:0x11080503
[    1.994428][  T117] sun55iw3-timer 3009000.timer: sun50i timer init:0xffffff0000000a
[    1.994434][  T117] clocksource: timer: mask: 0xffffffffffffff max_cycles: 0x1623fa770, max_idle_ns: 440795202238 ns
[    1.995080][  T117] sunxi:pwm-2527000.pwm:[INFO]: pwmchip probe success
[    1.995431][  T117] sunxi:pwm-2528000.pwm:[INFO]: pwmchip probe success
[    1.995800][  T117] sunxi:pwm-7023000.pwm:[INFO]: pwmchip probe success
[    1.996083][  T117] sunxi iommu: irq = 19
[    1.996115][  T117] sunxi iommu: irq = 20
[    1.997464][  T117] sun6i-dma 4601000.dma-controller: sunxi dma probed, driver version: 1.2.6
[    1.997853][  T117] pwm-backlight backlight1: supply power not found, using dummy regulator
[    1.998144][  T117] sunxi:pin:[INFO]: sunxi r-pinctrl version: 0.0.2
[    1.998458][    T8] sunxi:rtc:[INFO]:  Saving SoC boot-reason: OTHERS
[    1.999302][    T8] sunxi-rtc 7090000.rtc: registered as rtc0
[    1.999311][  T117] sunxi:pin-7025000.pinctrl:[INFO]: pinctrl withstand voltage config mode=auto_hard
[    1.999314][  T117] sunxi:pin:[INFO]: sunxi pinctrl core driver version: 1.4.8
[    1.999360][    T8] sunxi-rtc 7090000.rtc: setting system clock to 2025-05-29T13:49:17 UTC (1748526557)
[    1.999389][    T8] sunxi:rtc-7090000.rtc:[INFO]: sunxi rtc probed
[    1.999439][  T117] sunxi:pin:[INFO]: sunxi pinctrl version: 0.6.7
[    2.004331][  T129] [ADDR_MGT] addr_mgt_probe: success.
[    2.009919][  T126] [drm] [SUNXI-TCON] sunxi_tcon_of_get_id 0
[    2.016490][  T117] sunxi:pin-2000000.pinctrl:[INFO]: pinctrl withstand voltage config mode=auto_hard
[    2.021296][  T126] [drm] [TCON] sunxi_tcon_probe ret = 0
[    2.028203][  T117] sunxi:pin-2000000.pinctrl:[INFO]: Auto power withstand voltage configuration detected, automatically exit!
[    2.035827][  T126] [drm] [TCON] sunxi_tcon_probe start
[    2.046908][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: SD/MMC/SDIO Host Controller Driver(v5.58 2024-11-11 09:32)
[    2.054231][  T126] [drm] [SUNXI-TCON] sunxi_tcon_of_get_id 4
[    2.061554][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: ctl-spec-caps 428
[    2.068655][  T126] [drm] [TCON] sunxi_tcon_probe ret = 0
[    2.072742][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vmmc regulator found
[    2.077255][  T126] [drm] [TCON] sunxi_tcon_probe start
[    2.086349][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vqmmc regulator found
[    2.095132][  T126] [drm] [SUNXI-TCON] sunxi_tcon_of_get_id 5
[    2.102020][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vdmmc regulator found
[    2.109197][  T126] [drm] [TCON] sunxi_tcon_probe ret = 0
[    2.115354][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vd33sw regulator found
[    2.115357][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vd18sw regulator found
[    2.115358][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vq33sw regulator found
[    2.115360][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: No vq18sw regulator found
[    2.125724][  T126] [drm] sunxi_drm_platform_probe start
[    2.133387][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: manual set ocr
[    2.133400][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[WARN]: Cann't get uart0 pinstate,check if needed
[    2.143697][  T126] [drm] sunxi_drm_match_add start
[    2.150470][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[WARN]: Cann't get pin bias hs pinstate,check if needed
[    2.158003][  T126] [drm] sunxi_drm_match_add finish
[    2.163578][  T117] sunxi-mmc 4021000.sdmmc: sunxi:sunxi_mmc_hostexecute tuning in kernel, retune_period=3600
[    2.371929][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.396156][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.420270][  T117] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: detmode:manually by software
[    2.421096][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[    2.430877][  T117] NSI_PMU 2020000.nsi-controller: Get support-ecc failed
[    2.446364][  T117] [drm] [TCON_TOP]sunxi_tcon_top_probe start
[    2.446829][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[    2.452951][  T117] [drm] [TCON_TOP]sunxi_tcon_top_probe start
[    2.467861][   T70] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.482102][  T117] sunxi-display-engine 5000000.de: Adding to iommu group 0
[    2.484817][   T70] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.490037][  T117] [drm] de use no display sys
[    2.505297][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[    2.508511][  T117] sunxi-display-engine 5000000.de: register iommu fault callback for sunxi-drm, master=8
[    2.517719][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[    2.526965][  T117] [drm] [PHY] sunxi_dsi_combophy_probe start
[    2.536423][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[    2.542302][  T117] [drm] [PHY]sunxi_dsi_combophy_probe finish
[    2.551798][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[    2.557752][  T117] [drm] [DSI] sunxi_drm_dsi_probe start
[    2.566328][   T70] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[    2.572439][  T117] mipi-dsi 5506000.dsi0.0: Fixing up cyclic dependency with dsi_panel@1
[    2.585102][   T70] sunxi:pin-2000000.pinctrl:[INFO]: Auto power withstand voltage configuration detected, automatically exit!
[    2.594114][  T117] [drm] [DSI]sunxi_drm_dsi_probe ok
[    2.611971][  T117] pwm-backlight backlight0: supply power not found, using dummy regulator
[    2.621384][  T117] sunxi:pin-2000000.pinctrl:[ERR]: unknown pin
[    2.621390][  T117] sunxi:pin-2000000.pinctrl:[ERR]: unknown pin
[    2.628076][  T117] uart-ng 2500000.uart: there is not valid maps for state default
[    2.643169][  T117] sunxi:pin-2000000.pinctrl:[ERR]: unknown pin
[    2.643173][  T117] sunxi:pin-2000000.pinctrl:[ERR]: unknown pin
[    2.649776][  T117] uart-ng 2500000.uart: there is not valid maps for state sleep
[    2.664893][  T117] uart-ng uart-ng0: supply uart not found, using dummy regulator
[    2.673298][  T117] sunxi:uart-ng-uart-ng0:[INFO]: cannot get the TX DMA channel!
[    2.681507][  T117] sunxi:uart-ng-uart-ng0:[INFO]: cannot get the RX DMA channel!
[    2.689761][  T117] sunxi:uart-ng:[INFO]: sunxi uart-ng driver version: 1.1.7
[    2.697391][  T117] uart-ng0: ttyAS0 at MMIO 0x2500000 (irq = 426, base_baud = 1500000) is a SUNXI
[    2.707228][  T117] sunxi:uart-ng-uart-ng0:[INFO]: console setup baud 115200 parity n bits 8, flow n
[    2.717275][  T117] printk: console [ttyAS0] enabled
[    2.717275][  T117] printk: console [ttyAS0] enabled
[    2.728254][  T117] printk: bootconsole [uart8250] disabled
[    2.728254][  T117] printk: bootconsole [uart8250] disabled
[    2.741160][  T117] uart-ng uart-ng1: supply uart not found, using dummy regulator
[    2.749734][  T117] sunxi:uart-ng-uart-ng1:[INFO]: cannot get the TX DMA channel!
[    2.758119][  T117] sunxi:uart-ng-uart-ng1:[INFO]: cannot get the RX DMA channel!
[    2.766560][  T117] uart-ng1: ttyAS1 at MMIO 0x2501000 (irq = 427, base_baud = 1500000) is a SUNXI
[    2.777071][  T117] uart-ng uart-ng4: supply uart not found, using dummy regulator
[    2.785622][  T117] sunxi:uart-ng-uart-ng4:[INFO]: cannot get the TX DMA channel!
[    2.793984][  T117] sunxi:uart-ng-uart-ng4:[INFO]: cannot get the RX DMA channel!
[    2.802402][  T117] uart-ng4: ttyAS4 at MMIO 0x2504000 (irq = 428, base_baud = 1500000) is a SUNXI
[    2.812897][  T117] sunxi-twi 7083000.twi: supply twi not found, using dummy regulator
[    2.823032][  T117] sunxi:axp2101-13-0036:[INFO]: AXP20x variant AXP8191 found
[    2.836296][  T117] axp8191-dcdc1: supplied by regulator-dummy
[    2.845230][  T117] axp8191-dcdc2: supplied by regulator-dummy
[    2.854161][  T117] axp8191-dcdc3: supplied by regulator-dummy
[    2.863079][  T117] axp8191-dcdc4: supplied by regulator-dummy
[    2.872522][  T117] axp8191-dcdc5: supplied by regulator-dummy
[    2.881923][  T117] axp8191-dcdc6: supplied by regulator-dummy
[    2.891339][  T117] axp8191-dcdc7: supplied by regulator-dummy
[    2.900781][  T117] axp8191-dcdc8: supplied by regulator-dummy
[    2.909448][  T117] axp8191-dcdc9: supplied by regulator-dummy
[    2.918401][  T117] axp8191-dc1sw1: supplied by axp8191-dcdc1
[    2.925130][  T117] axp8191-dc1sw2: supplied by axp8191-dcdc1
[    2.932227][  T117] axp8191-aldo1: supplied by regulator-dummy
[    2.942011][  T117] axp8191-aldo2: supplied by regulator-dummy
[    2.949641][  T117] axp8191-aldo3: supplied by regulator-dummy
[    2.957288][  T117] axp8191-aldo4: supplied by regulator-dummy
[    2.964899][  T117] axp8191-aldo5: supplied by regulator-dummy
[    2.972562][  T117] axp8191-aldo6: supplied by regulator-dummy
[    2.979684][  T117] axp8191-bldo1: supplied by regulator-dummy
[    2.986737][  T117] axp8191-bldo2: supplied by regulator-dummy
[    2.993767][  T117] axp8191-bldo3: supplied by regulator-dummy
[    3.000807][  T117] axp8191-bldo4: supplied by regulator-dummy
[    3.007611][  T117] axp8191-bldo5: supplied by regulator-dummy
[    3.016108][  T117] axp8191-cldo1: supplied by regulator-dummy
[    3.024910][  T117] axp8191-cldo2: supplied by regulator-dummy
[    3.031699][  T117] axp8191-cldo3: supplied by regulator-dummy
[    3.040823][  T117] axp8191-cldo4: supplied by regulator-dummy
[    3.047656][  T117] axp8191-cldo5: supplied by regulator-dummy
[    3.056289][  T117] axp8191-dldo1: supplied by regulator-dummy
[    3.065861][  T117] axp8191-dldo2: supplied by regulator-dummy
[    3.072934][  T117] axp8191-dldo3: supplied by regulator-dummy
[    3.079998][  T117] axp8191-dldo4: supplied by regulator-dummy
[    3.086762][  T117] axp8191-dldo5: Bringing 2800000uV into 3300000-3300000uV
[    3.095601][  T117] axp8191-dldo5: supplied by regulator-dummy
[    3.104259][  T117] axp8191-dldo6: supplied by regulator-dummy
[    3.113229][  T117] axp8191-eldo1: supplied by regulator-dummy
[    3.122650][  T117] axp8191-eldo2: supplied by regulator-dummy
[    3.131865][  T117] axp8191-eldo3: supplied by regulator-dummy
[    3.138958][  T117] axp8191-eldo4: supplied by regulator-dummy
[    3.146031][  T117] axp8191-eldo5: supplied by regulator-dummy
[    3.152819][  T117] axp8191-eldo6: supplied by regulator-dummy
[    3.161158][  T117] axp8191-rtcldo: supplied by regulator-dummy
[    3.168054][  T117] axp2101-pek axp2101-pek.0: DMA mask not set
[    3.179544][  T117] input: axp8191-pek as /devices/platform/soc@3000000/7083000.twi/i2c-13/13-0036/axp2101-pek.0/input/input0
[    3.192257][  T117] axp8191-temp-ctrl: Failed to locate of_node [id: 0]
[    3.199739][  T117] sunxi:axp8191_temp_ctrl:[ERR]: axp8191-temp-ctrl device is not configed
[    3.211329][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.218886][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.226423][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.233965][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.241504][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.249038][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.256568][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.264095][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.271631][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.279189][  T117] reg-virt-consumer: Failed to locate of_node [id: -2]
[    3.288979][  T117] sunxi:axp2101-13-0036:[INFO]: AXP20X driver loaded
[    3.296421][  T117] i2c 13-004e: Fixing up cyclic dependency with 10.usbc0
[    3.304232][  T117] sunxi:twi-7083000.twi:[INFO]: v2.7.4 probe success
[    3.312030][  T117] sunxi-twi 7084000.twi: supply twi not found, using dummy regulator
[    3.321798][  T117] sunxi:twi-7084000.twi:[INFO]: v2.7.4 probe success
[    3.332693][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: SD/MMC/SDIO Host Controller Driver(v5.58 2024-11-11 09:32)
[    3.345168][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: ctl-spec-caps 328
[    3.354815][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: No vdmmc regulator found
[    3.363796][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: No vd33sw regulator found
[    3.372833][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: No vd18sw regulator found
[    3.381871][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: No vq33sw regulator found
[    3.390907][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: No vq18sw regulator found
[    3.399962][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[WARN]: Cann't get uart0 pinstate,check if needed
[    3.410558][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[WARN]: Cann't get pin bias hs pinstate,check if needed
[    3.421860][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[ERR]: Could not get store clock
[    3.431499][  T117] sunxi-mmc 4023000.sdmmc: sunxi:sunxi_mmc_host***ctl-cmdq-md*** 20
[    3.440518][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: cq_host:ffffff80c81d7c80, mmc:ffffff80c775d000, host:ffffff80c775d7c0
[    3.453859][  T117] mmc0: CQHCI version 0.00
[    3.458740][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.485223][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.512205][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.526330][  T117] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: detmode:alway in(non removable)
[    3.536955][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: SD/MMC/SDIO Host Controller Driver(v5.58 2024-11-11 09:32)
[    3.549577][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: ctl-spec-caps 428
[    3.552323][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.560037][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: No vqmmc regulator found
[    3.573280][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm OD pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.580893][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: No vdmmc regulator found
[    3.604593][  T117] sunxi-mmc 4020000.sdmmc: Got CD GPIO
[    3.608583][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm OD pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.610575][  T117] sunxi-mmc 4020000.sdmmc: sunxi:sunxi_mmc_hostcd-set-debounce is 0x1
[    3.624695][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm OD pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.647963][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.650703][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm OD pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.692120][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.720595][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[ERR]: avoid to switch power_off_notification to POWERED_ON(0x01)
[    3.732777][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[ERR]: avoid to switch power_off_notification to POWERED_ON(0x01)
[    3.744924][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[ERR]: avoid to switch power_off_notification to POWERED_ON(0x01)
[    3.757066][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[ERR]: avoid to switch power_off_notification to POWERED_ON(0x01)
[    3.770313][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 8 timing LEGACY(SDR12) dt B
[    3.787946][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS200 dt B
[    3.801794][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 52000000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS200 dt B
[    3.815969][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 200000000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS200 dt B
[    3.830148][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[ERR]: sdc3 :the host don't support tuning in kernel
[    3.841091][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 200000000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS(SDR20) dt B
[    3.855629][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 52000000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS(SDR20) dt B
[    3.870252][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS400 dt B
[    3.880351][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: no vqmmc,Check if there is regulator
[    3.884337][   T70] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: sdc set ios:clk 200000000Hz bm PP pm ON vdd 21 width 8 timing MMC-HS400 dt B
[    3.906905][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    3.922452][   T70] mmc0: Command Queue Engine enabled
[    3.928202][   T70] mmc0: new HS400 MMC card at address 0001
[    3.935404][   T70] blk_queue_max_segment_size: set to minimum 4096
[    3.935497][   T95] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[    3.942434][   T70] mmcblk0: mmc0:0001 MMC32G 29.2 GiB
[    3.956040][  T117] sunxi:sunxi_mmc_host-4020000.sdmmc:[INFO]: detmode:gpio irq
[    3.966283][   T70]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24 p25 p26 p27 p28 p29
[    3.970902][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    3.984917][   T70] mmcblk0rpmb: mmc0:0001 MMC32G 4.00 MiB, chardev (235:0)
[    3.992948][  T168] random: fsck_msdos: uninitialized urandom read (40 bytes read)
[    3.994465][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (408000000)
[    3.994665][    T1] fsck_msdos: linker: Warning: failed to find generated linker configuration from "/linkerconfig/ld.config.txt"
[    3.994680][    T1] fsck_msdos: WARNING: linker: Warning: failed to find generated linker configuration from "/linkerconfig/ld.config.txt"
[    3.998470][  T168] random: fsck_msdos: uninitialized urandom read (40 bytes read)
[    4.001284][    T1] fsck_msdos: Invalid signature in boot block: 0000
[    4.001297][    T1] fsck_msdos: /dev/block/by-name/media_data: UNEXPECTED INCONSISTENCY; RUN fsck_msdos MANUALLY.
[    4.002171][    T1] fsck_msdos: fsck_msdos terminated by exit(8)
[    4.002171][    T1]
[    4.005333][    T1] random: init: uninitialized urandom read (16 bytes read)
[    4.010791][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.028719][    T1] erofs: (device dm-0): mounted with root inode @ nid 65.
[    4.032349][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (720000000)
[    4.032431][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.052039][    T1] EXT4-fs (dm-4): mounted filesystem without journal. Opts: . Quota mode: none.
[    4.054787][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (792000000)
[    4.054866][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.063844][    T1] erofs: (device dm-1): mounted with root inode @ nid 42.
[    4.073498][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1008000000)
[    4.073591][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.084207][    T1] erofs: (device dm-3): mounted with root inode @ nid 39.
[    4.090603][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1104000000)
[    4.102037][    T1] erofs: (device dm-2): mounted with root inode @ nid 39.
[    4.109142][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.122387][    T1] newfs_msdos: executing /system/bin/newfs_msdos failed: No such file or directory
[    4.128327][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1200000000)
[    4.138262][    T1] newfs_msdos: newfs_msdos terminated by exit(255)
[    4.138262][    T1]
[    4.146866][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.157856][    T1] FAT-fs (mmcblk0p26): bogus number of reserved sectors
[    4.165261][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1296000000)
[    4.165345][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.173919][    T1] FAT-fs (mmcblk0p26): Can't find a valid FAT filesystem
[    4.175180][    T1] newfs_msdos: executing /system/bin/newfs_msdos failed: No such file or directory
[    4.184621][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1392000000)
[    4.184707][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.192425][    T1] newfs_msdos: newfs_msdos terminated by exit(255)
[    4.192425][    T1]
[    4.201126][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1416000000)
[    4.209321][    T1] FAT-fs (mmcblk0p27): bogus number of reserved sectors
[    4.219627][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.229791][    T1] FAT-fs (mmcblk0p27): Can't find a valid FAT filesystem
[    4.238414][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1512000000)
[    4.274912][    T1] printk: init: 146 output lines suppressed due to ratelimiting
[    4.285616][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.394547][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1608000000)
[    4.403420][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.410423][    T1] init: DM_DEV_STATUS failed for system_ext_a: No such device or address
[    4.414137][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1704000000)
[    4.423429][    T1] init: Could not update logical partition
[    4.433038][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.438435][    T1] init: Opening SELinux policy
[    4.449246][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1800000000)
[    4.454978][    T1] init: Falling back to standard signature check. TODO implementent support for fsverity SEPolicy.
[    4.463070][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.474709][    T1] init: Error: Apex SEPolicy failed signature check
[    4.485336][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (728000000)
[    4.492569][    T1] init: Loading APEX Sepolicy from /system/etc/selinux/apex/SEPolicy.zip
[    4.501239][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.510367][    T1] init: Failed to open package /system/etc/selinux/apex/SEPolicy.zip: No such file or directory
[    4.521007][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1092000000)
[    4.521264][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.541118][    T1] init: Loading SELinux policy
[    4.556918][    T1] SELinux:  Permission bpf in class capability2 not defined in policy.
[    4.556964][  T117] cpu cpu0: _opp_add: OPP not supported by regulators (1586000000)
[    4.566030][    T1] SELinux:  Permission checkpoint_restore in class capability2 not defined in policy.
[    4.575509][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.585169][    T1] SELinux:  Permission bpf in class cap2_userns not defined in policy.
[    4.595849][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (408000000)
[    4.595927][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.604905][    T1] SELinux:  Permission checkpoint_restore in class cap2_userns not defined in policy.
[    4.613450][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (720000000)
[    4.613511][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.624210][    T1] SELinux:  Class mctp_socket not defined in policy.
[    4.634634][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (792000000)
[    4.634702][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.643203][    T1] SELinux: the above unknown classes and permissions will be denied
[    4.653885][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1008000000)
[    4.653956][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.665791][    T1] SELinux:  policy capability network_peer_controls=1
[    4.669722][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1200000000)
[    4.669796][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.680461][    T1] SELinux:  policy capability open_perms=1
[    4.689183][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1296000000)
[    4.689247][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.697838][    T1] SELinux:  policy capability extended_socket_class=1
[    4.708520][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1392000000)
[    4.708593][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.715921][    T1] SELinux:  policy capability always_check_network=0
[    4.724559][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1512000000)
[    4.724636][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.735275][    T1] SELinux:  policy capability cgroup_seclabel=0
[    4.741577][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1608000000)
[    4.741634][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.750234][    T1] SELinux:  policy capability nnp_nosuid_transition=1
[    4.760918][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1704000000)
[    4.760991][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.768311][    T1] SELinux:  policy capability genfs_seclabel_symlinks=0
[    4.776956][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1800000000)
[    4.777030][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.787654][    T1] SELinux:  policy capability ioctl_skip_cloexec=0
[    4.794937][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1896000000)
[    4.795009][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.920482][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1920000000)
[    4.929331][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.940028][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1992000000)
[    4.948900][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.959595][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (728000000)
[    4.968562][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.979262][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1300000000)
[    4.988221][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    4.998915][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1586000000)
[    5.007763][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.018456][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1690000000)
[    5.027527][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.038223][  T117] cpu cpu6: _opp_add: OPP not supported by regulators (1976000000)
[    5.047369][  T117] cpu cpu0: EM: created perf domain
[    5.058868][  T117] cpu cpu6: EM: created perf domain
[    5.064587][   T80] audit: type=1403 audit(1748526560.564:2): auid=4294967295 ses=4294967295 lsm=selinux res=1
[    5.067994][  T117] sunxi:sunxi_dsufreq:[WARN]: dsu dvfs: 26m-vf0200
[    5.070180][    T1] selinux: SELinux: Loaded file_contexts
[    5.070185][    T1] selinux:
[    5.075564][    T1] random: init: uninitialized urandom read (40 bytes read)
[    5.082221][    T1] random: init: uninitialized urandom read (40 bytes read)
[    5.082999][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.091100][    T1] init: init second stage started!
[    5.092311][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (288000000)
[    5.092468][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.145524][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (528000000)
[    5.147758][    T1] FAT-fs (mmcblk0p26): bogus number of reserved sectors
[    5.156188][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.163701][    T1] FAT-fs (mmcblk0p26): Can't find a valid FAT filesystem
[    5.174545][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (600000000)
[    5.182159][    T1] init: mount media_data fail*****Invalid argument
[    5.192705][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.210415][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (744000000)
[    5.219149][    T1] init: Using Android DT directory /proc/device-tree/firmware/android/
[    5.221086][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.233982][    T1] init: Couldn't load property file '/vendor/default.prop': open() failed: No such file or directory: No such file or directory
[    5.240734][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (792000000)
[    5.240807][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.257627][    T1] init: Couldn't load property file '/odm_dlkm/etc/build.prop': open() failed: No such file or directory: No such file or directory
[    5.265886][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (840000000)
[    5.265955][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.277404][    T1] init: Couldn't load property file '/oem/build.prop': open() failed: No such file or directory: No such file or directory
[    5.291526][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (888000000)
[    5.291596][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.302488][    T1] init: Could not set 'ro.boot.dynamic_partitions' to 'true' while loading .prop filesRead-only property was already set
[    5.312793][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (912000000)
[    5.312858][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.326898][    T1] init: Could not set 'ro.boot.dynamic_partitions_retrofit' to 'true' while loading .prop filesRead-only property was already set
[    5.337453][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (984000000)
[    5.337522][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.348750][    T1] init: Setting product property ro.product.brand to 'Allwinner' (from ro.product.product.brand)
[    5.362023][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1032000000)
[    5.362089][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.372630][    T1] init: Setting product property ro.product.device to 'a733-demo-aiot' (from ro.product.product.device)
[    5.383287][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1056000000)
[    5.383352][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.485850][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1152000000)
[    5.496624][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.507329][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1200000000)
[    5.511106][  T184] random: init: uninitialized urandom read (40 bytes read)
[    5.518096][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.536625][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1224000000)
[    5.547448][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.558134][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1296000000)
[    5.568887][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.579571][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (546000000)
[    5.590325][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.601006][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (832000000)
[    5.611878][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.622568][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1196000000)
[    5.633432][  T117] core: _opp_supported_by_regulators: OPP minuV: 0 maxuV: 0, not supported by regulator
[    5.644114][  T117] sunxi-dsufreq 8860000.dsufreq: _opp_add: OPP not supported by regulators (1352000000)
[    5.654927][  T117] [drm] [DSI-PANEL] panel_dsi_probe start
[    5.661354][  T117] [drm] reset-on-sequence property not found
[    5.668136][  T117] [drm] [DSI]sunxi_drm_dsi_host_attach start
[    5.674668][  T117] [drm] [DSI]sunxi_drm_dsi_host_attach finish
[    5.681272][  T117] [drm] [DSI-PANEL] panel_dsi_probe finish
[    5.687866][  T117] [drm] sunxi_drm_bind start
[    5.692983][  T117] [drm] [TCON_TOP]sunxi_tcon_top_bind start
[    5.699517][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5500000.vo0 (ops sunxi_tcon_top_component_ops [sunxidrm])
[    5.711367][  T117] [drm] [TCON_TOP]sunxi_tcon_top_bind start
[    5.717820][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5510000.vo1 (ops sunxi_tcon_top_component_ops [sunxidrm])
[    5.729663][  T117] [drm] [SUNXI-DE] sunxi_de_bind start
[    5.735620][  T117] sunxi-drm soc@3000000:sunxi-drm: Adding to iommu group 0
[    5.743626][  T117] [drm] sunxi_de_bind crtc init for de 0 ok
[    5.750086][  T117] [drm] sunxi_de_bind crtc init for de 1 ok
[    5.757000][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5000000.de (ops sunxi_de_component_ops [sunxidrm])
[    5.768182][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5507000.phy (ops sunxi_cphy_component_ops [sunxi_drm_phy])
[    5.780041][  T117] [drm] [DSI]sunxi_drm_dsi_bind start
[    5.786045][  T117] [drm] [SUNXI-TCON] sunxi_tcon_of_get_id 0
[    5.787979][  T188] linkerconfig: Unable to access VNDK APEX at path: /apex/com.android.vndk.v33: No such file or directory
[    5.792489][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5506000.dsi0 (ops sunxi_drm_dsi_component_ops [sunxidrm])
[    5.805116][  T188] linkerconfig: Unable to access VNDK APEX at path: /apex/com.android.vndk.v33: No such file or directory
[    5.816785][  T117] [drm] [SUNXI-TCON] sunxi_tcon_of_get_id 4
[    5.831259][  T188] linkerconfig (188) used greatest stack depth: 11104 bytes left
[    5.835909][  T117] [drm] sunxi-hdmi: hdmi drv init dts done
[    5.851357][  T117] [drm] sunxi-hdmi: hdmi drv enable resource done
[    5.858364][  T117] [drm] sunxi-hdmi: hdmi drv init resource done
[    5.865265][  T117] [drm] sunxi-hdmi: hdmi drv init i2c adapter finish
[    5.865619][  T189] ueventd: ueventd started!
[    5.878252][  T117] [drm] sunxi-hdmi: drm hdmi connector create finish
[    5.879202][  T189] selinux: SELinux: Loaded file_contexts
[    5.885578][  T117] [drm] sunxi-hdmi: hdmi devices bind done <<<<<<<<<<
[    5.885578][  T117]
[    5.885591][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5520000.hdmi (ops sunxi_hdmi_compoent_ops [sunxidrm])
[    5.891794][  T189] selinux:
[    5.898693][  T190] apexd: Bootstrap subcommand detected
[    5.898765][  T190] apexd: ActivateFlattenedApex
[    5.898801][  T190] apexd: Scanning /system/apex
[    5.899419][  T190] apexd: Bind mounting /system/apex/com.android.adbd onto /apex/com.android.adbd
[    5.900047][  T190] apexd: Bind mounting /system/apex/com.android.adservices onto /apex/com.android.adservices
[    5.900637][  T190] apexd: Bind mounting /system/apex/com.android.appsearch onto /apex/com.android.appsearch
[    5.901214][  T190] apexd: Bind mounting /system/apex/com.android.art onto /apex/com.android.art
[    5.901543][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5501000.tcon0 (ops sunxi_tcon_component_ops [sunxidrm])
[    5.901818][  T190] apexd: Bind mounting /system/apex/com.android.btservices onto /apex/com.android.btservices
[    5.902431][  T190] apexd: Bind mounting /system/apex/com.android.conscrypt onto /apex/com.android.conscrypt
[    5.902952][  T190] apexd: Bind mounting /system/apex/com.android.extservices onto /apex/com.android.extservices
[    5.913451][  T189] ueventd: Parsing file /system/etc/ueventd.rc...
[    5.916216][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5730000.tcon3 (ops sunxi_tcon_component_ops [sunxidrm])
[    5.922254][  T189] ueventd: Added '/vendor/etc/ueventd.rc' to import list
[    5.923944][  T190] printk: apexd: 24 output lines suppressed due to ratelimiting
[    5.924165][  T190] apexd (190) used greatest stack depth: 10464 bytes left
[    5.927303][  T117] sunxi-drm soc@3000000:sunxi-drm: bound 5731000.tcon4 (ops sunxi_tcon_component_ops [sunxidrm])
[    5.932561][  T189] ueventd: Added '/odm/etc/ueventd.rc' to import list
[    5.942755][   T80] audit: type=1400 audit(1748526561.440:3): avc:  denied  { sys_admin } for  pid=117 comm="kworker/u16:2" capability=21  scontext=u:r:kernel:s0 tcontext=u:r:kernel:s0 tclass=capability permissive=1
[    5.945132][  T117] [drm] [SUNXI-CRTC]sunxi_crtc_atomic_enable
[    5.945137][  T117] [drm] sunxi_de_enable index 0
[    5.949771][  T117] [drm] sunxi_de_enable finish sw en=1
[    5.949787][  T117] [drm] [DSI] sunxi_drm_dsi_encoder_atomic_enable vrr_setp:0 start
[    5.949789][  T117] [drm] [DSI] sunxi_tcon_dsi_mode_init start
[    5.949909][  T117] [drm] [DSI] sunxi_lcd_pin_set_state start
[    5.954570][  T189] ueventd: Parsing file /vendor/etc/ueventd.rc...
[    6.095342][  T197] random: boringssl_self_: uninitialized urandom read (40 bytes read)
[    6.102506][  T189] ueventd: Parsing file /odm/etc/ueventd.rc...
[    6.131448][  T198] random: prng_seeder: uninitialized urandom read (40 bytes read)
[    6.135110][  T189] ueventd: Unable to read config file '/odm/etc/ueventd.rc': open() failed: No such file or directory
[    6.136105][  T199] random: boringssl_self_: uninitialized urandom read (40 bytes read)
[    6.172749][  T117] [drm] [DSI] sunxi_drm_dsi_encoder_atomic_enable finish
[    6.188569][  T198] prng_seeder: Hanging forever because setup failed: Unable to open hwrng /dev/hw_random
[    6.188569][  T198]
[    6.208178][  T117] [drm] Initialized sunxi-drm 3.0.0 20230901 for soc@3000000:sunxi-drm on minor 0
[    6.214976][  T198] Caused by:
[    6.216997][   T80] audit: type=1400 audit(1748526561.712:4): avc:  denied  { search } for  pid=184 comm="init" name="/" dev="dm-4" ino=2 scontext=u:r:vendor_init:s0 tcontext=u:object_r:system_dlkm_file:s0 tclass=dir permissive=1
[    6.224886][  T117] [drm] sunxi_drm_bind ok
[    6.226074][  T184] sunxi-rfkill soc@3000000:rfkill: module version: v1.1.4
[    6.226269][  T117] i2c i2c-2: of_i2c: modalias failure on /soc@3000000/twi@2512000/focaltech@38
[    6.226273][  T117] i2c i2c-2: Failed to create I2C device for /soc@3000000/twi@2512000/focaltech@38
[    6.226319][  T117] sunxi:twi-2512000.twi:[INFO]: v2.7.4 probe success
[    6.227254][  T117] sunxi:twi-2513000.twi:[INFO]: v2.7.4 probe success
[    6.228366][  T117] sunxi-cadence-combophy 6c00000.serdes: Sub System Version v2.0.0
[    6.228651][  T198]     No such file or directory (os error 2)
[    6.283755][  T184] sunxi-rfkill soc@3000000:rfkill: pinctrl_lookup_state(default) failed! return ffffffffffffffed
[    6.312737][  T189] ueventd: Coldboot took 0.127 seconds
[    6.320158][  T184] sunxi-rfkill soc@3000000:rfkill: get gpio chip_en failed
[    6.339567][  T184] sunxi-rfkill soc@3000000:rfkill: get gpio power_en failed
[    6.347617][  T184] sunxi-rfkill soc@3000000:rfkill: wlan_busnum (1)
[    6.355182][  T184] sunxi-rfkill soc@3000000:rfkill: wlan power[0] (axp8191-dcdc1) voltage: 3300mV
[    6.365441][  T184] sunxi-rfkill soc@3000000:rfkill: wlan power[1] (axp8191-bldo5) voltage: 1800mV
[    6.375694][  T184] sunxi-rfkill soc@3000000:rfkill: wlan power[2] (axp8191-cldo1) voltage: 1800mV
[    6.385726][  T184] sunxi-rfkill soc@3000000:rfkill: wlan_regon gpio=385 assert=1
[    6.394097][  T184] sunxi-rfkill soc@3000000:rfkill: wlan_hostwake gpio=384 assert=1
[    6.402743][  T184] sunxi-rfkill soc@3000000:rfkill: wakeup source is enabled
[    6.410703][  T184] sunxi-rfkill soc@3000000:rfkill: wlan power boot-on: 0, always-on: 0
[    6.419999][  T184] sunxi-rfkill soc@3000000:rfkill: bt power[0] (axp8191-dcdc1) voltage: 3300mV
[    6.430136][  T184] sunxi-rfkill soc@3000000:rfkill: bt power[1] (axp8191-bldo5) voltage: 1800mV
[    6.440266][  T184] sunxi-rfkill soc@3000000:rfkill: bt power[2] (axp8191-cldo1) voltage: 1800mV
[    6.450122][  T184] sunxi-rfkill soc@3000000:rfkill: bt_rst gpio=386 assert=0
[    6.458111][  T184] sunxi-rfkill soc@3000000:rfkill: bluetooth power boot-on: 0, always-on: 0
[    6.527208][    T1] Registered swp emulation handler
[    6.583577][  T184] g2d 5440000.g2d: Adding to iommu group 0
[    6.584547][  T212] logd.auditd: start
[    6.591007][  T184] sunxi:g2d_sunxi:[INFO]: [G2D]: rcq version initialized.major:505
[    6.594231][  T212] logd.klogd: 6418075835
[    6.602808][  T184] sunxi:g2d_sunxi:[INFO]: [G2D]: g2d_module_init
console:/ $ [    6.618121][  T212] logd: Loaded bug_map file: /system_ext/etc/selinux/bug_map
[    6.626659][  T212] logd: Loaded bug_map file: /vendor/etc/selinux/selinux_denial_metadata
[    6.636575][  T212] logd: Loaded bug_map file: /system/etc/selinux/bug_map
[    6.643045][  T219] treadahead: /treadahead/readahead_file_offset not exist;
[    6.652380][  T219] treadahead: go to open trace
[    6.686710][    T1] mke2fs: mke2fs 1.46.2 (28-Feb-2021)
[    6.692604][    T1] mke2fs: Discarding device blocks: done
[    6.703208][    T1] mke2fs: Creating filesystem with 4096 4k blocks and 4096 inodes
[    6.711758][    T1] mke2fs:
[    6.714970][    T1] mke2fs: Allocating group tables: done
[    6.724875][    T1] mke2fs: Writing inode tables: done
[    6.734495][    T1] mke2fs: Creating journal (1024 blocks): done
[    6.741203][    T1] mke2fs: Writing superblocks and filesystem accounting information: done
[    6.751691][    T1] mke2fs:
[    6.781266][    T1] e2fsdroid: Created filesystem with 11/4096 inodes and 1545/4096 blocks
[    6.792430][    T1] EXT4-fs (mmcblk0p21): Ignoring removed nomblk_io_submit option
[    6.803250][    T1] EXT4-fs (mmcblk0p21): mounted filesystem with ordered data mode. Opts: errors=remount-ro,nomblk_io_submit. Quota mode: none.
[    6.876619][    T1] EXT4-fs (mmcblk0p21): mounted filesystem with ordered data mode. Opts: errors=panic. Quota mode: none.
[    6.999862][    T1] EXT4-fs (mmcblk0p22): Ignoring removed nomblk_io_submit option
[    7.010725][    T1] EXT4-fs (mmcblk0p22): mounted filesystem with ordered data mode. Opts: errors=remount-ro,nomblk_io_submit. Quota mode: none.
[    7.052736][    T1] EXT4-fs (mmcblk0p22): mounted filesystem with ordered data mode. Opts: errors=panic. Quota mode: none.
[    7.098465][  T251] random: newfs_msdos: uninitialized urandom read (40 bytes read)
[    7.194125][  T229] type=1400 audit(1748526562.692:5): avc: denied { getattr } for comm="init" path="/sys/kernel/debug/devices_deferred" dev="debugfs" ino=11811 scontext=u:r:init:s0 tcontext=u:object_r:debugfs:s0 tclass=file permissive=1
[    7.218829][  T229] type=1400 audit(1748526562.692:6): avc: denied { getattr } for comm="init" path="/sys/kernel/debug/wakeup_sources" dev="debugfs" ino=1048 scontext=u:r:init:s0 tcontext=u:object_r:debugfs_wakeup_sources:s0 tclass=file permissive=1
[    7.289947][  T257] AW_keymint_2 : starting aw keymint service
[    7.290616][  T257] AW_keymint_2 : no optee, use software keymint
[    7.332656][  T257] AW_keymint_2 : adding keymint service instance: android.hardware.security.keymint.IKeyMintDevice/default
[    7.340360][  T257] AW_keymint_2 : adding keymint service instance: android.hardware.security.secureclock.ISecureClock/default
[    7.353464][  T257] AW_keymint_2 : adding keymint service instance: android.hardware.security.sharedsecret.ISharedSecret/default
[    7.366575][  T257] AW_keymint_2 : adding keymint service instance: android.hardware.security.keymint.IRemotelyProvisionedComponent/default
[    7.380207][  T257] AW_keymint_2 : start aw keymint service ok
[    9.361924][    T1] EXT4-fs (mmcblk0p29): Ignoring removed nomblk_io_submit option
[    9.381124][    T1] EXT4-fs (mmcblk0p29): mounted filesystem with ordered data mode. Opts: errors=remount-ro,nomblk_io_submit. Quota mode: journalled.
[    9.480150][    C6] random: crng init done
[    9.484731][    C6] random: 84 urandom warning(s) missed due to ratelimiting
[    9.604721][    T1] EXT4-fs (mmcblk0p29): Ignoring removed nomblk_io_submit option
[    9.613270][    T1] EXT4-fs (mmcblk0p29): Using encoding defined by superblock: utf8-12.1.0 with flags 0x0
[    9.631024][    T1] EXT4-fs (mmcblk0p29): mounted filesystem with ordered data mode. Opts: barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic,resuid=0,resgid=1065. Quota mode: journalled.
[    9.704261][  T184] pvrsrvkm: loading out-of-tree module taints kernel.
[    9.735350][  T184] [sunxi bxm]SysDevInit start!
[    9.740526][  T184] pvrsrvkm 1800000.gpu: sunxi_platform_init start
[    9.747581][  T184] pvrsrvkm 1800000.gpu: warning: default clk_rate is NOT set in DTS, set it to default:600000000
[    9.759138][  T184] pvrsrvkm 1800000.gpu: sunxi_parse_dts clk_rate:600000000
[    9.768272][  T184] pvrsrvkm 1800000.gpu: succeed to get gpu regulator, default volt value:800000
[    9.778315][  T184] pvrsrvkm 1800000.gpu: get opp:(400000000 hz, 800000 uv)
[    9.786097][  T184] pvrsrvkm 1800000.gpu: get opp:(600000000 hz, 800000 uv)
[    9.793865][  T184] pvrsrvkm 1800000.gpu: get opp:(800000000 hz, 840000 uv)
[    9.801636][  T184] pvrsrvkm 1800000.gpu: get opp:(1008000000 hz, 960000 uv)
[    9.809500][  T184] pvrsrvkm 1800000.gpu: opp count:4
[    9.815135][  T184] pvrsrvkm 1800000.gpu: set default clk_rate to max opp freq:1008000000
[    9.824260][  T184] pvrsrvkm 1800000.gpu: sunxi_parse_dts finished
[    9.831273][  T184] pvrsrvkm 1800000.gpu: sunxi_set_device_clk_rate:1008000000
[    9.839353][  T184] pvrsrvkm 1800000.gpu: sunxi_platform_init end
[    9.846159][  T184] [sunxi bxm]SysDevInit end!
[    9.851140][  T184] pvrsrvkm 1800000.gpu: sunxiPrePowerState ePwrFlags:1 current power status:1 1
[    9.861047][  T184] pvrsrvkm 1800000.gpu: sunxiPostPowerState ePwrFlags:1 current power status:1 1
[    9.871049][  T184] PVR_K:  184: Read BVNC 36.56.104.183 from HW device registers
[    9.879399][  T184] pvrsrvkm 1800000.gpu: sunxiPrePowerState ePwrFlags:1 current power status:1 1
[    9.889309][  T184] pvrsrvkm 1800000.gpu: sunxiPostPowerState ePwrFlags:1 current power status:1 1
[    9.899350][  T184] PVR_K:  184: RGX Device registered BVNC 36.56.104.183 with 1 core in the system
[    9.909820][  T184] pvrsrvkm 1800000.gpu: Found 4 OPP points.
[    9.916239][  T184] pvrsrvkm 1800000.gpu: opp[1/4]: (400000000 Hz, 800000 uV)
[    9.924206][  T184] pvrsrvkm 1800000.gpu: opp[2/4]: (600000000 Hz, 800000 uV)
[    9.932170][  T184] pvrsrvkm 1800000.gpu: opp[3/4]: (800000000 Hz, 840000 uV)
[    9.940133][  T184] pvrsrvkm 1800000.gpu: opp[4/4]: (1008000000 Hz, 960000 uV)
[    9.949382][  T184] [drm] Initialized pvr 24.2.6643903 20170530 for 1800000.gpu on minor 1
[   10.073537][  T226] vold: keystore2 Keystore earlyBootEnded returned service specific error: -68
[   10.096527][    T1] init: Not setting encryption policy on: /data/apex
[   10.108086][    T1] init: Inferred action different from explicit one, expected 0 but got 2
[   10.120795][    T1] init: Inferred action different from explicit one, expected 0 but got 3
[   10.121294][  T225] logd: logd reinit
[   10.131331][    T1] init: Inferred action different from explicit one, expected 0 but got 2
[   10.134684][  T225] logd: Cannot read /data/misc/logd/event-log-tags
[   10.145083][    T1] init: starting service 'apexd'...
[   10.151673][  T225] logd: FrameworkListener: read() failed (Connection reset by peer)
[   10.158952][    T1] init: Service 'logd-reinit' (pid 289) exited with status 0 oneshot service took 0.065000 seconds in background
[   10.178530][    T1] init: Sending signal 9 to service 'logd-reinit' (pid 289) process group...
[   10.186057][  T290] apexd: This device does not support updatable APEX. Exiting
[   10.188691][    T1] libprocessgroup: Successfully killed process cgroup uid 1036 pid 289 in 0ms
[   10.196399][  T290] apexd: Marking APEXd as activated
[   10.207566][    T1] init: Command 'copy /data/misc/recovery/ro.build.fingerprint /data/misc/recovery/ro.build.fingerprint.1' action=post-fs-data (/system/etc/init/hw/init.rc:754) took 0ms and failed: Could not read input file '/data/misc/recovery/ro.build.fingerprint': open() failed: No such file or directory
[   10.242371][    T1] init: Service 'apexd' (pid 290) exited with status 0 oneshot service took 0.084000 seconds in background
[   10.446885][  T295] vdc: Waited 0ms for vold
[   10.498427][  T226] vold: Failed to chmod /data/system_ce/0: No such file or directory
[   10.507563][  T226] vold: Failed to chmod /data/misc_ce/0: No such file or directory
[   10.516427][  T226] vold: Failed to chmod /data/media/0: No such file or directory
[   10.727306][  T301] apexd: This device does not support updatable APEX. Exiting
[   10.735722][  T301] apexd: Marking APEXd as ready
[   10.793386][  T184] init: Top-level directory needs encryption action, eg mkdir /data/audio_d <mode> <uid> <gid> encryption=Require
[   10.828546][  T184] init: Inferred action different from explicit one, expected 0 but got 2
[   10.841725][    T1] WARNING: Unprivileged eBPF is enabled, data leaks possible via Spectre v2 BHB attacks!
[   10.879971][  T305] bpfloader: Override /apex/com.android.tethering/etc/bpf/offload.o with /system/etc/bpf-override/offload.o
[   10.893957][  T305] LibBpfLoader: Loading critical for tethering ELF object /system/etc/bpf-override/offload.o with license Apache 2.0
[   10.907540][  T305] LibBpfLoader: Section bpfloader_min_ver value is 2 [0x2]
[   10.915478][  T305] LibBpfLoader: Section bpfloader_max_ver value is 65536 [0x10000]
[   10.924190][  T305] LibBpfLoader: Section size_of_bpf_map_def value is 116 [0x74]
[   10.932613][  T305] LibBpfLoader: Section size_of_bpf_prog_def value is 92 [0x5c]
[   10.940970][  T305] LibBpfLoader: BpfLoader version 0x00013 processing ELF object /system/etc/bpf-override/offload.o with ver [0x00002,0x10000)
[   10.958101][  T305] LibBpfLoader: Loaded code section 3 (schedcls_tether_downstream6_ether)
[   10.967725][  T305] LibBpfLoader: Loaded relo section 3 (.relschedcls/tether_downstream6_ether)
[   10.977447][  T305] LibBpfLoader: Adding section 3 to cs list
[   11.183655][  T305] printk: bpfloader: 1670 output lines suppressed due to ratelimiting
[   11.222764][  T308] update_verifier: Started with arg 1: nonencrypted
[   11.233363][  T308] update_verifier: Booting slot 0: isSlotMarkedSuccessful=1
[   11.241388][  T308] update_verifier: Leaving update_verifier.
[   11.343807][  T315] sunxi-rfkill soc@3000000:rfkill: wlan power on success
[   11.344486][  T184] [Awinic] aw87xxx_pa_init:driver version: v2.14.0
[   11.359212][  T184] [Awinic] [14-0058]aw87xxx_dtsi_parse: get det_battery_supply failed
[   11.359212][  T184]
[   11.371639][  T184] [Awinic] [14-0059]aw87xxx_dtsi_parse: get det_battery_supply failed
[   11.371639][  T184]
[   11.401134][  T184] sunxi:sound-i2s:[WARN]: 2206 snd_sunxi_dts_params_init(): clk-en-post-delay missing
[   11.411709][  T184] sunxi:sound-i2s:[WARN]: 2214 snd_sunxi_dts_params_init(): clk-keep missing
[   11.421777][  T184] sunxi:sound-i2s:[WARN]: 2206 snd_sunxi_dts_params_init(): clk-en-post-delay missing
[   11.432302][  T184] sunxi:sound-i2s:[WARN]: 2214 snd_sunxi_dts_params_init(): clk-keep missing
[   11.446002][  T184] sunxi:sound-ac101:[INFO]: 2626 ac101_i2c_probe():
[   11.451768][  T315] misc sunxi-wlan: start scan device on bus_index: 1
[   11.453414][  T184] sunxi:sound-ac101:[ERR]: 2592 ac101_set_params_from_of(): det_gpio        -> 34
[   11.460668][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.470750][  T184] sunxi:sound-ac101:[ERR]: 2593 ac101_set_params_from_of(): plug_gpio        -> 313
[   11.495768][  T184] sunxi:sound-common:[INFO]: 36 snd_sunxi_pa_user_trig_init(): pa user mode -> init
[   11.496150][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.506090][  T184] sunxi:sound-common:[INFO]: 36 snd_sunxi_pa_user_trig_init(): pa user mode -> init
[   11.533005][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[   11.543098][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[   11.552374][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.569459][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.585843][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 11, RE !!
[   11.595029][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[   11.610981][  T184] sunxi:sound-codec-hdmi:[ERR]: 442 sunxi_codec_dev_probe(): register codec-hdmi success
[   11.611256][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.637540][  T184] sunxi:sound-mach:[WARN]: 372 asoc_simple_parse_ucfmt(): set data late to default
[   11.648055][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.662907][   T94] platform boost5v-en: deferred probe pending
[   11.689441][   T95] mmc1: queuing unknown CIS tuple 0x10 [07 00 11 00 8e] (5 bytes)
[   11.703261][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.704497][  T184] sunxi:sound-ac101:[INFO]: 1529 ac101_probe(): wait ac101 reset successfully, need 0x101/257
[   11.717684][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 4 timing LEGACY(SDR12) dt B
[   11.741916][  T184] debugfs: Directory '2532000.i2s0_plat' with parent 'sndi2s0' already present!
[   11.743293][   T95] mmc1: queuing unknown CIS tuple 0x10 [07 00 31 00 32] (5 bytes)
[   11.753048][  T160] sunxi:sound-ac101:[INFO]: 531 sunxi_jack_adv_det_scan_work():
[   11.770114][  T160] [sound] jack report -> OUT
[   11.775378][   T95] mmc1: new SDIO card at address ac4d
[   11.776478][  T184] input: sndi2s0 Headphones as /devices/platform/soc@3000000/soc@3000000:i2s0_mach/sound/card0/input1
[   11.784648][  T315] sunxi-rfkill soc@3000000:rfkill: wlan power off success
[   11.793712][  T184] sunxi:sound-mach:[WARN]: 372 asoc_simple_parse_ucfmt(): set data late to default
[   11.801118][  T315] misc sunxi-wlan: start scan device on bus_index: 1
[   11.811664][  T184] debugfs: Directory '2535000.i2s3_plat' with parent 'sndhdmi' already present!
[   11.818680][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 7, RTO !!
[   11.837682][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 7, RTO !!
[   11.846907][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 7, RTO !!
[   11.856110][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 7, RTO !!
[   11.856901][  T184] npu[b8][b8] vipcore, platform driver init
[   11.871918][   T95] mmc1: card ac4d removed
[   11.872407][  T184] npu[b8][b8] vipcore, insmod param cpu_physical=0x0
[   11.876690][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[   11.884000][  T184] npu[b8][b8] vipcore, insmod param cpu_physical=0x0
[   11.898907][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.905459][  T184] npu[b8][b8] vipcore, insmod param cpu_physical=0x0
[   11.919205][  T315] aicbsp_init
[   11.926452][  T184] npu[b8][b8] vipcore, insmod param cpu_physical=0x0
[   11.929400][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.929504][  T315] aicbsp_init, Driver Release Tag: aic-bsp-compatible(sdio)-20240730-002
[   11.936851][  T184] npu[b8][b8] vipcore, platform device compatible=allwinner,npu
[   11.951401][  T315] -->aicbt_rfkill_init
[   11.951716][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[   11.960349][  T184] npu[b8][b8] vipcore, platform driver device=0xffffff80c0b7e410
[   11.968565][  T315] <--aicbt_rfkill_init
[   11.969279][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[   11.972957][  T184] npu[b8][b8] clock_rate: 26000000
[   11.982153][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   11.990777][  T184] npu[b8][b8] vipcore irq number is 463.
[   11.997953][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   12.004224][  T184] npu[b8][b8] npu power domains status: 0
[   12.004941][  T315] [BT_LPM] bluesleep_init: BlueSleep Mode Driver Ver 1.3.3
[   12.004949][  T315] [BT_LPM] bluesleep_init: Driver Release Tag: aic-btlpm-20220429-008
[   12.005329][  T315] [BT_LPM] bluesleep_probe: bt_hostwake gpio=388 assert=1
[   12.005329][  T315]
[   12.005333][  T315] [BT_LPM] bluesleep_probe: override host_wake assert to 1
[   12.005367][  T315] [BT_LPM] bluesleep_probe: wakeup source is disabled!
[   12.005367][  T315]
[   12.005380][  T315] [BT_LPM] bluesleep_probe: bt_wake gpio=387 assert=1
[   12.005380][  T315]
[   12.005384][  T315] [BT_LPM] bluesleep_probe: override ext_wake assert to 1
[   12.005400][  T315] [BT_LPM] bluesleep_probe: uart_index (1)
[   12.005400][  T315]
[   12.012191][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[   12.023847][  T184] NPU AXI CLK NULL
[   12.030788][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[   12.044049][  T184] NPU AHB CLK NULL
[   12.051092][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[   12.058151][  T184] NPU TZMA CLK NULL
[   12.067894][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 5, RTO !!
[   12.077302][  T184] npu[b8][b8] EXTRA: 0x00005100, SID: 0x0, max_freq: 1100000000, default_freq: 1100000000
[   12.085225][   T95] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[   12.095058][  T184] npu[b8][b8] current dvfs: 0, vf index: 0
[   12.095174][  T184] vipcore 3600000.npu: dev_pm_opp_set_regulators: no regulator (npu) found: -19
[   12.210697][  T184] npu[b8][b8] failed to set opp regulator
[   12.216944][  T184] npu[b8][b8] enable aw vip devfreq
[   12.222590][  T184] npu[b8][b8] no available freq info
[   12.228375][  T184] vipcore 3600000.npu: supply npu not found, using dummy regulator
[   12.237305][  T184] npu[b8][b8] vipcore, device_cnt=1, core_cnt=1
[   12.244308][  T184] npu[b8][b8] core_0, request irqline=463, name=vipcore_0
[   12.252171][  T184] npu[b8][b8] vipcore, allocate page for video memory, size: 0x400000 bytes
[   12.263004][  T184] npu[b8][b8] vipcore, heap_cnt=0, reserved video memory cpu_phy=0x11ac00000, vip_phy=0x11ac00000, size=0x400000
[   12.276294][  T184] npu[b8][b8] VIPLite driver version 2.0.3.0-AW-2024-05-29
[   12.308072][  T229] type=1400 audit(1748526567.804:10): avc: denied { write } for comm="init" name="discard_max_bytes" dev="sysfs" ino=39324 scontext=u:r:init:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[   12.330221][  T229] type=1400 audit(1748526567.804:11): avc: denied { open } for comm="init" path="/sys/devices/platform/soc@3000000/4023000.sdmmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/queue/discard_max_bytes" dev="sysfs" ino=39324 scontext=u:r:init:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[   12.425767][  T344] healthd: No battery devices found
[   12.433879][  T344] healthd: battery none chg=
[   12.438935][  T344] healthd: battery none chg=
[   12.444250][  T344] healthd: battery none chg=
[   12.479970][  T343] PVR_K:  343: RGX Firmware image 'rgx.fw.36.56.104.183' loaded
[   12.499008][  T343] PVR_K:  343: Shader binary image 'rgx.sh.36.56.104.183' loaded
[   12.512245][  T343] pvrsrvkm 1800000.gpu: sunxiPrePowerState ePwrFlags:1 current power status:0 1
[   12.513689][  T229] type=1400 audit(1748526568.012:12): avc: denied { read } for comm="display.output-" name="u:object_r:boot_status_prop:s0" dev="tmpfs" ino=80 scontext=u:r:hal_awdisplayoutput_default:s0 tcontext=u:object_r:boot_status_prop:s0 tclass=file permissive=1
[   12.522326][  T343] pvrsrvkm 1800000.gpu: sunxiPostPowerState ePwrFlags:1 current power status:1 1
[   12.549389][  T229] type=1400 audit(1748526568.012:13): avc: denied { open } for comm="display.output-" path="/dev/__properties__/u:object_r:boot_status_prop:s0" dev="tmpfs" ino=80 scontext=u:r:hal_awdisplayoutput_default:s0 tcontext=u:object_r:boot_status_prop:s0 tclass=file permissive=1
[   12.575490][  T343] pvrsrvkm 1800000.gpu: sunxiPrePowerState ePwrFlags:1 current power status:1 1
[   12.588254][  T229] type=1400 audit(1748526568.012:14): avc: denied { getattr } for comm="display.output-" path="/dev/__properties__/u:object_r:boot_status_prop:s0" dev="tmpfs" ino=80 scontext=u:r:hal_awdisplayoutput_default:s0 tcontext=u:object_r:boot_status_prop:s0 tclass=file permissive=1
[   12.598117][  T343] pvrsrvkm 1800000.gpu: sunxiPostPowerState ePwrFlags:1 current power status:1 1
[   12.601525][  T344] healthd: battery none chg=
[   12.625376][  T344] healthd: battery none chg=
[   12.626833][  T229] type=1400 audit(1748526568.012:15): avc: denied { map } for comm="display.output-" path="/dev/__properties__/u:object_r:boot_status_prop:s0" dev="tmpfs" ino=80 scontext=u:r:hal_awdisplayoutput_default:s0 tcontext=u:object_r:boot_status_prop:s0 tclass=file permissive=1
[   12.637247][  T362] function = msa_startup =  =  =  =  =  =  =  =  = LINE = 1043.
[   12.637765][  T343] pvrsrvkm 1800000.gpu: sunxiPrePowerState ePwrFlags:1 current power status:0 1
[   12.637837][  T343] pvrsrvkm 1800000.gpu: sunxiPostPowerState ePwrFlags:1 current power status:1 1
[   12.637843][  T343] pvrsrvkm 1800000.gpu: sunxiPrePowerState ePwrFlags:1 current power status:1 1
[   12.637845][  T343] pvrsrvkm 1800000.gpu: sunxiPostPowerState ePwrFlags:1 current power status:1 1
[   12.637882][  T344] healthd: battery none chg=
[   12.640102][  T344] healthd: battery none chg=
[   12.641800][  T229] type=1400 audit(1748526568.056:16): avc: denied { read } for comm="android.hardwar" name="thermal" dev="sysfs" ino=9141 scontext=u:r:hal_power_default:s0 tcontext=u:object_r:sysfs_thermal:s0 tclass=dir permissive=1
[   12.643025][  T344] healthd: battery none chg=
[   12.645330][  T184] file system registered
[   12.647025][  T362] msa use sepical device node name  =  msa
[   12.652935][  T184] using random self ethernet address
[   12.652944][  T184] using random host ethernet address
[   12.656841][  T343] PVR_K:  343: FTrace event from "gpu_work_period" enabled
[   12.675510][  T229] type=1400 audit(1748526568.056:17): avc: denied { open } for comm="android.hardwar" path="/sys/class/thermal" dev="sysfs" ino=9141 scontext=u:r:hal_power_default:s0 tcontext=u:object_r:sysfs_thermal:s0 tclass=dir permissive=1
[   12.685146][  T362] ERROR! get gsensor_para failed, func:sunxi_gsensor_startup, line:304
[   12.693964][  T229] type=1400 audit(1748526568.072:18): avc: denied { setattr } for comm="init" name="ext_csd" dev="debugfs" ino=11031 scontext=u:r:init:s0 tcontext=u:object_r:debugfs_mmc:s0 tclass=file permissive=1
[   12.703702][  T362] =========gsensor script_get_err============
[   12.703710][  T362] msa_startup: err.
[   12.710831][  T184] sunxi-rfkill soc@3000000:rfkill: block state already is 1
[   12.714169][  T229] type=1400 audit(1748526568.088:19): avc: denied { integrity } for comm="init" lockdown_reason="debugfs access" scontext=u:r:init:s0 tcontext=u:r:init:s0 tclass=lockdown permissive=1
[   12.735457][  T344] healthd: battery none chg=
[   12.763702][  T184] pps_core: LinuxPPS API ver. 1 registered
[   12.900186][  T184] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[   12.914661][  T362] qst-qmi8658_i2c_init(line:1046)  qmi8658 A+G driver: init
[   12.922816][  T362] function=startup=========LINE=1025.
[   12.923403][  T184] PTP clock support registered
[   12.929763][  T362] ERROR! get gsensor_para failed, func:sunxi_gsensor_startup, line:304
[   12.943343][  T362] =========gsensor script_get_err============
[   12.950007][  T362] startup: err.
[   12.955627][  T184] dwmac-sunxi 4500000.ethernet: IRQ eth_wake_irq not found
[   12.963890][  T184] sunxi:stmmac-4500000.ethernet:[INFO]: Phy use soc fanout
[   12.972399][  T184] sunxi:stmmac-4500000.ethernet:[INFO]: Not found delay-maps in dts
[   12.981662][  T184] sunxi:stmmac-4500000.ethernet:[INFO]: RGMII use external transmit clock
[   12.991313][  T184] dwmac-sunxi 4500000.ethernet: User ID: 0x20, Synopsys ID: 0x53
[   12.999835][  T184] dwmac-sunxi 4500000.ethernet:    DWMAC4/5
[   13.006089][  T184] dwmac-sunxi 4500000.ethernet: DMA HW capability register supported
[   13.008638][  T389] [drm] sunxi-hdmi: [warn] hdmi drv check old dynamic range 1 unsupport!
[   13.014951][  T184] dwmac-sunxi 4500000.ethernet: RX Checksum Offload Engine supported
[   13.014954][  T184] dwmac-sunxi 4500000.ethernet: TX Checksum insertion supported
[   13.014955][  T184] dwmac-sunxi 4500000.ethernet: Wake-Up On Lan supported
[   13.015092][  T184] dwmac-sunxi 4500000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[   13.015098][  T184] dwmac-sunxi 4500000.ethernet: Enabled RFS Flow TC (entries=8)
[   13.015103][  T184] dwmac-sunxi 4500000.ethernet: Using 32 bits DMA width
[   13.025269][  T362] ERROR! get ls_para failed, func:sunxi_ls_startup, line:563
[   13.033997][  T389] [drm] sunxi-hdmi: drm hdmi detect: disconnect
[   13.041985][  T362] startup: ls_fetch_sysconfig_para err.
[   13.049853][  T389] [drm] sunxi-hdmi: [warn] hdmi drv check old dynamic range 1 unsupport!
[   13.193111][  T184] sunxi:stmmac-4500000.ethernet:[INFO]: probe success (Version 0.3.2)
[   13.196839][  T418] [drm] sunxi-hdmi: drm hdmi detect: disconnect
[   13.218417][  T418] [drm] sunxi-hdmi: [warn] hdmi drv check old dynamic range 1 unsupport!
[   13.218839][  T184] IR NEC protocol handler initialized
[   13.240427][  T184] sun60iw2-r-pinctrl 7025000.pinctrl: pin PL4 already requested by 7025000.pinctrl:356; cannot claim for 7040000.irrx
[   13.254084][  T184] sun60iw2-r-pinctrl 7025000.pinctrl: pin-356 (7040000.irrx) status -22
[   13.263233][  T184] sun60iw2-r-pinctrl 7025000.pinctrl: could not request pin 356 (PL4) from group PL4  on device 7025000.pinctrl
[   13.276254][  T184] sunxi-rc-recv 7040000.irrx: Error applying setting, reverse things back
[   13.313983][  T184] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   13.318667][  T418] [drm] sunxi-hdmi: drm hdmi detect: disconnect
[   13.323851][  T184] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[   13.330621][  T418] [drm] sunxi-hdmi: [warn] hdmi drv check old dynamic range 1 unsupport!
[   13.338692][   T95] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[   13.358365][   T95] cfg80211: failed to load regulatory.db
[   13.385258][  T184] deinterlace 5400000.deinterlace: Adding to iommu group 0
[   13.393262][  T184] sunxi:deinterlace:[INFO]: DI probe
[   13.403432][  T184] sunxi:ehci_sunxi:[INFO]: sunxi-ehci: EHCI SUNXI driver
[   13.417438][  T184] sunxi:sunxi_hci:[INFO]: sunxi ehci0-controller don't init wakeup source
[   13.426852][  T184] sunxi:ehci_sunxi:[INFO]: [sunxi-ehci0]: probe, pdev->name: 4101000.ehci0-controller, sunxi_ehci: 0xffffffc001df0030, 0x:ffffffc00ca4d000, irq_no:1d5
[   13.443656][  T184] sunxi:ehci_sunxi:[INFO]: [sunxi-ehci0]: Not init ehci0
[   13.451870][  T184] sunxi:sunxi_hci:[INFO]: sunxi ehci1-controller don't init wakeup source
[   13.461224][  T184] sunxi:ehci_sunxi:[INFO]: [sunxi-ehci1]: probe, pdev->name: 4200000.ehci1-controller, sunxi_ehci: 0xffffffc001df0930, 0x:ffffffc00ca65000, irq_no:1d6
[   13.478132][  T184] sunxi-ehci 4200000.ehci1-controller: supply drvvbus not found, using dummy regulator
[   13.488964][  T184] sunxi-ehci 4200000.ehci1-controller: supply hci not found, using dummy regulator
[   13.499325][  T184] sunxi-ehci 4200000.ehci1-controller: EHCI Host Controller
[   13.507340][  T184] sunxi-ehci 4200000.ehci1-controller: new USB bus registered, assigned bus number 1
[   13.517819][  T184] sunxi-ehci 4200000.ehci1-controller: irq 470, io mem 0x04200000
[   13.540163][  T184] sunxi-ehci 4200000.ehci1-controller: USB 2.0 started, EHCI 1.00
[   13.548795][  T184] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
[   13.558810][  T184] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   13.567653][  T184] usb usb1: Product: EHCI Host Controller
[   13.573870][  T184] usb usb1: Manufacturer: Linux 5.15.119-gc82a3c8d0b63-dirty ehci_hcd
[   13.582807][  T184] usb usb1: SerialNumber: sunxi-ehci
[   13.588827][  T184] hub 1-0:1.0: USB hub found
[   13.593830][  T184] hub 1-0:1.0: 1 port detected
[   13.608353][  T184] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[   13.618398][  T184] ohci-pci: OHCI PCI platform driver
[   13.627014][  T184] sunxi:ohci_sunxi:[INFO]: sunxi-ohci: OHCI SUNXI driver
[   13.635291][  T184] sunxi:sunxi_hci:[INFO]: sunxi ohci0-controller don't init wakeup source
[   13.644689][  T184] sunxi:ohci_sunxi:[INFO]: [sunxi-ohci0]: probe, pdev->name: 4101400.ohci0-controller, sunxi_ohci: 0xffffffc001df04b0
[   13.658331][  T184] sunxi:ohci_sunxi:[INFO]: [sunxi-ohci0]: Not init ohci0
[   13.666544][  T184] sunxi:sunxi_hci:[INFO]: sunxi ohci1-controller don't init wakeup source
[   13.675926][  T184] sunxi:ohci_sunxi:[INFO]: [sunxi-ohci1]: probe, pdev->name: 4200400.ohci1-controller, sunxi_ohci: 0xffffffc001df0db0
[   13.689639][  T184] sunxi-ohci 4200400.ohci1-controller: supply drvvbus not found, using dummy regulator
[   13.700480][  T184] sunxi-ohci 4200400.ohci1-controller: supply hci not found, using dummy regulator
[   13.710834][  T184] sunxi-ohci 4200400.ohci1-controller: OHCI Host Controller
[   13.718846][  T184] sunxi-ohci 4200400.ohci1-controller: new USB bus registered, assigned bus number 2
[   13.729379][  T184] sunxi-ohci 4200400.ohci1-controller: irq 472, io mem 0x04200400
[   13.800390][  T184] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 5.15
[   13.810415][  T184] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   13.819257][  T184] usb usb2: Product: OHCI Host Controller
[   13.825477][  T184] usb usb2: Manufacturer: Linux 5.15.119-gc82a3c8d0b63-dirty ohci_hcd
[   13.834416][  T184] usb usb2: SerialNumber: sunxi-ohci
[   13.840451][  T184] hub 2-0:1.0: USB hub found
[   13.845456][  T184] hub 2-0:1.0: 1 port detected
[   13.852562][   T95] usb 1-1: new high-speed USB device number 2 using sunxi-ehci
[   13.861921][  T184] sunxi:phy_sunxi_plat-6b00000.phy:[INFO]: resistance calibration supported - enabled, mode - V2
[   13.873943][  T184] sunxi:phy_sunxi_plat-6b00000.phy:[INFO]: phy provider register success
[   13.887686][  T184] sunxi:dwc3_sunxi_plat-12.usbc2:[ERR]: couldn't get drvvbus supply
[   13.897741][  T184] sunxi-cadence-combophy 6c00000.serdes: combophy1 set power ON
[   13.919545][  T441] sunxi:sound-ac101:[INFO]: 653 ac101_startup(): wait ac101 reset successfully, need 0x101/257
[   13.933017][  T184] xhci-hcd xhci-hcd.41.auto: xHCI Host Controller
[   13.935958][  T441] sunxi-ac101 14-001a: sunxi:sound-ac101ac101 sysclk source don't pll, don't need config pll
[   13.940064][  T184] xhci-hcd xhci-hcd.41.auto: new USB bus registered, assigned bus number 3
[   13.940166][  T184] xhci-hcd xhci-hcd.41.auto: hcc params 0x0118ffc5 hci version 0x120 quirks 0x0000000000010010
[   13.966260][  T441] dma dma0chan0: The timeout func is not suportted or chan->private is NULL, timeout mode not used
[   13.972188][  T184] xhci-hcd xhci-hcd.41.auto: irq 473, io mem 0x06a00000
[   13.991639][  T184] xhci-hcd xhci-hcd.41.auto: xHCI Host Controller
[   13.998683][  T184] xhci-hcd xhci-hcd.41.auto: new USB bus registered, assigned bus number 4
[   14.008116][  T184] xhci-hcd xhci-hcd.41.auto: Host supports USB 3.1 Enhanced SuperSpeed
[   14.017244][  T184] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
[   14.027289][  T184] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   14.036167][  T184] usb usb3: Product: xHCI Host Controller
[   14.042403][  T184] usb usb3: Manufacturer: Linux 5.15.119-gc82a3c8d0b63-dirty xhci-hcd
[   14.051351][  T184] usb usb3: SerialNumber: xhci-hcd.41.auto
[   14.057671][   T95] usb 1-1: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.11
[   14.060470][  T184] hub 3-0:1.0: USB hub found
[   14.067579][   T95] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[   14.067581][   T95] usb 1-1: Product: USB 2.0 Hub
[   14.068916][   T95] hub 1-1:1.0: USB hub found
[   14.072601][  T184] hub 3-0:1.0: 1 port detected
[   14.085454][   T95] hub 1-1:1.0: 4 ports detected
[   14.086840][  T184] usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
[   14.111935][  T184] usb usb4: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.15
[   14.121962][  T184] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   14.130811][  T184] usb usb4: Product: xHCI Host Controller
[   14.137040][  T184] usb usb4: Manufacturer: Linux 5.15.119-gc82a3c8d0b63-dirty xhci-hcd
[   14.145986][  T184] usb usb4: SerialNumber: xhci-hcd.41.auto
[   14.152602][  T184] hub 4-0:1.0: USB hub found
[   14.157604][  T184] hub 4-0:1.0: 1 port detected
[   14.163161][  T184] sunxi:dwc3_sunxi_plat-12.usbc2:[INFO]: DesignWare USB3 Allwinner Glue Layer Driver(v1.0.22 2024-10-08 16:30)
[   14.184539][  T184] sunxi_usb_udc 4100000.udc-controller: sunxi:sunxi_usb_udc UDC Inner DMA Feature - wordaddr: 1, extend: enabled
[   14.201634][  T184] sunxi:sunxi_usbc:[INFO]: OTG can't find bcten-gpio, use default mode.
[   14.211003][  T184] sunxi:sunxi_usbc:[INFO]: get det_vbus is fail, -84
[   14.218364][  T184] sunxi:sunxi_usbc:[INFO]: get id is fail, -84
[   14.233759][  T184] usbcore: registered new interface driver option
[   14.246127][  T184] usbserial: USB Serial support registered for GSM modem (1-port)
[   14.257084][  T184] I2C functionality : OK...
[   14.262411][  T184] husb311 failed to find usb power
[   14.270733][  T184] husb311 13-004e: vbus is already Off
[   14.277974][  T184] sunxi:sunxi_usbc:[INFO]: usb role switch set null -> null
[   14.287433][  T448] husb311 13-004e: vbus is already Off
[   14.287730][  T184] husb311 13-004e: Vendor ID:0x2e99, Product ID:0x0311, probe success
[   14.294758][  T448] sunxi:sunxi_usbc:[INFO]: usb role switch set null -> null
[   14.331714][  T184] sunxi:lradc-2524000.lradc:[WARN]: get key_debounce failed, please check whether to enable key debounce
[   14.344215][  T184] sunxi:lradc-2524000.lradc:[WARN]: warn: filter_cnt not set, default value is 3
[   14.355347][  T184] input: sunxi-keyboard as /devices/platform/soc@3000000/2524000.lradc/input/input2
[   14.367079][  T184] sunxi:lradc-2524000.lradc:[INFO]: sunxi lradc init success
[   14.377856][  T184] sunxi:sunxi_smcdrm config service not available: FFFFFFFF
[   14.428922][  T184] sunxi:VE:[INFO]: 2373 sunxi_cedar_init(): sunxi cedar version 1.1
[   14.445886][  T184] sunxi-cedar 1c0e000.ve: Adding to iommu group 0
[   14.452968][  T184] sunxi:VE:[INFO]: 2295 sunxi_cedar_probe(): probe ve
[   14.460508][  T184] sunxi-cedar 1c0e000.ve: supply ve not found, using dummy regulator
[   14.469664][  T184] sunxi-cedar 1c0e000.ve: sunxi:VE no or not support operating-points-v2 node
[   14.479573][  T184] sunxi-cedar soc@3000000:ve1@1c0e000: Adding to iommu group 0
[   14.487906][  T184] sunxi:VE:[INFO]: 2298 sunxi_cedar_probe(): probe ve1
[   14.495464][  T184] sunxi-cedar 1c10000.ve2: Adding to iommu group 0
[   14.502611][  T184] sunxi:VE:[INFO]: 2301 sunxi_cedar_probe(): probe ve2
[   14.510241][  T184] sunxi-cedar 1c10000.ve2: supply ve not found, using dummy regulator
[   14.519484][  T184] sunxi-cedar 1c10000.ve2: sunxi:VE no or not support operating-points-v2 node
[   14.533175][  T184] reg-virt-consumer reg-virt-consumer.1.auto: DMA mask not set
[   14.541952][  T184] reg-virt-consumer reg-virt-consumer.2.auto: DMA mask not set
[   14.550587][  T184] reg-virt-consumer reg-virt-consumer.3.auto: DMA mask not set
[   14.559241][  T184] reg-virt-consumer reg-virt-consumer.4.auto: DMA mask not set
[   14.567912][  T184] reg-virt-consumer reg-virt-consumer.5.auto: DMA mask not set
[   14.576654][  T184] reg-virt-consumer reg-virt-consumer.6.auto: DMA mask not set
[   14.585462][  T184] reg-virt-consumer reg-virt-consumer.7.auto: DMA mask not set
[   14.594237][  T184] reg-virt-consumer reg-virt-consumer.8.auto: DMA mask not set
[   14.603129][  T184] reg-virt-consumer reg-virt-consumer.9.auto: DMA mask not set
[   14.611998][  T184] reg-virt-consumer reg-virt-consumer.10.auto: DMA mask not set
[   14.620799][  T184] reg-virt-consumer reg-virt-consumer.11.auto: DMA mask not set
[   14.629414][  T184] reg-virt-consumer reg-virt-consumer.12.auto: DMA mask not set
[   14.638020][  T184] reg-virt-consumer reg-virt-consumer.13.auto: DMA mask not set
[   14.646611][  T184] reg-virt-consumer reg-virt-consumer.14.auto: DMA mask not set
[   14.655215][  T184] reg-virt-consumer reg-virt-consumer.15.auto: DMA mask not set
[   14.663866][  T184] reg-virt-consumer reg-virt-consumer.16.auto: supply bldo1 not found, using dummy regulator
[   14.675256][  T184] reg-virt-consumer reg-virt-consumer.17.auto: supply bldo2 not found, using dummy regulator
[   14.686640][  T184] reg-virt-consumer reg-virt-consumer.18.auto: supply bldo3 not found, using dummy regulator
[   14.697990][  T184] reg-virt-consumer reg-virt-consumer.19.auto: supply bldo4 not found, using dummy regulator
[   14.709334][  T184] reg-virt-consumer reg-virt-consumer.20.auto: supply bldo5 not found, using dummy regulator
[   14.720692][  T184] reg-virt-consumer reg-virt-consumer.21.auto: supply cldo1 not found, using dummy regulator
[   14.732041][  T184] reg-virt-consumer reg-virt-consumer.22.auto: supply cldo2 not found, using dummy regulator
[   14.743409][  T184] reg-virt-consumer reg-virt-consumer.23.auto: supply cldo3 not found, using dummy regulator
[   14.754753][  T184] reg-virt-consumer reg-virt-consumer.24.auto: supply cldo4 not found, using dummy regulator
[   14.766146][  T184] reg-virt-consumer reg-virt-consumer.25.auto: supply cldo5 not found, using dummy regulator
[   14.777496][  T184] reg-virt-consumer reg-virt-consumer.26.auto: DMA mask not set
[   14.786234][  T184] reg-virt-consumer reg-virt-consumer.27.auto: DMA mask not set
[   14.794792][  T184] reg-virt-consumer reg-virt-consumer.28.auto: DMA mask not set
[   14.796543][  T317] husb311 13-004e: CC1: 0 - Open, CC2: 0 - Open
[   14.803345][  T184] reg-virt-consumer reg-virt-consumer.29.auto: DMA mask not set
[   14.810001][  T317] sunxi:sunxi_usbc:[INFO]: usb role switch set null -> null
[   14.818488][  T184] reg-virt-consumer reg-virt-consumer.30.auto: DMA mask not set
[   14.834989][  T184] reg-virt-consumer reg-virt-consumer.31.auto: DMA mask not set
[   14.843734][  T184] reg-virt-consumer reg-virt-consumer.32.auto: DMA mask not set
[   14.852624][  T184] reg-virt-consumer reg-virt-consumer.33.auto: DMA mask not set
[   14.861411][  T184] reg-virt-consumer reg-virt-consumer.34.auto: DMA mask not set
[   14.870127][  T184] reg-virt-consumer reg-virt-consumer.35.auto: DMA mask not set
[   14.878712][  T184] reg-virt-consumer reg-virt-consumer.36.auto: DMA mask not set
[   14.887398][  T184] reg-virt-consumer reg-virt-consumer.37.auto: DMA mask not set
[   14.896274][  T184] reg-virt-consumer reg-virt-consumer.38.auto: DMA mask not set
[   14.904995][  T184] reg-virt-consumer reg-virt-consumer.39.auto: DMA mask not set
[   14.913412][  T184] reg-virt-consumer reg-virt-consumer.39.auto: supply dc1sw1 not found, using dummy regulator
[   14.924909][  T184] reg-virt-consumer reg-virt-consumer.40.auto: DMA mask not set
[   14.933333][  T184] reg-virt-consumer reg-virt-consumer.40.auto: supply dc1sw2 not found, using dummy regulator
[   15.102309][    T1] init: Command 'mkdir /sys/kernel/tracing/instances/bootreceiver 0700 system system' action=bootreceiver.enable=1 && ro.product.cpu.abilist64=* (/system/etc/init/hw/init.rc:656) took 67ms and succeeded
[   15.126380][    T1] init: processing action (net.tcp_def_init_rwnd=*) from (/system/etc/init/hw/init.rc:1211)
[   15.137848][    T1] init: processing action (sys.init.perf_lsm_hooks=1) from (/system/etc/init/hw/init.rc:1222)
[   15.149422][    T1] init: processing action (security.perf_harden=1) from (/system/etc/init/hw/init.rc:1236)
[   15.160789][    T1] init: processing action (ro.debuggable=1) from (/system/etc/init/hw/init.rc:1271)
[   15.171367][    T1] init: processing action (init.svc.audioserver=running) from (/system/etc/init/audioserver.rc:38)
[   15.183165][    T1] init: service 'vendor.audio-hal' requested start, but it is already running (flags: 4)
[   15.193983][    T1] init: Command 'start vendor.audio-hal-4-0-msd' action=init.svc.audioserver=running (/system/etc/init/audioserver.rc:40) took 0ms and failed: service vendor.audio-hal-4-0-msd not found
[   15.214279][    T1] init: Command 'start audio_proxy_service' action=init.svc.audioserver=running (/system/etc/init/audioserver.rc:41) took 0ms and failed: service audio_proxy_service not found
[   15.233625][    T1] init: Command 'start vendor.audio-hal-2-0' action=init.svc.audioserver=running (/system/etc/init/audioserver.rc:43) took 0ms and failed: service vendor.audio-hal-2-0 not found
[   15.390477][  T104] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: have to disable cqe when send cmd with data!!!, CQHCI_CFG:2001020
[   15.404602][    C0] sunxi:sunxi_mmc_host-4023000.sdmmc:[INFO]: cmd with data done, restore cqe enable and halt:2001021,1,6,6
[   15.716746][  T337] [Awinic] [14-0059]aw_monitor_get_battery_status: get power supply failed
[   15.720789][  T536] read descriptors
[   15.726930][  T337] [Awinic] [14-0058]aw_monitor_get_battery_status: get power supply failed
[   15.736197][  T536] read strings
[   15.739980][  T337] [Awinic] aw87xxx_hal_monitor_time_get:get monitor time 3000
[   15.756692][  T317] husb311 13-004e: CC1: 3 - Rp-def, CC2: 3 - Rp-def
[   15.764332][  T317] sunxi:sunxi_usbc:[INFO]: usb role switch set null -> device
[   15.772840][  T317] sunxi:sunxi_usbc:[INFO]: auto set usb role [device]
[   15.780576][  T317] sunxi:sunxi_usbc:[INFO]: insmod_device_driver
[   15.780576][  T317]
[   15.790671][  T317] sunxi_usb_udc 4100000.udc-controller: supply udc not found, using dummy regulator
[   16.435316][  T317] sunxi:sunxi_usb_udc:[WARN]: sunxi_set_cur_vol_work()537 WARN: get power supply failed
[   16.522187][  T317] android_work: sent uevent USB_STATE=CONNECTED
[   16.687823][   T21] sunxi:sunxi_usb_udc:[WARN]: sunxi_set_cur_vol_work()537 WARN: get power supply failed
[   16.780216][  T317] sunxi:sunxi_usb_udc:[WARN]: sunxi_vbus_det_work()3728 WARN: get power supply failed
[   16.791713][  T317] android_work: sent uevent USB_STATE=DISCONNECTED
[   16.802842][  T317] android_work: sent uevent USB_STATE=CONNECTED
[   16.831884][  T317] android_work: sent uevent USB_STATE=CONFIGURED
[   18.341302][  T229] type=1400 audit(1748526573.840:54): avc: denied { open } for comm="getprop" path="/dev/__properties__/u:object_r:aac_drc_prop:s0" dev="tmpfs" ino=59 scontext=u:r:shell:s0 tcontext=u:object_r:aac_drc_prop:s0 tclass=file permissive=1
[   18.345749][  T608] audit: audit_backlog=65 > audit_backlog_limit=64
[   18.364522][  T362] audit: audit_backlog=65 > audit_backlog_limit=64
[   18.364531][  T362] audit: audit_lost=1 audit_rate_limit=0 audit_backlog_limit=64
[   18.364535][  T362] audit: backlog limit exceeded
[   18.366819][  T229] type=1400 audit(1748526573.840:55): avc: denied { getattr } for comm="getprop" path="/dev/__properties__/u:object_r:aac_drc_prop:s0" dev="tmpfs" ino=59 scontext=u:r:shell:s0 tcontext=u:object_r:aac_drc_prop:s0 tclass=file permissive=1
[   18.370523][  T344] healthd: battery none chg=
[   18.372078][  T344] healthd: battery none chg=
[   18.372476][  T344] healthd: battery none chg=
[   18.373547][  T608] audit: audit_lost=2 audit_rate_limit=0 audit_backlog_limit=64
[   18.381050][  T229] type=1400 audit(1748526573.840:56): avc: denied { map } for comm="getprop" path="/dev/__properties__/u:object_r:aac_drc_prop:s0" dev="tmpfs" ino=59 scontext=u:r:shell:s0 tcontext=u:object_r:aac_drc_prop:s0 tclass=file permissive=1
[   18.382334][  T344] healthd: battery none chg=
[   18.382911][  T344] healthd: battery none chg=
[   18.385306][  T344] healthd: battery none chg=
[   18.389152][  T608] audit: backlog limit exceeded
[   18.394629][  T229] type=1400 audit(1748526573.840:57): avc: denied { open } for comm="getprop" path="/dev/__properties__/u:object_r:ab_update_gki_prop:s0" dev="tmpfs" ino=61 scontext=u:r:shell:s0 tcontext=u:object_r:ab_update_gki_prop:s0 tclass=file permissive=1
[   18.419640][  T608] audit: audit_backlog=65 > audit_backlog_limit=64
[   18.424660][  T229] type=1400 audit(1748526573.840:58): avc: denied { getattr } for comm="getprop" path="/dev/__properties__/u:object_r:ab_update_gki_prop:s0" dev="tmpfs" ino=61 scontext=u:r:shell:s0 tcontext=u:object_r:ab_update_gki_prop:s0 tclass=file permissive=1
[   18.429511][  T608] audit: audit_lost=3 audit_rate_limit=0 audit_backlog_limit=64
[   18.434564][  T229] type=1400 audit(1748526573.840:59): avc: denied { map } for comm="getprop" path="/dev/__properties__/u:object_r:ab_update_gki_prop:s0" dev="tmpfs" ino=61 scontext=u:r:shell:s0 tcontext=u:object_r:ab_update_gki_prop:s0 tclass=file permissive=1
[   18.442787][  T608] audit: backlog limit exceeded
[   18.442899][  T608] audit: audit_backlog=65 > audit_backlog_limit=64
[   18.469395][  T229] type=1400 audit(1748526573.840:60): avc: denied { open } for comm="getprop" path="/dev/__properties__/u:object_r:adaptive_haptics_prop:s0" dev="tmpfs" ino=62 scontext=u:r:shell:s0 tcontext=u:object_r:adaptive_haptics_prop:s0 tclass=file permissive=1
[   18.620830][  T229] type=1400 audit(1748526573.840:61): avc: denied { getattr } for comm="getprop" path="/dev/__properties__/u:object_r:adaptive_haptics_prop:s0" dev="tmpfs" ino=62 scontext=u:r:shell:s0 tcontext=u:object_r:adaptive_haptics_prop:s0 tclass=file permissive=1
[   18.647877][  T229] type=1400 audit(1748526573.840:62): avc: denied { map } for comm="getprop" path="/dev/__properties__/u:object_r:adaptive_haptics_prop:s0" dev="tmpfs" ino=62 scontext=u:r:shell:s0 tcontext=u:object_r:adaptive_haptics_prop:s0 tclass=file permissive=1
[   18.674481][  T229] type=1400 audit(1748526573.840:63): avc: denied { open } for comm="getprop" path="/dev/__properties__/u:object_r:adbd_prop:s0" dev="tmpfs" ino=64 scontext=u:r:shell:s0 tcontext=u:object_r:adbd_prop:s0 tclass=file permissive=1
[   18.810467][  T344] healthd: battery none chg=
[   18.816778][  T344] healthd: battery none chg=
[   18.822488][  T344] healthd: battery none chg=
[   18.828438][  T344] healthd: battery none chg=
[   24.999219][  T441] sunxi:sound-ac101:[INFO]: 653 ac101_startup(): wait ac101 reset successfully, need 0x101/257
[   25.016396][  T441] sunxi-ac101 14-001a: sunxi:sound-ac101ac101 sysclk source don't pll, don't need config pll
[   25.172235][   T95] sunxi:sunxi_pd_test-soc@3000000:pd_pcie_test@0:[WARN]: runtime_suspend disable clock
[   25.182858][   T95] sunxi:sunxi_pd_test-soc@3000000:pd_usb2_test@0:[WARN]: runtime_suspend disable clock
[   25.193652][   T95] sunxi:sunxi_pd_test-soc@3000000:pd_de_sys_test@0:[WARN]: runtime_suspend disable clock
[   25.204584][   T95] sunxi:sunxi_pd_test-soc@3000000:pd_vo_test@0:[WARN]: runtime_suspend disable clock
[   25.215000][   T95] sunxi:sunxi_pd_test-soc@3000000:pd_vo1_test@0:[WARN]: runtime_suspend disable clock
[   28.553250][    T1] init: Sending signal 9 to service 'idmap2d' (pid 483) process group...
[   28.568012][    T1] libprocessgroup: Successfully killed process cgroup uid 1000 pid 483 in 5ms
[   28.578387][    T1] init: Control message: Processed ctl.stop for 'idmap2d' from pid: 450 (system_server)
[   28.589418][    T1] init: Service 'idmap2d' (pid 483) received signal 9
[   29.077868][  T615] read descriptors
[   29.081889][  T615] read strings
[   29.085581][  T615] read descriptors
[   29.089583][  T615] read strings
[   29.757067][  T344] healthd: battery none chg=
[   29.866566][    T1] init: starting service 'vendor.wifi_hal_legacy'...
[   29.877917][    T1] init: Control message: Processed ctl.interface_start for 'android.hardware.wifi@1.0::IWifi/default' from pid: 215 (/system/bin/hwservicemanager)
[   29.895306][    T1] init: service 'vendor.wifi_hal_legacy' requested start, but it is already running (flags: 134)
[   29.907141][    T1] init: Control message: Processed ctl.interface_start for 'android.hardware.wifi@1.0::IWifi/default' from pid: 215 (/system/bin/hwservicemanager)
[   29.997174][  T344] healthd: battery none chg=
[   30.014342][ T1002] >>> rwnx_mod_init()
[   30.018712][ T1002] rwnx 20240730-005-6.4.3.0 - - 241c091M (master)
[   30.025735][ T1002] Driver Release Tag: aic-rwnx-compatible(sdio)-20240730-005
[   30.033872][ T1002] aicbsp: aicbsp_set_subsys, subsys: AIC_WIFI, state to: 1
[   30.041778][ T1002] aicbsp: aicbsp_set_subsys, power state change to 1 dure to AIC_WIFI
[   30.050806][ T1002] aicbsp: aicbsp_platform_power_on
[   30.060502][ T1002] sunxi-rfkill soc@3000000:rfkill: bus_index: 1
[   30.067930][ T1002] aicbsp: aicbsp_platform_power_on disable MMC_CAP_UHS_DDR50 for host 00000000b1358c3e
[   30.078886][  T344] healthd: battery none chg=
[   30.089841][ T1002] sunxi-rfkill soc@3000000:rfkill: wlan power on success
[   30.147563][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.164459][  T310] dwmac-sunxi 4500000.ethernet eth0: PHY [stmmac-0:01] driver [Generic PHY] (irq=POLL)
[   30.175596][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.176352][  T310] dwmac-sunxi 4500000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   30.201056][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[   30.208168][  T310] dwmac4: Master AXI performs fixed burst length
[   30.211245][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 52, RTO !!
[   30.217317][  T310] dwmac-sunxi 4500000.ethernet eth0: No Safety Features support found
[   30.226572][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.245548][  T310] dwmac-sunxi 4500000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[   30.252559][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.260130][  T344] healthd: battery none chg=
[   30.275047][  T310] dwmac-sunxi 4500000.ethernet eth0: registered PTP clock
[   30.286773][  T344] healthd: battery none chg=
[   30.287964][    C0] sunxi:sunxi_mmc_host-4021000.sdmmc:[ERR]: smc 1 p1 err, cmd 11, RE !!
[   30.291883][  T310] dwmac-sunxi 4500000.ethernet eth0: configuring for phy/rgmii link mode
[   30.292309][  T344] healthd: battery none chg=
[   30.292438][  T344] healthd: battery none chg=
[   30.292564][  T344] healthd: battery none chg=
[   30.292676][  T344] healthd: battery none chg=
[   30.292784][  T344] healthd: battery none chg=
[   30.300905][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[   30.303531][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.310683][  T310] 8021q: adding VLAN 0 to HW filter on device eth0
[   30.327762][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.413655][  T160] mmc1: queuing unknown CIS tuple 0x10 [07 00 11 00 8e] (5 bytes)
[   30.427681][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[   30.442190][  T160] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 4 timing LEGACY(SDR12) dt B
[   30.456687][  T160] mmc1: queuing unknown CIS tuple 0x10 [07 00 31 00 32] (5 bytes)
[   30.466396][  T160] mmc1: new SDIO card at address 96ec
[   30.489266][ T1002] aicbsp: aicbsp_sdio_probe:2
[   30.494361][ T1002] aicbsp: aicbsp_sdio_probe:2, matched chip: aic8800d
[   30.501775][ T1002] aicbsp: aicbsp_sdio_probe after replace:1
[   30.508193][ T1002] aicbsp: aicbsp_sdio_probe host max clock frequecy: 208000000
[   30.516459][ T1002] aicbsp: aicwf_sdio_reg_init
[   30.521609][ T1002] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 70000000Hz bm PP pm ON vdd 21 width 4 timing LEGACY(SDR12) dt B
[   30.535990][ T1002] aicbsp: Set SDIO Clock 66 MHz
[   30.543179][ T1002] aicbsp: aicbsp_8800d_fw_init, rev id: 0x7, subrev id: 0x20
[   30.554646][ T1002] rwnx_request_firmware, name: fw_patch_table_u03.bin
[   30.562083][ T1002] aicbt_patch_info_unpack bt patch version: - Jun 24 2024 21:01:47 - git 0bcba10
[   30.572099][ T1002] aicbt_init no patch info found in bt fw
[   30.578885][ T1002] rwnx_request_firmware, name: fw_adid_u03.bin
[   30.587722][ T1002] rwnx_request_firmware, name: fw_patch_u03.bin
[   30.610188][ T1002] aicbt_patch_table_load bt uart baud: 1500000, flowctrl: 1, lpm_enable: 1, tx_pwr: 24608, bt mode:255.
[   30.655276][ T1002] rwnx_request_firmware, name: fmacfw.bin
[   30.731715][ T1002] rwnx_request_firmware, name: fmacfw_patch.bin
[   30.748002][ T1002] aicbsp: crypto data BBAD831C477E445AC3A462102C50D125
[   30.755693][ T1002] aicbsp: verify data 52C1C402DC4E526F51C01D59442A8008
[   30.764406][ T1002] aicsdio: aicwf_sdio_probe:1
[   30.769617][ T1002] aicsdio: aicwf_sdio_reg_init
[   30.775410][ T1002] sunxi:sunxi_mmc_host-4021000.sdmmc:[INFO]: sdc set ios:clk 70000000Hz bm PP pm ON vdd 21 width 4 timing LEGACY(SDR12) dt B
[   30.790214][ T1002] aicsdio: Set SDIO Clock 66 MHz
[   30.796167][    C7] aicbsp: err:<aicwf_sdio_bus_pwrctl,1257>: bus down
[   30.806825][ T1002] aicbsp: aicbsp_resv_mem_alloc_skb, alloc resv_mem_txdata succuss, id: 0, size: 98304
[   30.818886][ T1002] >>> rwnx_platform_init()
[   30.824712][ T1002] >>> rwnx_cfg80211_init()
[   30.829988][ T1002] rwnx_cfg80211_init sizeof(struct rwnx_hw):47616
[   30.839359][ T1002] >>> rwnx_init_aic()
[   30.843701][ T1002] >>> rwnx_cmd_mgr_init()
[   30.852307][ T1002] tcp_ack_init
[   30.856650][ T1002] >>> rwnx_send_set_stack_start_req()
[   30.865250][ T1002] is 5g support = 1, vendor_info = 0x21
[   30.871750][ T1002] Firmware Version: di Nov 14 2024 17:34:41 - g9aed4718
[   30.871769][ T1002] >>> rwnx_platform_on()
[   30.884313][ T1002] >>> rwnx_plat_fmac_load()
[   30.889578][ T1002] userconfig file path:aic_userconfig.txt
[   30.897883][ T1002] rwnx_plat_userconfig_parsing, enable = 1
[   30.908928][ T1002] rwnx_plat_userconfig_parsing, dsss = 10
[   30.915284][ T1002] rwnx_plat_userconfig_parsing, ofdmlowrate_2g4 = 11
[   30.922595][ T1002] rwnx_plat_userconfig_parsing, ofdm64qam_2g4 = 10
[   30.930072][ T1002] rwnx_plat_userconfig_parsing, ofdm256qam_2g4 = 10
[   30.937650][ T1002] rwnx_plat_userconfig_parsing, ofdm1024qam_2g4 = 9
[   30.945329][ T1002] rwnx_plat_userconfig_parsing, ofdmlowrate_5g = 11
[   30.953537][ T1002] rwnx_plat_userconfig_parsing, ofdm64qam_5g = 10
[   30.961230][ T1002] rwnx_plat_userconfig_parsing, ofdm256qam_5g = 10
[   30.968681][ T1002] rwnx_plat_userconfig_parsing, ofdm1024qam_5g = 9
[   30.977630][ T1002] rwnx_plat_userconfig_parsing, ofst_enable = 1
[   30.984742][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_1_4 = -5
[   30.992222][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_5_9 = -2
[   31.002539][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_10_13 = -2
[   31.010779][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_36_64 = -5
[   31.018437][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_100_120 = -6
[   31.026217][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_122_140 = -6
[   31.033983][ T1002] rwnx_plat_userconfig_parsing, ofst_chan_142_165 = 4
[   31.041585][ T1002] >>> rwnx_send_txpwr_idx_req()
[   31.048236][ T1002] >>> rwnx_send_txpwr_ofst_req()
[   31.054049][ T1002] >>> rwnx_send_rf_calib_req()
[   31.390545][ T1002] get macaddr: 94:ff:6e:cd:1f:cc
[   31.396015][ T1002] >>> rwnx_send_reset()
[   31.401929][ T1002] >>> rwnx_send_version_req()
[   31.407285][ T1002] >>> rwnx_set_vers()
[   31.411583][ T1002] >>> rwnx_send_me_config_req()
[   31.416835][ T1002] ieee80211 phy0: HT supp 1, VHT supp 1, HE supp 1
[   31.424666][ T1002] >>> rwnx_send_me_chan_config_req()
[   31.431003][ T1002] >>> rwnx_send_me_chan_config_req()
[   31.437213][ T1002] >>> rwnx_dbgfs_register()
[   31.442192][ T1002] rwnx_interface_add: wlan%d, 2, 10
[   31.442226][ T1002] interface add:94 ff 6e cd 1f cc
[   31.460241][ T1002] ieee80211 phy0: New interface create wlan0
[   31.500677][ T1002] >>> rwnx_open()
[   31.504653][ T1002] >>> rwnx_send_me_set_lp_level()
[   31.510152][ T1002] rwnx_send_me_set_lp_level 1 1
[   31.518129][ T1002] >>> rwnx_send_start()
[   31.524513][ T1002] >>> rwnx_send_coex_req()
[   31.529878][ T1002] rwnx_open rwnx_vif->drv_flags:4
[   31.535501][ T1002] >>> rwnx_send_add_if()
[   31.548562][  T229] type=1107 audit(1748526587.044:313): uid=0 auid=4294967295 ses=4294967295 subj=u:r:init:s0 msg='avc: denied { set } for property=vendor.wlan.firmware.version pid=1002 uid=1010 gid=1010 scontext=u:r:hal_wifi_default:s0 tcontext=u:object_r:vendor_default_prop:s0 tclass=property_service permissive=1'
[   31.653165][    T1] init: starting service 'wpa_supplicant'...
[   31.660385][    T1] init: Created socket '/dev/socket/wpa_wlan0', mode 660, user 1010, group 1010
[   31.749168][ T1190] capability: warning: `wpa_supplicant' uses 32-bit capabilities (legacy support in use)
[   31.920048][ T1190] rwnx_virtual_interface_add: 10, p2p-dev-wlan0
[   31.926970][ T1190] rwnx_virtual_interface_add, ifname=p2p-dev-wlan0, wdev=00000000670e1c4a, vif_idx=1
[   31.937393][ T1190] p2p dev addr=94 ff 6e cd 1f cd
[   31.945929][ T1190] P2P interface started
[   32.009541][ T1190] IOCTL PRIVATE
[   32.013322][ T1190] android_priv_cmd: Android private cmd "COUNTRY CN" on wlan0
[   32.021779][ T1190] wrong cmd:(null) in handle_private_cmd
[   32.045484][ T1190] IOCTL PRIVATE
[   32.049702][ T1190] android_priv_cmd: Android private cmd "SETSUSPENDMODE 1" on wlan0
[   32.058898][ T1190] >>> rwnx_send_me_set_lp_level()
[   32.064553][ T1190] rwnx_send_me_set_lp_level 1 0
[   32.067369][  T229] type=1400 audit(1748526587.564:314): avc: granted { read } for comm="rkstack.process" name="psched" dev="proc" ino=4026531986 scontext=u:r:network_stack:s0 tcontext=u:object_r:proc_net:s0 tclass=file
[   32.072791][ T1190] set suspend mode 1
[   32.093242][  T229] type=1400 audit(1748526587.564:315): avc: granted { read open } for comm="rkstack.process" path="/proc/1204/net/psched" dev="proc" ino=4026531986 scontext=u:r:network_stack:s0 tcontext=u:object_r:proc_net:s0 tclass=file
[   32.120002][  T229] type=1400 audit(1748526587.564:316): avc: granted { getattr } for comm="rkstack.process" path="/proc/1204/net/psched" dev="proc" ino=4026531986 scontext=u:r:network_stack:s0 tcontext=u:object_r:proc_net:s0 tclass=file
[   33.059997][  T338] aicbt_set_power: start_block=1
[   33.065431][  T338] aicbsp: aicbsp_set_subsys, subsys: AIC_BLUETOOTH, state to: 0
[   33.074320][  T338] aicbsp: aicbsp_set_subsys, power state no need to change, current: 1
[   33.083431][  T338] aicbt_set_power: end_block=1
[   33.088950][  T338] aicbt_set_power: start_block=0
[   33.094393][  T338] aicbsp: aicbsp_set_subsys, subsys: AIC_BLUETOOTH, state to: 1
[   33.102957][  T338] aicbsp: aicbsp_set_subsys, power state no need to change, current: 1
[   33.112201][  T338] aicbt_set_power: end_block=0
[   33.127845][ T1002] >>> rwnx_close()
[   33.131914][ T1002] aicwf_sdio mmc1:96ec:1 wlan0: CLOSE
[   33.137906][    T8] >>> rwnx_cfg80211_del_key()
[   33.138859][ T1002] >>> rwnx_send_remove_if()
[   33.142993][    T8] >>> rwnx_send_key_del()
[   33.145537][    T8] >>> rwnx_cfg80211_del_key()
[   33.148618][ T1002] >>> rwnx_send_msg1()
[   33.152573][    T8] >>> rwnx_send_key_del()
[   33.153485][    T8] >>> rwnx_cfg80211_del_key()
[   33.158626][ T1002] >>> rwnx_send_coex_req()
[   33.163220][    T8] >>> rwnx_send_key_del()
[   33.167525][ T1002] >>> rwnx_send_reset()
[   33.172234][    T8] >>> rwnx_cfg80211_del_key()
[   33.178309][ T1002] >>> rwnx_send_me_config_req()
[   33.181730][    T8] >>> rwnx_send_key_del()
[   33.185845][ T1002] ieee80211 phy0: HT supp 1, VHT supp 1, HE supp 1
[   33.186282][ T1002] >>> rwnx_send_me_chan_config_req()
[   33.191582][    T8] >>> rwnx_cfg80211_del_key()
[   33.196765][ T1002] rwnx_close rwnx_vif->drv_flags:0
[   33.201120][    T8] >>> rwnx_send_key_del()
[   33.229682][    T8] >>> rwnx_cfg80211_del_key()
[   33.234761][    T8] >>> rwnx_send_key_del()
[   33.240302][ T1002] >>> rwnx_open()
[   33.244215][ T1002] >>> rwnx_send_me_set_lp_level()
[   33.249663][ T1002] rwnx_send_me_set_lp_level 1 1
[   33.255483][ T1002] >>> rwnx_send_start()
[   33.260675][ T1002] >>> rwnx_send_coex_req()
[   33.265850][ T1002] rwnx_open rwnx_vif->drv_flags:4
[   33.271416][ T1002] >>> rwnx_send_add_if()
[   33.276561][  T160] >>> rwnx_send_me_chan_config_req()
[   33.282716][  T160] >>> rwnx_send_me_chan_config_req()
[   33.320559][  T338] [BT_LPM] bluesleep_get_uart_port: bluesleep_get_uart_port get uart_port from blusleep_uart_dev: 2501000.uart, port irq: 427
[   33.368684][ T1190] IOCTL PRIVATE
[   33.372412][ T1190] android_priv_cmd: Android private cmd "BTCOEXSCAN-STOP" on wlan0
[   33.381074][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.387730][ T1190] IOCTL PRIVATE
[   33.391588][ T1190] android_priv_cmd: Android private cmd "RXFILTER-STOP" on wlan0
[   33.400173][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.406901][ T1190] IOCTL PRIVATE
[   33.410622][ T1190] android_priv_cmd: Android private cmd "RXFILTER-ADD 2" on wlan0
[   33.419192][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.425748][ T1190] IOCTL PRIVATE
[   33.429483][ T1190] android_priv_cmd: Android private cmd "RXFILTER-START" on wlan0
[   33.438041][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.444459][ T1190] IOCTL PRIVATE
[   33.448179][ T1190] android_priv_cmd: Android private cmd "RXFILTER-STOP" on wlan0
[   33.456642][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.463066][ T1190] IOCTL PRIVATE
[   33.466800][ T1190] android_priv_cmd: Android private cmd "RXFILTER-ADD 3" on wlan0
[   33.475373][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.481777][ T1190] IOCTL PRIVATE
[   33.485498][ T1190] android_priv_cmd: Android private cmd "RXFILTER-START" on wlan0
[   33.494062][ T1190] wrong cmd:(null) in handle_private_cmd
[   33.500593][ T1190] IOCTL PRIVATE
[   33.504314][ T1190] android_priv_cmd: Android private cmd "SETSUSPENDMODE 1" on wlan0
[   33.513079][ T1190] >>> rwnx_send_me_set_lp_level()
[   33.518526][ T1190] rwnx_send_me_set_lp_level 1 0
[   33.524545][ T1190] set suspend mode 1
[   33.579613][ T1190] IOCTL PRIVATE
[   33.583365][ T1190] android_priv_cmd: Android private cmd "SETSUSPENDMODE 0" on wlan0
[   33.592132][ T1190] >>> rwnx_send_me_set_lp_level()
[   33.597578][ T1190] rwnx_send_me_set_lp_level 1 1
[   33.603637][ T1190] set suspend mode 0
[   34.132751][    T1] init: starting service 'idmap2d'...
[   34.142467][    T1] init: Control message: Processed ctl.start for 'idmap2d' from pid: 450 (system_server)
[   34.348171][    C7] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   35.326899][    T1] init: processing action (sys.boot_completed=1) from (/system/etc/init/hw/init.rc:1193)
[   35.339953][    T1] init: starting service 'exec 19 (/bin/rm -rf /data/per_boot)'...
[   35.354540][    T1] init: SVC_EXEC service 'exec 19 (/bin/rm -rf /data/per_boot)' pid 1584 (uid 1000 gid 1000+0 context default) started; waiting...
[   35.370880][    T1] init: Service 'exec 19 (/bin/rm -rf /data/per_boot)' (pid 1584) exited with status 0 waiting took 0.018000 seconds
[   35.374592][  T500] >>> rwnx_cfg80211_scan()
[   35.384489][    C7] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   35.384773][    T1] init: Sending signal 9 to service 'exec 19 (/bin/rm -rf /data/per_boot)' (pid 1584) process group...
[   35.389347][  T500] >>> rwnx_send_scanu_req()
[   35.398294][    T1] libprocessgroup: Successfully killed process cgroup uid 1000 pid 1584 in 0ms
[   35.426295][    T1] init: processing action (sys.boot_completed=1) from (/vendor/etc/init/hw/init.sun60iw2p1.rc:138)
[   35.438798][    T1] init: Command 'insmod /vendor/lib/modules/kheaders.ko' action=sys.boot_completed=1 (/vendor/etc/init/hw/init.sun60iw2p1.rc:139) took 0ms and failed: open("/vendor/lib/modules/kheaders.ko") failed: No such file or directory
[   35.754224][  T184] init (184): drop_caches: 3
[   35.754822][  T344] healthd: battery none chg=
[   35.788907][    T1] zram0: detected capacity change from 0 to 9060872
[   35.846457][    T1] mkswap: Swapspace size: 4530432k, UUID=aa727031-8a5d-4aba-ae20-95608634a812
[   35.858906][    T1] Adding 4530432k swap on /dev/block/zram0.  Priority:-2 extents:1 across:4530432k SS
[   35.893905][  T229] type=1400 audit(1748526591.392:317): avc: denied { entrypoint } for comm="init" path="/system/bin/fix_traceing" dev="dm-0" ino=8778258 scontext=u:r:shell:s0 tcontext=u:object_r:system_file:s0 tclass=file permissive=1
[   35.955090][  T229] type=1400 audit(1748526591.452:318): avc: denied { dac_read_search } for comm="runin.sh" capability=2 scontext=u:r:shell:s0 tcontext=u:r:shell:s0 tclass=capability permissive=1
[   35.989174][  T229] type=1400 audit(1748526591.484:319): avc: denied { search } for comm="treadahead" name="/" dev="mmcblk0p22" ino=2 scontext=u:r:vendor_init:s0 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1
[   35.989614][ T1658] treadahead: /treadahead/readahead_file_offset not exist;
[   36.021142][ T1658] treadahead: go to read trace
[   36.226833][  T344] healthd: battery none chg=
[   36.233557][  T344] healthd: battery none chg=
[   36.242210][  T184] get ctp_power is fail, -22
[   36.247556][  T184] get ctp_power_ldo_vol is fail, -22
[   36.255059][  T184] sunxi_ctp_startup: ctp_power_io is invalid.
[   36.261894][  T184] get ctp_gesture_wakeup fail, no gesture wakeup
[   36.270165][  T184] i2c 2-0040: supply ctp not found, using dummy regulator
[   36.287139][  T344] healthd: battery none chg=
[   36.318690][  T184] can not get fw from file gsl_firmware/gsl1680_7inch.bin
[   36.328547][  T184] input: gslX680 as /devices/platform/soc@3000000/2512000.twi/i2c-2/2-0040/input/input3
[   36.328604][  T344] healthd: battery none chg=
[   36.344913][  T344] healthd: battery none chg=
[   36.346238][  T184] ERROR! get hall_para failed, func:switch_init, line:236
[   36.350540][  T344] healthd: battery none chg=
[   36.363209][  T344] healthd: battery none chg=
[   36.363377][  T229] type=1400 audit(1748526591.860:320): avc: denied { read } for comm="InputReader" name="u:object_r:vendor_awdisplayoutput_prop:s0" dev="tmpfs" ino=301 scontext=u:r:system_server:s0 tcontext=u:object_r:vendor_awdisplayoutput_prop:s0 tclass=file permissive=1
[   36.371924][  T344] healthd: battery none chg=
[   36.397127][  T229] type=1400 audit(1748526591.860:321): avc: denied { open } for comm="InputReader" path="/dev/__properties__/u:object_r:vendor_awdisplayoutput_prop:s0" dev="tmpfs" ino=301 scontext=u:r:system_server:s0 tcontext=u:object_r:vendor_awdisplayoutput_prop:s0 tclass=file permissive=1
[   36.400495][    C7] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   36.404502][  T344] healthd: battery none chg=
[   36.431874][  T229] type=1400 audit(1748526591.860:322): avc: denied { getattr } for comm="InputReader" path="/dev/__properties__/u:object_r:vendor_awdisplayoutput_prop:s0" dev="tmpfs" ino=301 scontext=u:r:system_server:s0 tcontext=u:object_r:vendor_awdisplayoutput_prop:s0 tclass=file permissive=1
[   36.553997][ T1104] >>> rwnx_rx_scanu_start_cfm()
[   36.575575][  T229] type=1400 audit(1748526592.072:324): avc: denied { write } for comm="HwBinder:346_2" name="property_service" dev="tmpfs" ino=335 scontext=u:r:mediacodec:s0 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=1
[   36.600890][  T229] type=1400 audit(1748526592.072:325): avc: denied { connectto } for comm="HwBinder:346_2" path="/dev/socket/property_service" scontext=u:r:mediacodec:s0 tcontext=u:r:init:s0 tclass=unix_stream_socket permissive=1
[   36.624583][  T229] type=1107 audit(1748526592.072:326): uid=0 auid=4294967295 ses=4294967295 subj=u:r:init:s0 msg='avc: denied { set } for property=vendor.display.codec2_aisr_process pid=346 uid=1046 gid=1006 scontext=u:r:mediacodec:s0 tcontext=u:object_r:vendor_default_prop:s0 tclass=property_service permissive=1'
[   36.849265][ T1450] [BT_LPM] bluesleep_tx_allow_sleep: Tx has been idle
[   36.849265][ T1450]
[   36.964510][ T1919] audit_log_lost: 503 callbacks suppressed
[   36.964516][ T1919] audit: audit_lost=172 audit_rate_limit=5 audit_backlog_limit=64
[   36.967844][  T229] type=1400 audit(1748526592.460:327): avc: denied { setattr } for comm="chmod" name="/" dev="tracefs" ino=1 scontext=u:r:shell:s0 tcontext=u:object_r:debugfs_tracing_debug:s0 tclass=dir permissive=1
[   36.971757][ T1919] audit: rate limit exceeded
[   37.158118][ T1309] BOOTEVENT:     37158.117399: OFF
[   37.369794][  T338] [BT_LPM] bluesleep_outgoing_data: tx was sleeping, wakeup it
[   37.417090][  T229] type=1400 audit(1748526592.916:330): avc: denied { read } for comm="binder:254_2" name="event_count" dev="sysfs" ino=46443 scontext=u:r:system_suspend:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[   37.447404][  T229] type=1400 audit(1748526592.916:331): avc: denied { open } for comm="binder:254_2" path="/sys/devices/platform/soc@3000000/7083000.twi/i2c-13/13-004e/wakeup/wakeup12/event_count" dev="sysfs" ino=46443 scontext=u:r:system_suspend:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[   37.477822][  T229] type=1400 audit(1748526592.916:332): avc: denied { getattr } for comm="binder:254_2" path="/sys/devices/platform/soc@3000000/7083000.twi/i2c-13/13-004e/wakeup/wakeup12/event_count" dev="sysfs" ino=46443 scontext=u:r:system_suspend:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[   37.636006][  T229] type=1400 audit(1748526593.132:333): avc: denied { search } for comm="android.hardwar" name="1" dev="proc" ino=30 scontext=u:r:hal_power_default:s0 tcontext=u:r:init:s0 tclass=dir permissive=1
[   37.657750][  T229] type=1400 audit(1748526593.132:334): avc: denied { read } for comm="android.hardwar" name="cmdline" dev="proc" ino=23769 scontext=u:r:hal_power_default:s0 tcontext=u:r:init:s0 tclass=file permissive=1
[   37.868174][    C1] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   38.027515][ T1658] treadahead: getpartitiondev /system= 254:0
[   38.036843][ T1658] treadahead: getpartitiondev /product= 254:2
[   38.045477][ T1658] treadahead: getpartitiondev /vendor= 254:1
[   38.053325][ T1658] treadahead: getpartitiondev /vendor_dlkm= 254:3
[   38.092516][ T1658] audit: audit_lost=277 audit_rate_limit=5 audit_backlog_limit=64
[   38.101804][ T1658] audit: rate limit exceeded
[   38.108677][ T1658] treadahead:  begain fgets_alloc ======== 254:0   254:2
[   38.892175][    C1] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   39.916177][    C1] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   40.401219][ T1450] [BT_LPM] bluesleep_tx_allow_sleep: Tx has been idle
[   40.401219][ T1450]
[   41.420174][    C5] [BT_LPM] bluesleep_rx_timer_expire: bluesleep_rx_timer_expire
[   41.435573][   T79] [BT_LPM] bluesleep_sleep_work: going to sleep...
[   42.390131][ T1658] treadahead: treadahead read-trace over 327701  345525
[   42.505827][    T1] init: starting service 'vendor.drm-clearkey-service'...
[   42.518906][    T1] init: Control message: Processed ctl.interface_start for 'aidl/android.hardware.drm.IDrmFactory/clearkey' from pid: 214 (/system/bin/servicemanager)
[   42.565481][    T1] init: starting service 'vendor.drm-widevine-hal'...
[   42.579417][    T1] init: Control message: Processed ctl.interface_start for 'aidl/android.hardware.drm.IDrmFactory/widevine' from pid: 214 (/system/bin/servicemanager)
[   42.733367][ T1658] treadahead: treadahead write trace end
[   42.990365][    T1] init: processing action (persist.service.dragon.start=1) from (/system/etc/init/dragonservice.rc:1)
[   43.004493][    T1] init: starting service 'dragonservice'...
[   43.104392][    T1] init: processing action (persist.service.dragon.start=0) from (/system/etc/init/dragonservice.rc:4)
[   43.116584][    T1] init: Sending signal 9 to service 'dragonservice' (pid 2469) process group...
[   43.132631][    T1] libprocessgroup: Successfully killed process cgroup uid 0 pid 2469 in 5ms
[   43.143970][    T1] init: Service 'dragonservice' (pid 2469) received signal 9
[   51.168801][ T1658] treadahead: read trace end
[   51.476065][ T1658] treadahead: begin match traceinfo
[   51.483300][  T229] type=1400 audit(1748526606.980:443): avc: denied { search } for comm="treadahead" name="/" dev="mmcblk0p22" ino=2 scontext=u:r:vendor_init:s0 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1
[   51.505850][  T229] type=1400 audit(1748526606.980:444): avc: denied { write } for comm="treadahead" name="/" dev="mmcblk0p22" ino=2 scontext=u:r:vendor_init:s0 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1
[   51.529592][  T229] type=1400 audit(1748526606.980:445): avc: denied { add_name } for comm="treadahead" name="readahead_file_offset" scontext=u:r:vendor_init:s0 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1
[   51.551336][  T229] type=1400 audit(1748526606.980:446): avc: denied { create } for comm="treadahead" name="readahead_file_offset" scontext=u:r:vendor_init:s0 tcontext=u:object_r:unlabeled:s0 tclass=file permissive=1
[   51.573015][  T229] type=1400 audit(1748526606.980:447): avc: denied { read write open } for comm="treadahead" path="/treadahead/readahead_file_offset" dev="mmcblk0p22" ino=15 scontext=u:r:vendor_init:s0 tcontext=u:object_r:unlabeled:s0 tclass=file permissive=1
[   51.602351][    T1] init: Service 'vendor.drm-clearkey-service' (pid 2434) exited with status 0 oneshot service took 9.086000 seconds in background
[   51.617399][    T1] init: Sending signal 9 to service 'vendor.drm-clearkey-service' (pid 2434) process group...
[   51.629259][    T1] libprocessgroup: Successfully killed process cgroup uid 1013 pid 2434 in 0ms
[   51.652328][    T1] init: Service 'vendor.drm-widevine-hal' (pid 2437) exited with status 0 oneshot service took 9.077000 seconds in background
[   51.667180][    T1] init: Sending signal 9 to service 'vendor.drm-widevine-hal' (pid 2437) process group...
[   51.678647][    T1] libprocessgroup: Successfully killed process cgroup uid 1013 pid 2437 in 0ms
[   51.948662][ T1658] audit: audit_lost=282 audit_rate_limit=5 audit_backlog_limit=64
[   51.957280][ T1658] audit: rate limit exceeded
[   52.019280][ T1658] treadahead: trace readahead complete
[   52.019840][    T1] init: processing action (persist.device_config.runtime_native_boot.iorap_perfetto_enable=true && persist.sys.without.treadahead=1 && ro.iorapd.enable=true) from (/system/etc/init/iorapd.rc:34)
[   52.047472][    T1] init: starting service 'iorapd'...
[   52.060493][    T1] init: Service 'treadahead_trace' (pid 1658) exited with status 0 oneshot service took 16.128000 seconds in background
[   52.074782][    T1] init: Sending signal 9 to service 'treadahead_trace' (pid 1658) process group...
[   55.383165][  T500] >>> rwnx_cfg80211_scan()
[   55.388008][  T500] >>> rwnx_send_scanu_req()
[   56.542667][ T1104] >>> rwnx_rx_scanu_start_cfm()

console:/ $
console:/ $
console:/ $

#10 Re: 全志 SOC » t113 xplayerdemo抖动,显示缓冲区挂掉的问题 » 2025-05-10 21:32:44

用tplayerdemo测试看看,估计效果也差不多,可能是CPU占用率高的时候丢帧了。

#11 Re: 全志 SOC » 哪位成功配置了MIPI ILI9881的吗? » 2025-05-10 18:33:18

memory 说:
lanlanzhilian 说:

现在好多屏幕都是直接29 11就显示了

屏组装厂固化参数的才行,大部分厂家都没固化。

是不显示吗?找显示屏厂商要初始化参数。

#13 Re: 全志 SOC » 【视频分享】制作荔枝派Zero开发板(全志V3s) TF/SD卡启动盘 » 2025-05-04 17:53:23

ryanpham 说:

https://whycan.com/files/members/16486/Untitled.jpegHello I create the image as guideline from but I met a problem as image bellow:
Could you please help me

(V3s/V3x/S3/S3L/R11通吃)小智V3x开发板smallwitpi lite u-boot/linux/buildroot测试
https://whycan.com/t_7248.html

#14 Re: 全志 SOC » 求全志T113-S3寄存器地址等底资料 » 2025-04-24 10:54:30

通过网盘分享的文件:T113_Tina5.0 V1.2
链接: https://pan.baidu.com/s/1vhUfWqklOFop_GJs_fegmw?pwd=TN12 提取码: TN12


T113-S3/T113-S4/T113-i 全整合在一起了

#16 Re: 全志 SOC » 求助F1C100S裸机连接J-LINK后如何单步调试 » 2025-03-27 11:06:42

@kingfa025
可以,KEIL工程配置可以设置初始化脚本文件,这个脚本可以配置DDR控制器,配好就能访问整块DDR了,前提是JTAG能正常访问ARM9 CORE

#18 Re: 全志 SOC » 45块顺丰包邮买到的10.1寸保资LCD价签F1C200S 值不值 » 2025-03-22 16:58:59

li6848 说:

只能看到#210楼。新的回复都看不到……是灌水评论被管理删了吗?

是的,都是一些垃圾帖。

#19 Re: 全志 SOC » 新人求教!关于T113-S3 SMHC1能否连接到SD卡的问题 » 2025-03-22 09:41:07

SDC1可以接TF卡,改下board.dts里面的驱动即可,但是SDC1不能引导系统。


另一种方案:
设计一片 SD NAND + JTAG(全志soc) 转接板    [切记切记0.8mm厚度]
https://whycan.com/t_2025.html

#22 Re: 全志 SOC » 如何破解一块串口屏当开发板 » 2025-02-20 09:17:54

yin 说:

请教一个问题,我看串口屏用的是PE9 PE10作为I2C引脚,但是实际引脚复用里面这两个引脚是没有I2C复用功能的,你用的是软件I2C吗?谢谢,在这个屏上刷了linux,但是发现触摸屏用的I2C总线的引脚不具有硬件I2C复用功能。

用逻辑分析仪抓包,用io程序回放即可。
linux也有一个gpio的i2c驱动。

#23 Re: 全志 SOC » XFEL已支持spi nand flash烧写 » 2025-02-17 10:54:04

KoGu 说:

请问一下,我在linux下clone了源码,然后我添加里的自己板子上的flash型号,我要怎么编译出win10下使用的exe呢?

用 MSVC2017 编译 XFEL 项目
https://whycan.com/t_6660.html

#24 Re: GM8135s/GM8136s/GM8135/GM8136/GM8125/GM8126 » GM8135s入坑记录 » 2025-02-05 10:43:48

舟渡 说:

不知道大佬们是否能看到,我这刚拆了一个1516年的安防网络摄像头,不知道怎么烧录,求大佬帮助

https://item.taobao.com/item.htm?id=710573620450

配套④编程器+SOP8测试线+200mil烧录座

#26 Re: 全志 SOC » 45块顺丰包邮买到的10.1寸保资LCD价签F1C200S 值不值 » 2024-12-26 20:04:38

18578292200 说:

新回复的内容好像看不到了?

没有营养的跟帖不显示

#27 Re: 全志 SOC » 初学者小白的第一点疑问 » 2024-12-16 11:21:54

XBOOT只要能编译出固件,用 sunxi-fel 烧录到SPI FLASH就可以运行了。

细节问题XBOOT已经处理好了。

#28 Re: 全志 SOC » 初学者小白的第一点疑问 » 2024-12-16 10:37:08

淘宝搜下 小淘气

他们的SDK可以用MDK开发

#30 Re: 全志 SOC » 全志H3要用qt该怎么做? » 2024-12-09 08:49:24

zyz_432 说:

楼主,问题解决了吗我也遇到了同样问题,交叉编译编译不过,在板子上H3编译编几个小时后也报错,快奔溃了

用buildroot,配置为h3 sdk里面相同的toolchain就可以顺利编译。

#31 Re: 全志 SOC » f1c200(板子widora tiny200-r3)的lvgl7.11.0移植例程(屏是800x480的电容屏) » 2024-11-25 20:45:44

KingDong 说:

你好,我自己做的板子 也是Tina系统,编译出了出来的LVGL 运行不起来,提示我

root@TinaLinux:~# ls
demo
root@TinaLinux:~# ./demo 1
-/bin/sh: ./demo: not found

编译命令行加静态链接参数, -static

#32 Re: 全志 SOC » T113-I ddr初始化失败[悬赏200块] » 2024-11-18 09:42:52

suibian 说:

哈哈,200要归我了。
找到全志的参考原理图调整数据线的线序,你这个线序不对。

@aeo1234 请问楼主你的问题解决了吗?

已给楼主发 email

#34 Re: DIY/综合/Arduino/写字机/3D打印机/智能小车/平衡车/四轴飞行/MQTT/物联网 » Linux 开发板选择。 » 2024-10-29 17:20:32

GGDuck 说:

新手小白最近想入手泰山派学linux,请问一下他的生态比树莓派好吗?

入门建议 树莓派,文字教程视频教程都比较多,
也可以选 百问网韦老师,正点原子或者野火等教程多的开发板,
泰山派建议有一定基础再入手。

#35 Re: 全志 SOC » T113-i spi nand 启动失败 » 2024-10-27 20:38:27

@zx2132

[    2.397788] 0x000000500000-0x000008000000 : "sys"
[    2.465305] sunxi-spinand-phy: phy blk 245 is bad
[    2.528048] sunxi-spinand-phy: phy blk 440 is bad
[    2.589057] sunxi-spinand-phy: phy blk 635 is bad
[    2.648875] sunxi-spinand-phy: phy blk 830 is bad

[    6.117168] VFS: Cannot open root device "ubi0_3" or unknown-block(0,0): error -19
[    6.125666] Please append a correct "root=" boot option; here are the available partitions:
[    6.135105] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

换片 flash 试一试

#36 Re: 全志 SOC » T113使用gpadc去采集电压。不知道是不是设置有问题,不能读取 » 2024-10-11 06:58:26

无情一刀 说:
哇酷小二 说:

不能用这个驱动,貌似有另外一个读adc值驱动。

或者直接在用户层devmem读取/dev/mem adc寄存器。


现在就是不知道这个读取adc值的驱动是那个  ,可能驱动不对,我的dev下没有这个mem的寄存器值

https://cn.bing.com/search?q=devmem%20site:whycan.com

#38 Re: 全志 SOC » 用什么工具开发基于开发板的应用比较方便 » 2024-09-30 09:54:28

QQ截图20240930095212.png

mobaxterm ssh 终端勾上 X11-Forwarding 可以直接显示基于SDL的LVGL app窗口

#40 Re: 全志 SOC » V3s buildroot 一键生成打包生成32M spi flash 镜像, jffs2 文件系统, 默认启动 Qt 模拟时钟demo, » 2024-09-23 17:07:53

lsknife 说:
路人 说:

@晕哥
env.bin文件没有自动生成,这文件是什么?

同意遇到这个问题了,env.bin生产失败是什么原因呢

建议移步到:
(V3s/V3x/S3/S3L/R11通吃)小智V3x开发板smallwitpi lite u-boot/linux/buildroot测试

#41 Re: 全志 SOC » 请问有没有大神搞定了f1c100s的主线kernel4.19下的声卡驱动?[13楼@wammaw1314搞定声卡驱动,欢迎测试] » 2024-09-18 11:00:43

retroman 说:

有人试过6.6内核吗, 现在用6.6别的都正常, 就差声卡了. 打了Mesih Kilinc的补丁, 声卡设备是认了, 但是没有声音出, 没有头绪了.

buildroot-tiny200 (F1C100/200s) 开发包近期更新内容 * 已支持DVP摄像头 *,支持SPI NAND
https://whycan.com/t_5221.html

可以先用这个测试

#42 Re: 全志 SOC » V3s 应用程序 segmentation fatult » 2024-09-12 17:36:45

netonet88 说:

内存泄漏会把整个文件系统都破坏掉吗?但系统看上去都正常,文件也都在,就是应用程序运时就报错

比较一下可执行文件和依赖的so文件的md5码

#44 Re: 全志 SOC » 全志分区的解打包 » 2024-09-09 17:26:10

试一试通过uboot或者linux命令替换上面的 bootlogo.bmp文件

#47 Re: 全志 SOC » 使用T113S3 tina linux驱动ST7701S RGB长条屏幕,显示lvgl demo分两半问题 » 2024-08-30 10:35:56

我翻了一下 →→→ST7701S手册←←←

支持以下分辨率

Display Resolution
- 480*RGB (H) *960(V) (FWVGA)
- 480*RGB (H) *864(V) (WVGA)
- 480*RGB (H) *854(V)
- 480*RGB (H) *800(V)
- 480*RGB (H) *720(V)
- 480*RGB (H) *640(V) (VGA)
- 480*RGB (H) *360(V)

如果没猜错的话,接受分辨率应该是480*RGB (H) *960(V) (FWVGA)

实际面板被剪裁到了 400*960,你问下供应商是不是这样?

#48 Re: 全志 SOC » 小白自制Linux开发板(F1C200s)整理系列,持续更新中 » 2024-08-29 16:44:15

姓名死机了 说:

最近开始对开发板感兴趣了,向大佬学习一下

请发这种帖:

老树也能开新花,A20都用上linux6了
https://whycan.com/t_11345.html

#49 Re: 全志 SOC » 准备把Qt5.9.2运行在AllWinner全志V3s荔枝派zero板子上 » 2024-08-29 15:07:15

范特西 说:

请问这个平台能把opengl编进去吗?

V3s没有GPU不支持OpenGL,A33/A133支持OpenGL。

#51 Re: 全志 SOC » ubuntu 22.03不能显示中文是哪里不对啊? » 2024-08-28 20:14:23

ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ cat /etc/issue
Ubuntu 22.04.3 LTS \n \l

ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ export |grep UTF-8
declare -x LANG="en_US.UTF-8"
declare -x LC_ADDRESS="zh_CN.UTF-8"
declare -x LC_IDENTIFICATION="zh_CN.UTF-8"
declare -x LC_MEASUREMENT="zh_CN.UTF-8"
declare -x LC_MONETARY="zh_CN.UTF-8"
declare -x LC_NAME="zh_CN.UTF-8"
declare -x LC_NUMERIC="zh_CN.UTF-8"
declare -x LC_PAPER="zh_CN.UTF-8"
declare -x LC_TELEPHONE="zh_CN.UTF-8"
declare -x LC_TIME="zh_CN.UTF-8"
ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ ls /mnt/hgfs/D/*.txt -l
-rwxrwxrwx 1 root root  6853  8月 14 21:51  /mnt/hgfs/D/1.txt
-rwxrwxrwx 1 root root 27295  8月 14 21:52  /mnt/hgfs/D/2.txt
-rwxrwxrwx 1 root root  2348  8月 14 22:02  /mnt/hgfs/D/3.txt
-rwxrwxrwx 1 root root  3317  8月 14 22:02  /mnt/hgfs/D/4.txt
-rwxrwxrwx 1 root root 16537  8月 13 09:17  /mnt/hgfs/D/5.txt
-rwxrwxrwx 1 root root 66847  7月 14 21:09  /mnt/hgfs/D/t113_i_nezha_error.txt
-rwxrwxrwx 1 root root 34186  7月 14 20:51  /mnt/hgfs/D/t113_s3_sw113_error.txt
-rwxrwxrwx 1 root root 39927  7月 14 20:53  /mnt/hgfs/D/t113_s3_sw113_ok.txt
-rwxrwxrwx 1 root root   923  7月 13 15:56  /mnt/hgfs/D/test.txt
-rwxrwxrwx 1 root root     0  6月  3 17:21  /mnt/hgfs/D/中国.txt
-rwxrwxrwx 1 root root 13826  8月  5 11:27 '/mnt/hgfs/D/新文件 24.txt'
-rwxrwxrwx 1 root root 35635  8月  5 11:27 '/mnt/hgfs/D/新文件 25.txt'
-rwxrwxrwx 1 root root 37255  8月  5 11:36 '/mnt/hgfs/D/新文件 26.txt'
-rwxrwxrwx 1 root root 87707  8月  5 11:55 '/mnt/hgfs/D/新文件 27.txt'
-rwxrwxrwx 1 root root 93467  8月  5 11:57 '/mnt/hgfs/D/新文件 28.txt'
-rwxrwxrwx 1 root root 35862  8月  5 12:21 '/mnt/hgfs/D/新文件 29.txt'
ubuntu@ubuntu:/opt$ 
ubuntu@ubuntu:/opt$ 

QQ截图20240828201312.png

"en_US.UTF-8" 不应该是 "zh_CN.UTF-8" 吗?

#52 Re: 全志 SOC » T113的tina编译gtk报错 » 2024-08-24 06:58:59

s45123456789 说:
晕哥 说:

@s45123456789
T113不支持,A133支持wayland。

哦哦,这样呀。大佬,那T113有什么办法编译出gtk的webkit来用吗?

不建议,估计得卡成ppt

#53 Re: 全志 SOC » T113的tina编译gtk报错 » 2024-08-23 19:09:17

@s45123456789
T113不支持,A133支持wayland。

#54 Re: 全志 SOC » 开源个 D1 / D1-H核心板 » 2024-08-23 13:57:41

arychen 说:

这个跟T113-I  pin2pin吗

是的,但是T113-i缺HDMI功能。

#55 Re: 全志 SOC » 全志H6的USB0 OTG模式连接电脑没有任何反应 » 2024-08-22 17:02:44

剑圣UZI 说:

应该是主线linux吧,uname -a 的output:
Linux orangepi3-lts 5.10.75-sun50iw6 #2.2.2 SMP Wed Apr 20 09:45:07 CST 2022 aarch64 aarch64 aarch64 GNU/Linux

参考这个看看:请问下主线 V3s Linux 如何在程序运行中自动切换USB模式: otg/host/peripheral

#57 Re: 全志 SOC » T113-S3 对比 v3s » 2024-08-21 15:40:27

wonrowl 说:

V3S经常抽风,感觉是个半成品,我的板子就是莫名其妙的问题,我都放弃V3S了,

V3S的编解码器也没用起来过😞

V3S芯片没有问题的,这个芯片出货量挺大。

#58 Re: 全志 SOC » T113-S3 对比 v3s » 2024-08-21 15:39:25

chendong 说:
晕哥 说:

V3s有mipi camera和h264 encoder,T113-S3没有。

T113-S3外设更丰富,内存128M。

晕哥,哪里能下下到最新的版本的v3s的声卡驱动,我现在内核是3.4 的,播放网络音乐时不时出现xrun, 不知道是不是驱动问题。

是不是没有建缓冲区?凡数字方式传播音乐,都要在接收端建缓冲区。

#59 Re: 全志 SOC » T113-S3 对比 v3s » 2024-08-21 15:37:37

wonrowl 说:

大佬,这论坛有没有改版的计划啊,发个图片什么都麻烦的要死😰

晕哥 说:

V3s有mipi camera和h264 encoder,T113-S3没有。

T113-S3外设更丰富,内存128M。

感谢您的建议,其实计划早就有了,只是缺money。

一定改,只是时间问题,谢谢支持。

#61 Re: 全志 SOC » 有没有tf卡座接口的sd芯片啊? » 2024-08-18 23:01:08

8p是啥?我记得tf卡座是9p的吧,也许我记错了

8p是指sdnand芯片封装

#62 Re: 全志 SOC » 有没有tf卡座接口的sd芯片啊? » 2024-08-18 23:00:29

我说的就是这意思啊,为啥不把tf卡芯片封装成卡座那种9针的,直接往卡座上一焊就行了,这些厂家非要自己搞个两排八脚的封装出来,通用性差了十万八千里,搞成通用封装所有的产品只要把卡座拆掉,都不用改板子

每个用户需求不同,可以考虑自己做一个转接板,类似这种:

设计一片 SD NAND + JTAG(全志soc) 转接板    [切记切记0.8mm厚度]
https://whycan.com/t_2025.html

改成半孔的

#63 Re: 全志 SOC » 有没有tf卡座接口的sd芯片啊? » 2024-08-18 22:57:56

echo 说:
晕哥 说:

用TF卡直接做产品基本没有,因为那个接插口太不可靠了。

米兔故事机内部就是TF卡槽+TF卡存储当内置存储用。

消费电子产品这样用,问题也不大.

但是如果是类工业设备,经过一个春夏秋冬触点大概就氧化差不多了.即使不氧化,运输途中的颠簸就够喝一壶.

#64 Re: 全志 SOC » 有没有tf卡座接口的sd芯片啊? » 2024-08-18 22:55:47

microxp 说:
晕哥 说:

用TF卡直接做产品基本没有,因为那个接插口太不可靠了。

我说的就是这意思啊,为啥不把tf卡封装成卡座那种9针的,直接往卡座上一焊就行了

啊这,8p不是更好吗?

#65 Re: 全志 SOC » v3s 如何在线更新内核。 » 2024-08-18 22:54:16

chendong 说:

用的正是spi nand。歇菜了。

也可以刷,命令不同,应该是用ubi相关命令.

#66 Re: 全志 SOC » 有没有tf卡座接口的sd芯片啊? » 2024-08-18 21:22:57

用TF卡直接做产品基本没有,因为那个接插口太不可靠了。

#67 Re: 全志 SOC » v3s 如何在线更新内核。 » 2024-08-18 20:28:09

emmc tf卡 可以用dd,

spi nor和spi nand不行

#68 Re: 全志 SOC » 拜求大佬帮我看看我编译f1c200s的uboot遇到的问题 » 2024-08-18 16:54:04

arch/arm/dts/suniv-f1c100s-licheepi-nano.dts

59行有语法错误

#69 Re: 全志 SOC » T113-S3 对比 v3s » 2024-08-17 22:09:33

V3s有mipi camera和h264 encoder,T113-S3没有。

T113-S3外设更丰富,内存128M。

#70 Re: 全志 SOC » 全职v3s 换到I2C出现GPIO报错问题有谁知道! » 2024-08-17 21:08:44

hai2599 说:

全志v3s TWI1  能PB8 PB9  也能 PE21 PE22的吗??

串口已经用PB8 PB9了

内核是用5.2的。。

没有这么用过,感觉不行,或许可以。

#73 Re: 全志 SOC » t113i + openwrt tina » 2024-08-10 19:38:07

这是A523 ddr调整方法:

1. 查看DDR频点
a523-pro:/ # cat /sys/class/devfreq/3120000.dmcfreq/available_frequencies
154000000 528000000 739200000 924000000
2. 查看实时频率参数的节点
echo  1 > /sys/module/sun55iw3_devfreq/parameters/dbg_level
或者
echo > 1  /sys/module/ccu_ddr/parameters/dbg_level
如果还是找不到,就到/sys/module/下find -name dbg_level找到具体的路径执行echo 1即可
响应的串口打印

[  434.856467][  T496] drate:154M load:57 rw:705M total:1232M
[  434.870411][  T496] drate:154M load:55 rw:684M total:1232M
[  434.889498][  T496] drate:154M load:42 rw:521M total:1232M
[  434.899553][  T496] drate:154M load:62 rw:771M total:1232M
[  434.909495][  T496] drate:154M load:41 rw:506M total:1232M
可以看到当前的DDR频率是154MHz

T113芯片可能不支持

#74 Re: 全志 SOC » D1s调试lvds,求解? » 2024-08-09 14:06:16

@ghosoft
把正常的文件和不正常的文件都发上来看看

#75 Re: 全志 SOC » t113i + openwrt tina » 2024-08-09 10:51:18

1、CPU 频率可以再现有系统调整,DDR有类似方法吗?还是必须配置内核,重新编译烧录?


这句没看懂

#76 Re: 全志 SOC » D1s调试lvds,求解? » 2024-08-08 16:32:55

退回去再一步一步修改,看改到哪一步的时候触发Unhandled exception: Load access fault

#78 Re: 全志 SOC » 求助! 全志H133录音是能正常录进去声音 但是伴随有哒哒哒的杂音 » 2024-08-06 14:20:32

是麦克风录音吗,检查一下麦克风周边电路。

还有检查一下采集的录音数据是否完整,如果丢了一些数据可能也会有杂音。

#79 Re: 全志 SOC » 哪一个是最新的BuildRoot合适F1C100s? » 2024-08-06 11:50:30

可能是编译环境的问题,我这边用Ubuntu18.04 编译 aodzip/buildroot-tiny200 正常。

#80 Re: 全志 SOC » f1c100s如何设置root开机免密自动登陆 » 2024-08-05 18:19:21

晕哥 说:

https://whycan.cn/t_542.html#p12585




找到 /etc/inittab 文件的

console::respawn:/sbin/getty -L  console 0 vt100 # GENERIC_SERIAL

修改为:

console::respawn:-/bin/sh

重启后就没有恼人的 login 提示了.

这里有个问题,会导致没有加载用户配置,没有$HOME 环境变量。

改成这样:
console::respawn:/bin/login -f root

解决$HOME环境变量问题。

# export
export EDITOR='/bin/vi'
export HOME='/root'
export LOGNAME='root'
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
export PS1='# '
export PWD='/root'
export SHELL='/bin/sh'
export SHLVL='1'
export TERM='vt102'
export USER='root'
#

#81 Re: 全志 SOC » 有没有在全志 V3s下用过Spi nand flash的朋友? » 2024-08-04 16:30:53

hdlazyhy 说:

我的开发板上就是这个nand flash芯片。是不是需要在sunxi-tools中添加支持。正好找到这。

xfel 支持spi nand读写

#82 Re: 全志 SOC » 请教V3S驱动1024分辨率屏的问题 » 2024-08-04 15:42:08

可能在 uboot 里面有个显存大小配置不够大,导致初始化失败

#83 Re: 全志 SOC » 荔枝派nano f1c100s开发板连接JLink调试器分享 » 2024-08-04 11:01:25

袜裤够穿吗 说:

晕哥,jlink可以固化程序到flash吗?还是只能在内存中调试呢?

单步调试必须在内存,加魔术头之后可以固化到flash,参考 mksunxi.c

#84 Re: 全志 SOC » t113i + openwrt tina » 2024-08-01 22:11:34

CPU和DDR降频排除硬件问题

#85 Re: 全志 SOC » V3s/S3/f1c100s通过USB启动Linux,并把SD NAND/TF卡挂载为U盘, 可以dd或Win32DiskImager任烧写 » 2024-07-28 13:02:02

海石生风 说:

提示出错的语句为f'{x}'语法,这是python3.6起才支持的语法,很可能反而是python3没有安装。

有道理,不过我看了早期的uboot版本里面binman确实用的是Python2.7

#86 Re: 全志 SOC » V3s/S3/f1c100s通过USB启动Linux,并把SD NAND/TF卡挂载为U盘, 可以dd或Win32DiskImager任烧写 » 2024-07-28 11:05:48

田维龙 说:

https://whycan.com/files/members/14964/sshot-1.png
晕哥编译v3s的uboot的时候有遇到过這个问题吗?

没记错的话,binman 是一个 python2.x 版本,先检查一下 python2.7 有没有安装?或者看下 /usr/bin/python 是不是软链接到 python3.x 了?

#87 Re: 全志 SOC » 全志a133支持同时控制多个屏幕吗 » 2024-07-14 18:41:28

那可以,只要CPU,DRAM和网络带宽允许,跑多少个都不是问题。

#88 Re: 全志 SOC » 全志a133支持同时控制多个屏幕吗 » 2024-07-14 18:00:48

A133只支持一个显示屏

D1-H,H133 支持一个HDMI(或CVBS) + 一个LCD
D1s,T113-S3,T113-S4,T113-i 支持一个 CVBS + 一个LCD

#89 Re: 硬件设计 KiCAD/Protel/DXP/PADS/ORCAD/EAGLE » 发帖挣几个积分 » 2024-07-07 10:24:28

正常发帖回帖的朋友都不会有这个困扰,后台一堆垃圾贴看到都头疼。

#90 Re: 全志 SOC » 请问有没有10元左右,带2个usb host接口的芯片 » 2024-07-04 21:45:16

如果全志找不到,其他家找更难了,加个hub芯片扩?

#91 Re: 全志 SOC » 求一份xr829 tina sdk 3.10内核的驱动 » 2024-06-30 18:24:19

从 linux3.4 里面复制过去试一试:

lichee/linux-3.4/drivers/net/wireless/xr829

#93 Re: 全志 SOC » D1s调试lvds,求解? » 2024-06-27 16:46:42

参考这个帖子:d1 lvds dual

首先在dts中配置lvds1的gpio,大致是下面这样的

			lvds1_pins_a: lvds1@0 {
				pins  = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
				function = "lvds1";
				drive-strength = <30>;
				bias-disable;
			};

			lvds1_pins_b: lvds1@1 {
				pins  = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
				function = "io_disabled";
				drive-strength = <30>;
				bias-disable;
			};

然后在dts中配置dual lvds,主要是lcd_lvds_if与pinctrl-0

&lcd0 {
	lcd_used            = <1>;

	lcd_driver_name     = "default_lcd";
	lcd_backlight       = <50>;
	lcd_if              = <3>;

	lcd_x               = <640>;
	lcd_y               = <2560>;
	lcd_width           = <150>;
	lcd_height          = <94>;
	lcd_dclk_freq       = <117>;

	lcd_pwm_used        = <0>;
	lcd_pwm_ch          = <7>;
	lcd_pwm_freq        = <50000>;
	lcd_pwm_pol         = <1>;
	lcd_pwm_max_limit   = <255>;
 
	lcd_hbp             = <40>;
	lcd_ht              = <720>;
	lcd_hspw            = <20>;
	lcd_vbp             = <20>;
	lcd_vt              = <2600>;
	lcd_vspw            = <10>;
	
	lcd_lvds_if         = <1>;
	lcd_lvds_colordepth = <0>;	
	lcd_lvds_mode       = <0>;
	lcd_frm             = <0>;
	lcd_hv_clk_phase    = <0>;
	lcd_hv_sync_polarity= <0>;
	lcd_gamma_en        = <0>;
	lcd_bright_curve_en = <0>;
	lcd_cmap_en         = <0>;

	deu_mode            = <0>;
	lcdgamma4iep        = <22>;
	smart_color         = <90>;
	
        pinctrl-0 = <&lvds0_pins_a &lvds1_pins_a>;
        pinctrl-1 = <&lvds0_pins_b &lvds1_pins_b>;	
  
};

把20条腿都复用为LVDS:
        pinctrl-0 = <&lvds0_pins_a &lvds1_pins_a>;


驱动配置为双8:
    lcd_lvds_if         = <1>;

Linux启动后查看引脚复用状态:

# cat /sys/kernel/debug/pinctrl/pio/pinmux-pins
Pinmux settings per pin
Format: pin (name): mux_owner|gpio_owner (strict) hog?
pin 32 (PB0): device 2502800.twi function gpio_in group PB0
pin 33 (PB1): device 2502800.twi function gpio_in group PB1
pin 34 (PB2): UNCLAIMED
pin 35 (PB3): UNCLAIMED
pin 36 (PB4): UNCLAIMED
pin 37 (PB5): UNCLAIMED
pin 38 (PB6): UNCLAIMED
pin 39 (PB7): UNCLAIMED
pin 40 (PB8): device 2500000.uart function uart0 group PB8
pin 41 (PB9): device 2500000.uart function uart0 group PB9
pin 42 (PB10): GPIO pio:42
pin 43 (PB11): GPIO pio:43
pin 44 (PB12): GPIO pio:44
pin 64 (PC0): device 2008000.ledc function ledc group PC0
pin 65 (PC1): UNCLAIMED
pin 66 (PC2): device 4025000.spi function spi0 group PC2
pin 67 (PC3): device 4025000.spi function spi0 group PC3
pin 68 (PC4): device 4025000.spi function spi0 group PC4
pin 69 (PC5): device 4025000.spi function spi0 group PC5
pin 70 (PC6): device 4025000.spi function spi0 group PC6
pin 71 (PC7): device 4025000.spi function spi0 group PC7
pin 96 (PD0): UNCLAIMED
pin 97 (PD1): UNCLAIMED
pin 98 (PD2): UNCLAIMED
pin 99 (PD3): UNCLAIMED
pin 100 (PD4): UNCLAIMED
pin 101 (PD5): UNCLAIMED
pin 102 (PD6): UNCLAIMED
pin 103 (PD7): UNCLAIMED
pin 104 (PD8): UNCLAIMED
pin 105 (PD9): UNCLAIMED
pin 106 (PD10): UNCLAIMED
pin 107 (PD11): UNCLAIMED
pin 108 (PD12): UNCLAIMED
pin 109 (PD13): UNCLAIMED
pin 110 (PD14): UNCLAIMED
pin 111 (PD15): UNCLAIMED
pin 112 (PD16): UNCLAIMED
pin 113 (PD17): UNCLAIMED
pin 114 (PD18): UNCLAIMED
pin 115 (PD19): UNCLAIMED
pin 116 (PD20): UNCLAIMED
pin 117 (PD21): UNCLAIMED
pin 118 (PD22): UNCLAIMED
pin 128 (PE0): device 4500000.eth function gmac0 group PE0
pin 129 (PE1): device 4500000.eth function gmac0 group PE1
pin 130 (PE2): device 4500000.eth function gmac0 group PE2
pin 131 (PE3): device 4500000.eth function gmac0 group PE3
pin 132 (PE4): device 4500000.eth function gmac0 group PE4
pin 133 (PE5): device 4500000.eth function gmac0 group PE5
pin 134 (PE6): device 4500000.eth function gmac0 group PE6
pin 135 (PE7): device 4500000.eth function gmac0 group PE7
pin 136 (PE8): device 4500000.eth function gmac0 group PE8
pin 137 (PE9): device 4500000.eth function gmac0 group PE9
pin 138 (PE10): device 4500000.eth function gmac0 group PE10
pin 139 (PE11): device 4500000.eth function gmac0 group PE11
pin 140 (PE12): device 4500000.eth function gmac0 group PE12
pin 141 (PE13): device 4500000.eth function gmac0 group PE13
pin 142 (PE14): device 4500000.eth function gmac0 group PE14
pin 143 (PE15): device 4500000.eth function gmac0 group PE15
pin 144 (PE16): GPIO pio:144
pin 145 (PE17): UNCLAIMED
pin 160 (PF0): device 4020000.sdmmc function sdc0 group PF0
pin 161 (PF1): device 4020000.sdmmc function sdc0 group PF1
pin 162 (PF2): device 4020000.sdmmc function sdc0 group PF2
pin 163 (PF3): device 4020000.sdmmc function sdc0 group PF3
pin 164 (PF4): device 4020000.sdmmc function sdc0 group PF4
pin 165 (PF5): device 4020000.sdmmc function sdc0 group PF5
pin 166 (PF6): GPIO pio:166
pin 192 (PG0): device 4021000.sdmmc function sdc1 group PG0
pin 193 (PG1): device 4021000.sdmmc function sdc1 group PG1
pin 194 (PG2): device 4021000.sdmmc function sdc1 group PG2
pin 195 (PG3): device 4021000.sdmmc function sdc1 group PG3
pin 196 (PG4): device 4021000.sdmmc function sdc1 group PG4
pin 197 (PG5): device 4021000.sdmmc function sdc1 group PG5
pin 198 (PG6): device 2500400.uart function uart1 group PG6
pin 199 (PG7): device 2500400.uart function uart1 group PG7
pin 200 (PG8): device 2500400.uart function uart1 group PG8
pin 201 (PG9): device 2500400.uart function uart1 group PG9
pin 202 (PG10): GPIO pio:202
pin 203 (PG11): device soc@3000000:rfkill@0 function clk_fanout1 group PG11
pin 204 (PG12): GPIO pio:204
pin 205 (PG13): UNCLAIMED
pin 206 (PG14): UNCLAIMED
pin 207 (PG15): GPIO pio:207
pin 208 (PG16): GPIO pio:208
pin 209 (PG17): GPIO pio:209
pin 210 (PG18): GPIO pio:210

如果文件/sys/kernel/debug/pinctrl/pio/pinmux-pins不存在,先执行这个命令:

mount -t debugfs none /sys/kernel/debug;

#94 Re: 全志 SOC » D1s调试lvds,求解? » 2024-06-27 15:55:11

找一下哪个文件参与编译 find . -name pinctrl-sun*.o

然后直接那个 .c 文件

#95 Re: 全志 SOC » 全志v3s的dts怎么配置pwm0,让其管脚PB4在系统初始化阶段不是3.3v高电平 » 2024-06-27 10:13:03

游侠TT 说:
晕哥 说:

uboot初始化成 gpio低电平,进linux配置成pwm

昨天已经试过了,屏蔽了linux的pwm,pwm0的管脚PB4可以正常被Uboot设置成高或者低电平,设置成低后再加上linux的pwm,立马就变高了

所以建议你改V3s 的 pwm 驱动,先把pwm寄存器值读出来,然后再写回去,或者可以用别的方法避免再次初始化。

#97 Re: RK3288/RK3399/RK1108 » [RK3188] kernel 卡死,请各位给点分析问题的意见? » 2024-06-26 11:35:15

如果没有任何日志输出就死了,考虑一下硬件问题,给CPU/DDR降频降温试一试。

#98 Re: 全志 SOC » t113-s3的tina linux如何配置及编译sdk自带的qt? » 2024-06-25 11:40:17

arychen 说:

如果只用来解码放视频,能不用QT吗

可以不用

#99 Re: 全志 SOC » t113-s3的tina linux如何配置及编译sdk自带的qt? » 2024-06-25 10:11:02

lch922 说:
暗水天狼 说:

有朋友测试过Wayland吗?

这颗芯片不带GPU,wayland可以开启硬件加速吗?

只能g2d加速

#100 Re: 工业芯 匠芯创 » 请教,单片机一般如何保存定时采集的数据,要求长期保存,方便查寻历史记录。 » 2024-06-25 09:57:25

Gentlepig 说:
晕哥 说:

建议用日志型(ext4,jffs2...)的文件系统,按时间段分文件存储。

如果没有后备电池和断电检测,做好最后一个文件阵亡的心理准备。

我这不是linux系统啊,是rtt,目前看sdk里默认打开了fatfs和littlefs。

那建议优先使用Littlefs文件系统,按时间段分文件存储。

LittleFS 是一种日志结构化的文件系统。它结合了日志结构(log-structured)文件系统和Copy-on-Write (COW)文件系统的特点。在日志结构的文件系统中,新的数据总是被写入到空闲或新分配的空间中,而不是直接覆盖旧的数据,这有助于减少对闪存介质的磨损并提供更好的掉电恢复能力。

#101 Re: 工业芯 匠芯创 » 请教,单片机一般如何保存定时采集的数据,要求长期保存,方便查寻历史记录。 » 2024-06-25 09:28:03

建议用日志型(ext4,jffs2...)的文件系统,按时间段分文件存储。

如果没有后备电池和断电检测,做好最后一个文件阵亡的心理准备。

#103 Re: 全志 SOC » st7789v编译不通过,求助 » 2024-06-24 22:52:56

arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts:54.36-37 syntax error

语法错误

#105 Re: 全志 SOC » A33主线Linux跑起OpenGL/ES » 2024-06-19 17:10:46

wangjun110 说:

楼主,请问一下,在编译应用程序的时候-lX11,这个libx11.so的库在哪里有提供呢?

应该在 buildroot 有这个package

#106 Re: RT1050/RT10XX » 把前几年买的不能自动的JLINK V9刷成 可以自动更新的版本了. » 2024-06-17 11:02:41

liyucai 说:

我的 J-Link V9 被 segger 软件自动升级了,然后就用不了了。
有什么办法防止它去自动升级吗?

用另外一个jlink,按楼顶的办法烧回去

#108 Re: 全志 SOC » F1C100S可以软关机或者进入低功耗吗 » 2024-06-13 17:39:04

echo N > /sys/module/printk/parameters/console_suspend

echo mem > /sys/power/state

#109 Re: 工业芯 匠芯创 » luban-lite不支持D133BAS吗? » 2024-06-11 10:47:18

如果是同一个DIE,那应该通用。

#111 Re: 全志 SOC » 全志v3s系统怎么支持中文显示 » 2024-06-08 22:04:56

是说 ls 不能显示中文目录和文件名吗?

参考这个:

T113 Busybox ls 支持中文的解决办法
https://whycan.com/t_11022.html

#112 Re: 全志 SOC » v3s官方buildroot文件系统卡在start kernerl... » 2024-06-06 10:29:43

用这个:

(V3s/V3x/S3/S3L/R11通吃)小智V3x开发板smallwitpi lite u-boot/linux/buildroot测试
https://whycan.com/t_7248.html

#113 Re: 全志 SOC » f1c100s烧写tina镜像失败 » 2024-05-29 09:21:59

先把 sys_config.fex 里面的 debug uart 改成你的调试uart

#115 Re: 全志 SOC » 模仿stm32标准库风格写的库文件(f1c100s/f1c200s),且已移植了rt-thread、lvgl、fatfs、cherryusb » 2024-05-26 20:10:09

gaoda 说:

为什么我烧录进spiflash成功,但重启后还是进入fel模式呢?flash型号是w25q128,烧录进ram能运行

烧flash和tf卡要加魔术头,本站右上角搜:mksunxi

#118 Re: 全志 SOC » 请问F1C100S 怎么配置,才可以点亮MIYOO游戏机的40PIN屏幕 » 2024-05-24 16:28:00

据说每个显示屏厂家给的初始化代码都是不一样的,所以建议用逻辑分析仪抓能点亮的屏数据,然后照着写进去就可以了。

#121 Re: 全志 SOC » 真是渣渣,T113-S3 tplayerdemo 测试播放1280x720视频,两小时就挂了 » 2024-05-17 13:34:25

改大这个初始化参数试一试: VideoConf.nVbvBufferSize

	if(Decoder->ScaleDownEn > 0){
		VideoConf.nVbvBufferSize = 1*1024*1024;
		VideoConf.bScaleDownEn = 1;
		VideoConf.nHorizonScaleDownRatio = 1;
		VideoConf.nVerticalScaleDownRatio = 1;
	}

	VideoConf.eOutputPixelFormat  = Decoder->decode_format;

    VideoConf.nDeInterlaceHoldingFrameBufferNum = GetConfigParamterInt("pic_4di_num", 2);
    VideoConf.nDisplayHoldingFrameBufferNum = GetConfigParamterInt("pic_4list_num", 3);
    VideoConf.nRotateHoldingFrameBufferNum = GetConfigParamterInt("pic_4rotate_num", 0);
    VideoConf.nDecodeSmoothFrameBufferNum = GetConfigParamterInt("pic_4smooth_num", 3);
    VideoConf.memops = Decoder->memops;
    nRet = InitializeVideoDecoder(Decoder->pVideoDec, &VideoInfo, &VideoConf);

#122 Re: 全志 SOC » F1C200S 改为电阻触摸屏 » 2024-05-10 09:11:23

wwddgod 说:

[*] 缺少匹配的标签 [/*]
发帖的时候一直报这个错误是什么意思?

用code 标签包裹就可以,这是一个bbcode解析错误信息。

#124 Re: 工业芯 匠芯创 » 5款Linux桌面环境推荐,你最爱哪个? » 2024-04-29 16:36:52

Gentlepig 说:

感觉楼主是机器人自动发帖。
搜了下楼主发的帖子,有几个明显是复制粘贴过来,原帖可能有图片,就只把文字复制过来了。

现在这个帖子,在厂家版块发了个不知所以的灌水贴。

应该是的,另外几个广告帖删了。

#125 Re: 全志 SOC » 对于V3s 和 H3 上面 Jtag 的疑问 » 2024-04-28 20:02:41

设计一片 SD NAND + JTAG(全志soc) 转接板    [切记切记0.8mm厚度]
https://whycan.com/t_2025.html

#126 Re: 全志 SOC » OOM炸了,DRAM不够,SWAP来凑 » 2024-04-24 09:52:49

dgtg 说:

请教晕哥,在C100外挂8MB nor flash的平台上也可以开启SWAP吗?

应该不行,除了速度特慢外,swap应该不支持这种分区类型。

#127 Re: 全志 SOC » Whycanpi sdk_2.1 编译T113问题 » 2024-04-23 10:36:08

--来自百度网盘超级会员V4的分享
hi,这是我用百度网盘分享的内容~复制这段内容打开「百度网盘」APP即可获取 
链接:https://pan.baidu.com/s/1tADvigD1xtOWqieJmcuPkA?pwd=awol 
提取码:awol

#128 Re: 全志 SOC » 求教 t113如何使用外置声卡如wm8960 » 2024-04-21 15:06:57

amixer 命令读出通路配置,然后对照wm8960手册设置。

最快的办法还是找一下其他开发板现成的配置

#131 Re: 全志 SOC » 荔枝派nano固件启动卡在login处的问题 » 2024-04-20 12:54:42

Rs428 说:
晕哥 说:

可能是串口的发送有问题,用自发自收测试一下看看。

大佬请教下咋测呀,是短接板子的rx和tx嘛

先测usb串口头的tx rx,短路后,用电脑串口软件发信息,看是不是能收到同样的信息。

#132 Re: 全志 SOC » 荔枝派nano固件启动卡在login处的问题 » 2024-04-20 12:31:37

可能是串口的发送有问题,用自发自收测试一下看看。

#133 Re: 全志 SOC » licheepi-nano OTG挂载RTL8188xx终于驱动起来了~ » 2024-04-19 22:17:16

检查供电和USB信号完整性,最好用稳定的开发板先测试。

#134 Re: 全志 SOC » OOM炸了,DRAM不够,SWAP来凑 » 2024-04-19 17:43:18

5O@X4S@HO$9~ETD[77K`I)O.png

malloc ok, count=146
malloc ok, count=147
malloc ok, count=148
malloc ok, count=149
malloc ok, count=150
malloc ok, count=151
malloc ok, count=152
malloc ok, count=153
[  216.137338] mem_test invoked oom-killer: gfp_mask=0x24200ca(GFP_HIGHUSER_MOVABLE), nodemask=0, order=0, oom_score_adj=0
[  216.150768] CPU: 0 PID: 1703 Comm: mem_test Not tainted 4.9.118 #183
[  216.164815] Hardware name: sun8iw8
[  216.168650] [<c010c7cc>] (unwind_backtrace) from [<c010a6f4>] (show_stack+0x10/0x14)
[  216.179140] [<c010a6f4>] (show_stack) from [<c01da458>] (dump_header.constprop.3+0x64/0x1ac)
[  216.190381] [<c01da458>] (dump_header.constprop.3) from [<c01975a4>] (oom_kill_process+0xec/0x4a8)
[  216.208704] [<c01975a4>] (oom_kill_process) from [<c0197e28>] (out_of_memory+0x348/0x3f0)
[  216.217901] [<c0197e28>] (out_of_memory) from [<c019c0ec>] (__alloc_pages_nodemask+0x950/0xa28)
[  216.234830] [<c019c0ec>] (__alloc_pages_nodemask) from [<c01ba94c>] (handle_mm_fault+0x140/0xb70)
[  216.245960] [<c01ba94c>] (handle_mm_fault) from [<c010ec34>] (do_page_fault+0x210/0x2a8)
[  216.256745] [<c010ec34>] (do_page_fault) from [<c01012d4>] (do_DataAbort+0x38/0xb8)
[  216.271863] [<c01012d4>] (do_DataAbort) from [<c010b39c>] (__dabt_usr+0x3c/0x40)
[  216.281845] Exception stack(0xc2393fb0 to 0xc2393ff8)
[  216.294763] 3fa0:                                     ad371010 00006b7f ad448028 00007fff
[  216.304956] 3fc0: 00000000 00000000 00000000 00000000 00000001 00000000 00000020 beda4e34
[  216.316019] 3fe0: ad37101c beda4df0 00000000 b6f72774 20000010 ffffffff
[  216.330038] [ pid ]   uid  tgid total_vm      rss nr_ptes nr_pmds swapents oom_score_adj name
[  216.341363] [  720]     0   720      330        1       4       0        6             0 syslogd
[  216.359483] [  724]     0   724      329        1       4       0        6             0 klogd
[  216.369134] [  736]     0   736      333        1       5       0       13             0 mdev
[  216.383525] [  780]     0   780     1657       11       7       0      754             0 haveged
[  216.395798] [  786]  1001   786      331        0       4       0       18             0 dbus-daemon
[  216.407732] [  792]     0   792     1110       27       6       0       81             0 ntpd
[  216.424769] [  805]     0   805      223        1       4       0        9             0 dropbear
[  216.435459] [  808]     0   808   168315       19       8       0      211             0 allxbee
[  216.446949] [  812]     0   812   167906       32       7       0      313             0 iotWatchdog
[  216.464755] [  952]     0   952      332        1       4       0       10             0 sh
[  216.474740] [ 1616]     0  1616      329        1       3       0        6             0 udhcpc
[  216.486136] [ 1703]     0  1703    40009     8503      82       0    31313             0 mem_test
[  216.502559] Out of memory: Kill process 1703 (mem_test) score 836 or sacrifice child
[  216.512924] Killed process 1703 (mem_test) total-vm:160036kB, anon-rss:33956kB, file-rss:56kB, shmem-rss:0kB
[  216.602368] oom_reaper: reaped process 1703 (mem_test), now anon-rss:4kB, file-rss:0kB, shmem-rss:0kB
Killed
# bg
-sh: bg: No current job
#
#
# free
              total        used        free      shared  buff/cache   available
Mem:          53960       12648       21936           8       19376       37272
Swap:        131068        5320      125748
#

V3s可以申请到153M 内存

#135 Re: 全志 SOC » OOM炸了,DRAM不够,SWAP来凑 » 2024-04-19 11:19:04

已经判断了指针是否为NULL,这个做法是应用程序普遍的处理方式

内存分配器返回非空才是成功,否则就是操作野指针了

即便这样应用还是会被杀。

系统物理内存不够了,或交换内存也不够了。

那如何编写有护栏的应用呢?

护栏是指没有判断参数个数,随便写段测试代码。


要求即便内存oom发生,应用程序也不会被杀。

恐怕不行吧,这不成了无源之水了?

请教晕哥。

不敢当,边学边卖弄。

#136 全志 SOC » OOM炸了,DRAM不够,SWAP来凑 » 2024-04-19 06:49:16

晕哥
回复: 6

刚刚开机,没有swap:

|_   _||_| ___  _ _   |  |   |_| ___  _ _  _ _
  | |   _ |   ||   |  |  |__ | ||   || | ||_'_|
  | |  | || | || _ |  |_____||_||_|_||___||_,_|
  |_|  |_||_|_||_|_|  Tina is Based on OpenWrt!
 ----------------------------------------------
 Tina Linux (5.0, r0-6ada511)
 ----------------------------------------------
nodev   debugfs
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/# free
              total        used        free      shared  buff/cache   available
Mem:         233780       15596      210488           0        7696      211804
Swap:             0           0           0
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/#

编译一个没有护栏的测试程序,每次动态申请1M内存,第二个参数是申请次数:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

void main(int argc, char* argv[])
{
        static int count = 0;
        int times = atoi(argv[1]);

        for(int i =0; i<times; i++)
        {
                void* ptr = malloc(1*1024*1024);

                if(ptr == NULL)
                {
                        printf("malloc error");
                }
                else
                {
                        memset(ptr, 0, 1*1024*1024);
                        printf("malloc ok, count=%3d\n", count++);
                }
        }

        while (1)
        {
                printf("sleep\n");
                usleep(1000*1000);
        }
}



申请大约200M内存的时候挂了:

root@TinaLinux:/#
root@TinaLinux:/# free
              total        used        free      shared  buff/cache   available
Mem:         233780       15788      204344        5948       13648      205664
Swap:             0           0           0
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/# chmod +x /tmp/test && /tmp/test 206
malloc ok, count=0
malloc ok, count=1
... ...
malloc ok, count=197
malloc ok, count=198
malloc ok, count=199
malloc ok, count=200
[  167.228684] test invoked oom-killer: gfp_mask=0x1100cca(GFP_HIGHUSER_MOVABLE|0x1000000), order=0, oom_score_adj=0
[  167.240249] CPU: 1 PID: 1296 Comm: test Not tainted 5.4.61 #1
[  167.246694] Hardware name: Generic DT based system
[  167.252092] [<c010e318>] (unwind_backtrace) from [<c010a8dc>] (show_stack+0x10/0x14)
[  167.260798] [<c010a8dc>] (show_stack) from [<c0785f90>] (dump_stack+0x7c/0x98)
[  167.260815] [<c0785f90>] (dump_stack) from [<c0195914>] (dump_header+0x54/0x270)
[  167.277204] [<c0195914>] (dump_header) from [<c0195d88>] (oom_kill_process+0x78/0x2bc)
[  167.286088] [<c0195d88>] (oom_kill_process) from [<c019676c>] (out_of_memory+0x318/0x384)
[  167.295270] [<c019676c>] (out_of_memory) from [<c01c82e4>] (__alloc_pages_nodemask+0x758/0x9b0)
[  167.305037] [<c01c82e4>] (__alloc_pages_nodemask) from [<c01b37ac>] (alloc_zeroed_user_highpage_movable+0x14/0x3c)
[  167.316657] [<c01b37ac>] (alloc_zeroed_user_highpage_movable) from [<c01b6264>] (handle_mm_fault+0x214/0x7c0)
[  167.327787] [<c01b6264>] (handle_mm_fault) from [<c010f1ac>] (do_page_fault+0x13c/0x29c)
[  167.336872] [<c010f1ac>] (do_page_fault) from [<c010f468>] (do_DataAbort+0x34/0xb4)
[  167.345468] [<c010f468>] (do_DataAbort) from [<c010255c>] (__dabt_usr+0x3c/0x40)
[  167.353768] Exception stack(0xce1fffb0 to 0xce1ffff8)
[  167.359436] ffa0:                                     aa452008 00000000 00006000 aa54c000
[  167.368612] ffc0: 00010bd4 00010c68 00000000 00010134 00000000 00010134 00079470 bea9cb84
[  167.377793] ffe0: 00000000 bea9cb68 000104fc 00027908 20070010 ffffffff
[  167.385280] Mem-Info:
[  167.387840] active_anon:52056 inactive_anon:1486 isolated_anon:0
[  167.387840]  active_file:9 inactive_file:9 isolated_file:0
[  167.387840]  unevictable:0 dirty:0 writeback:0 unstable:0
[  167.387840]  slab_reclaimable:562 slab_unreclaimable:2552
[  167.387840]  mapped:88 shmem:1487 pagetables:139 bounce:0
[  167.387840]  free:478 free_pcp:103 free_cma:0
[  167.423747] Node 0 active_anon:208224kB inactive_anon:5944kB active_file:36kB inactive_file:36kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:352kB dirty:0kB writeback:0kB shmem:5948kB writeback_tmp:0kB unstable:0kB all_unreclaimable? yes
[  167.423767] Normal free:1912kB min:1916kB low:2392kB high:2868kB active_anon:208224kB inactive_anon:5944kB active_file:36kB inactive_file:36kB unevictable:0kB writepending:0kB present:254400kB managed:233780kB mlocked:0kB kernel_stack:560kB pagetables:556kB bounce:0kB free_pcp:412kB local_pcp:112kB free_cma:0kB
[  167.479940] lowmem_reserve[]: 0 0
[  167.479952] Normal: 14*4kB (UM) 12*8kB (UM) 2*16kB (UE) 0*32kB 1*64kB (M) 1*128kB (M) 2*256kB (ME) 0*512kB 1*1024kB (M) 0*2048kB 0*4096kB = 1912kB
[  167.498408] Free pages count per migrate typeat order:     0      1      2      3      4      5      6      7      8      9     10
[  167.511744] zone   Normal, type    Unmovable     13     11      1      0      0      0      0      0      0      0      0
[  167.524168] zone   Normal, type      Movable      1      1      0      0      1      1      1      0      1      0      0
[  167.536584] zone   Normal, type  Reclaimable      0      0      1      0      0      0      1      0      0      0      0
[  167.549007] zone   Normal, type          CMA      0      0      0      0      0      0      0      0      0      0      0
[  167.561421] zone   Normal, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
[  167.573839] zone   Normal, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
[  167.586255] 1501 total pagecache pages
[  167.590458] 0 pages in swap cache
[  167.594173] Swap cache stats: add 0, delete 0, find 0/0
[  167.600066] Free swap  = 0kB
[  167.603293] Total swap = 0kB
[  167.606533] 63600 pages RAM
[  167.609661] 0 pages HighMem/MovableOnly
[  167.613957] 5155 pages reserved
[  167.617487] 2048 pages cma reserved
[  167.621396] Tasks state (memory values in pages):
[  167.626678] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[  167.636364] [   1211]     0  1211     9461       49    18432        0             0 adbd
[  167.645462] [   1254]     0  1254      782       31    10240        0             0 sh
[  167.645472] [   1255]     0  1255      751       27    10240        0             0 init
[  167.663433] [   1256]     0  1256      751       27    10240        0             0 init
[  167.672521] [   1257]     0  1257      751       27    10240        0             0 init
[  167.681611] [   1296]     0  1296    52073    51958   215040        0             0 test
[  167.690698] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),task=test,pid=1296,uid=0
[  167.699814] Out of memory: Killed process 1296 (test) total-vm:208292kB, anon-rss:207480kB, file-rss:0kB, shmem-rss:352kB, UID:0 pgtables:210kB oom_score_adj:0
[  167.766642] oom_reaper: reaped process 1296 (test), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Killed
root@TinaLinux:/#

下面开启交换分区:

mkswap /dev/by-name/swapper && swapon /dev/by-name/swapper 

开启完成:

root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/# mkswap /dev/by-name/swapper && swapon /dev/by-name/swapper
Setting up swapspace version 1, size = 536866816 bytes
[  317.944647] Adding 524284k swap on /dev/by-name/swapper.  Priority:-2 extents:1 across:524284k SS
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/#

测试申请700M,系统正常:

malloc ok, count=0
malloc ok, count=1
... ...
malloc ok, count=691
malloc ok, count=692
malloc ok, count=693
malloc ok, count=694
malloc ok, count=695
malloc ok, count=696
malloc ok, count=697
malloc ok, count=698
malloc ok, count=699
sleep
sleep
sleep

free命令看下内存占用:

root@TinaLinux:/# free
              total        used        free      shared  buff/cache   available
Mem:         233780      221724        6532          92        5524        6400
Swap:        524284      524284           0

申请703M的时候,OOM炸了:

root@TinaLinux:/#
root@TinaLinux:/# chmod +x /tmp/test && /tmp/test 720
malloc ok, count=0
malloc ok, count=1
... ...
malloc ok, count=701
malloc ok, count=702
[24017.015074] test invoked oom-killer: gfp_mask=0x1100cca(GFP_HIGHUSER_MOVABLE|0x1000000), order=0, oom_score_adj=0
[24017.026721] CPU: 1 PID: 1412 Comm: test Not tainted 5.4.61 #1
[24017.033176] Hardware name: Generic DT based system
[24017.033206] [<c010e318>] (unwind_backtrace) from [<c010a8dc>] (show_stack+0x10/0x14)
[24017.033221] [<c010a8dc>] (show_stack) from [<c0785f90>] (dump_stack+0x7c/0x98)
[24017.033237] [<c0785f90>] (dump_stack) from [<c0195914>] (dump_header+0x54/0x270)
[24017.033250] [<c0195914>] (dump_header) from [<c0195d88>] (oom_kill_process+0x78/0x2bc)
[24017.033262] [<c0195d88>] (oom_kill_process) from [<c019676c>] (out_of_memory+0x318/0x384)
[24017.033277] [<c019676c>] (out_of_memory) from [<c01c82e4>] (__alloc_pages_nodemask+0x758/0x9b0)
[24017.033292] [<c01c82e4>] (__alloc_pages_nodemask) from [<c01b37ac>] (alloc_zeroed_user_highpage_movable+0x14/0x3c)
[24017.033305] [<c01b37ac>] (alloc_zeroed_user_highpage_movable) from [<c01b6264>] (handle_mm_fault+0x214/0x7c0)
[24017.033318] [<c01b6264>] (handle_mm_fault) from [<c010f1ac>] (do_page_fault+0x13c/0x29c)
[24017.033332] [<c010f1ac>] (do_page_fault) from [<c010f468>] (do_DataAbort+0x34/0xb4)
[24017.033344] [<c010f468>] (do_DataAbort) from [<c010255c>] (__dabt_usr+0x3c/0x40)
[24017.033349] Exception stack(0xce22ffb0 to 0xce22fff8)
[24017.033358] ffa0:                                     8ac74008 00000000 00007000 8ad6d000
[24017.033368] ffc0: 00010bd4 00010c68 00000000 00010134 00000000 00010134 00079470 beef1b84
[24017.033377] ffe0: 00000000 beef1b68 000104fc 00027908 20070010 ffffffff
[24017.033381] Mem-Info:
[24017.033398] active_anon:25811 inactive_anon:25853 isolated_anon:0
[24017.033398]  active_file:6 inactive_file:4 isolated_file:0
[24017.033398]  unevictable:0 dirty:0 writeback:127 unstable:0
[24017.033398]  slab_reclaimable:628 slab_unreclaimable:3241
[24017.033398]  mapped:19 shmem:19 pagetables:399 bounce:0
[24017.033398]  free:1366 free_pcp:0 free_cma:0
[24017.033412] Node 0 active_anon:103244kB inactive_anon:103412kB active_file:24kB inactive_file:16kB unevictable:0kB isolated(anon):0kB isolated(file):0kB map                                                                    ped:76kB dirty:0kB writeback:508kB shmem:76kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
[24017.033428] Normal free:5464kB min:1916kB low:2392kB high:2868kB active_anon:103300kB inactive_anon:103328kB active_file:24kB inactive_file:16kB unevictable                                                                    :0kB writepending:488kB present:254400kB managed:233780kB mlocked:0kB kernel_stack:536kB pagetables:1596kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[24017.033431] lowmem_reserve[]: 0 0
[24017.033438] Normal: 199*4kB (UME) 141*8kB (UME) 85*16kB (UME) 37*32kB (ME) 16*64kB (ME) 1*128kB (M) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 5620kB
[24017.033474] Free pages count per migrate typeat order:     0      1      2      3      4      5      6      7      8      9     10
[24017.033496] zone   Normal, type    Unmovable     61     34      8      0      0      0      0      0      0      0      0
[24017.033531] zone   Normal, type      Movable     98     82     60     25     13      1      0      0      0      0      0
[24017.033580] zone   Normal, type  Reclaimable     40     25     17     12      3      0      0      0      0      0      0
[24017.033612] zone   Normal, type          CMA      0      0      0      0      0      0      0      0      0      0      0
[24017.033632] zone   Normal, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
[24017.033652] zone   Normal, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
[24017.033671] 178 total pagecache pages
[24017.033678] 146 pages in swap cache
[24017.033683] Swap cache stats: add 424365, delete 424256, find 343/587
[24017.033686] Free swap  = 0kB
[24017.033689] Total swap = 524284kB
[24017.033693] 63600 pages RAM
[24017.033696] 0 pages HighMem/MovableOnly
[24017.033699] 5155 pages reserved
[24017.033702] 2048 pages cma reserved
[24017.033705] Tasks state (memory values in pages):
[24017.033708] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[24017.033730] [   1211]     0  1211    11510        0    24576       77             0 adbd
[24017.033738] [   1254]     0  1254      782        0    10240       36             0 sh
[24017.033747] [   1255]     0  1255      751        0    10240       27             0 init
[24017.033755] [   1256]     0  1256      751        0    10240       27             0 init
[24017.033764] [   1257]     0  1257      751        0    10240       27             0 init
[24017.033772] [   1277]     0  1277      782        0    10240       40             0 sh
[24017.033781] [   1412]     0  1412   181087    51492   731136   129420             0 test
[24017.033787] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),task=test,pid=1412,uid=0
[24017.033813] Out of memory: Killed process 1412 (test) total-vm:724348kB, anon-rss:205892kB, file-rss:0kB, shmem-rss:76kB, UID:0 pgtables:714kB oom_score_adj                                                                    :0
[24017.260905] oom_reaper: reaped process 1412 (test), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Killed
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/#

#137 Re: 全志 SOC » 分享t113-s3 iar裸机工程代码,实现定时器和gpio读写和中断,有兴趣的朋友开源逐步完善其他外设功能 » 2024-04-18 13:26:21

lyy 说:

@jxmlegend  这个xfel怎么编译,我现在板上的SPINAND flash的ID在这个xfel-v1.3.2里面没有,我在文件里加上了我的SPINAND flash的ID,但是不知道该怎么编译代码生成exe

用 MSVC2017 编译 XFEL 项目
https://whycan.com/t_6660.html

#140 Re: 全志 SOC » Debian 9.9 (stretch) 文件系统制作 » 2024-04-15 15:00:05

richardsu 说:

@晕哥

rootfs
debian9.9.rootfs.gz 打包完了, 怎么打成img?  我按照网上找的教程打包, phoenixsuit 说固件文件版本太低, 格式被破坏

或者怎么直接刷到rootfs中, 我现在的系统是buildroot, rootfs是1G

这个只是文件系统,做成原来打包方式里面的根文件系统格式,原来是squashfs就得是squashfs,原来是ext4就得打包成ext4。

然后再用原来的打包方式打包。

#141 Re: 全志 SOC » 在f1c100s上跑MySQL5.1.73 移植记录 » 2024-04-09 13:17:59

@lmnb

$ grep mysql_install_db -r /opt/buildroot/buildroot-2024-aarch64/package/
/opt/buildroot/buildroot-2024-aarch64/package/mariadb/S97mysqld:                $MYSQL_BIN/mysql_install_db --basedir=/usr \
/opt/buildroot/buildroot-2024-aarch64/package/mariadb/mysqld.service:ExecStartPre=/bin/sh -c 'test "`ls -1 /var/lib/mysql | wc -l`" != "0" ||

$ grep mysqld_safe -r /opt/buildroot/buildroot-2024-aarch64/package/
/opt/buildroot/buildroot-2024-aarch64/package/mariadb/S97mysqld:        $MYSQL_BIN/mysqld_safe --pid-file=$MYSQL_PIDFILE --user=mysql \
/opt/buildroot/buildroot-2024-aarch64/package/mariadb/mysqld.service:ExecStart=/usr/bin/mysqld_safe --log-error=/var/log/mysql/mysqld.log

MySQL的package确实没有你说的这两个,但是mariadb里面有,用buildroot 2024.02 可以试一试。

#142 Re: 全志 SOC » 在f1c100s上跑MySQL5.1.73 移植记录 » 2024-04-09 12:03:19

感谢楼主分享!

可是有个问题不明白,你都用buildroot了,为何不直接配置buildroot直接自动编译MySQL呢?

#144 Re: 全志 SOC » 请问t113的nand 刷机这样问题,可能是什么造成的? » 2024-03-31 22:09:00

name         = boot-resource
    size         = 34438


这个改成1024,如果打包失败,就再改大一倍。

#145 Re: 全志 SOC » 请问t113的nand 刷机这样问题,可能是什么造成的? » 2024-03-31 20:15:06

youkebing 说:
memory 说:

ubi volume total size is larger than mtd size.

超过大小了?

看样子是,但是不知道怎么配置

先改板级目录下的 sys_partition.fex 试一试

#146 Re: 全志 SOC » 荔枝派nano 串口无输出 » 2024-03-29 19:28:35

接USB看能否进入FEL烧录模式,如果能进入,说明没有运行程序。

#147 Re: 全志 SOC » T113-S3如何将自己制作的动态库打包进镜像里的usr/lib目录下 » 2024-03-26 13:23:36

find out/ -name libxxx.so |grep ipkg

看下能不能在 out 目录找到文件

#149 Re: 全志 SOC » adb提示No space left on device » 2024-03-15 15:25:57

子非鱼 说:
晕哥 说:

@子非鱼
为什么用adb去测试呢,直接进串口终端测试文件系统不好么?

我最终的目的就是想要把自己的写的应用程序放到板子板子上去运行,现在是上传不上去

得先解决根本问题,前面已经明确了就是文件系统大小问题。

#150 Re: 全志 SOC » adb提示No space left on device » 2024-03-15 13:39:45

@子非鱼
为什么用adb去测试呢,直接进串口终端测试文件系统不好么?

#151 Re: 全志 SOC » adb提示No space left on device » 2024-03-15 10:09:09

@子非鱼
就是 rootfs_data 空间不够,

修改 板级目录下面的 sys_partition.fex 对应rootfs_data的空间大小

#152 Re: 全志 SOC » adb提示No space left on device » 2024-03-15 09:37:52

子非鱼 说:
晕哥 说:

@子非鱼
这个是正常,还是不正常的?

这个是启动正常,但是使用adb push向板子传文件的时候提示remote No space left on device

/dev/by-name/rootfs_data
                          1.4M     24.0K      1.2M   2% /overlay
overlayfs:/overlay        1.4M     24.0K      1.2M   2% /

可能是可写分区大小不够

试一试这两个命令:

mkdir -p /opt/
touch /opt/test.txt

#153 Re: 全志 SOC » adb提示No space left on device » 2024-03-15 09:22:23

@子非鱼
这个是正常,还是不正常的?

#154 Re: 全志 SOC » adb提示No space left on device » 2024-03-15 09:01:20

子非鱼 说:

上传的时候终端上什么都没有显示,需要用什么命令查看吗?

从上电开始的串口日志。

#156 Re: 全志 SOC » buildroot-tiny200 (F1C100/200s) 开发包近期更新内容 * 已支持DVP摄像头 *,支持SPI NAND » 2024-03-13 16:42:48

aaayao 说:
晕哥 说:
aaayao 说:

请问楼主,这个是用什么版本的ubuntu编译的?

16.04,18.04,20.04都可以,其他没有验证。

好的,谢谢!目前用14.0.6编译老是出错,看来要换个系统试试了。

14确实有点老了

#157 Re: 全志 SOC » buildroot-tiny200 (F1C100/200s) 开发包近期更新内容 * 已支持DVP摄像头 *,支持SPI NAND » 2024-03-13 16:04:35

aaayao 说:

请问楼主,这个是用什么版本的ubuntu编译的?

16.04,18.04,20.04都可以,其他没有验证。

#158 Re: 全志 SOC » V3S启动uboot的时候出现这个,有人遇到过嘛 » 2024-02-27 17:28:37

mysteryli 说:
晕哥 说:

提示找不到默认环境变量文件

想起来了 好像是有这么个文件,叫啥名来着
bootcmd.agr还是什么 太久忘了

我也忘记了

#160 Re: 全志 SOC » T113-S3 LVGL独立工程 支持G2D C++/C混合编译 » 2024-02-27 16:51:47

上邪 说:

晕哥,为啥看到有新的回复,我看不到呢

两个“谢谢分享”,一个“不错,学习了”

#161 Re: 全志 SOC » 开源全志V3S 两层板PCB 支持OV7725 OV2640摄像头 » 2024-02-27 12:04:58

whycan.com 说:

这是openmv吗,我记得有个开源的openmv能用ov5640

这个用户名你不能用,重新注册一个吧。

#162 Re: 全志 SOC » 板子新加ES7202 ADC芯片做麦克风 » 2024-02-23 12:03:53

全志的开发板都带了例程,比如D1-H哪吒开发板就有


全志D1-H/D1s RISC-V(基于平头哥C906) 哪吒开发板超全资料合集
https://whycan.com/t_6440.html

#163 Re: 全志 SOC » 板子新加ES7202 ADC芯片做麦克风 » 2024-02-23 10:47:55

建议先找个简易数字麦克风测试

#164 Re: 全志 SOC » t113-s3 adbd cpu占用率45% » 2024-02-15 17:19:55

@帝国炮灰
也没有遇到,你lunch的是第几个?

#165 Re: 全志 SOC » t113-s3 adbd cpu占用率45% » 2024-02-14 20:38:32

帝国炮灰 说:
晕哥 说:
帝国炮灰 说:

@晕哥
感谢晕哥,您使用的是glibc还是musl?

都用过,但是没有发现过adb有问题。


晕哥,您使用的是procd init还是busybox init?

都用过,都没有问题

#166 Re: 全志 SOC » t113-s3 adbd cpu占用率45% » 2024-02-06 17:33:28

帝国炮灰 说:

@晕哥
感谢晕哥,您使用的是glibc还是musl?

都用过,但是没有发现过adb有问题。

#167 Re: 全志 SOC » t113-s3 adbd cpu占用率45% » 2024-02-06 17:07:15

可能是SDK问题:

_20240206170535.jpg


--来自百度网盘超级会员V4的分享
hi,这是我用百度网盘分享的内容~复制这段内容打开「百度网盘」APP即可获取 
链接: https://pan.baidu.com/s/1tADvigD1xtOWqieJmcuPkA?pwd=awol 
提取码:awol

#168 Re: 全志 SOC » t113-s3 adbd cpu占用率45% » 2024-02-06 12:16:58

确实不正常,插了USB线吗?

#169 Re: 全志 SOC » 全志平台耳机HDMI自动切换 » 2024-01-29 11:54:03

8===D 说:

大佬有啥参考案例吗

D1_Linux_AUDIOCODEC_开发指南.pdf
这里有耳机插拔检测说明

#171 Re: 全志 SOC » f1c100s 是否可以在插入tf卡的状态下从flash启动? » 2024-01-25 10:13:49

buildroot-tiny200 (F1C100/200s) 开发包近期更新内容 * 已支持DVP摄像头 *,支持SPI NAND
https://whycan.com/t_5221.html

用这个吧,基本非常完善了,一键编译出所有烧录固件。

#172 Re: 全志 SOC » 《保姆级教程》全志F1C100S/F1C200S spi-flash 启动全流程适配烧录及踩坑指南 » 2024-01-23 23:42:24

howudoingwhycan 说:

楼主,请教一下:F1C200S如何将文件从PC端传至开发板中?F1C200S好像不能联网,而且好像不支持adb命令?

支持adb,本站右上角搜一下。

#175 Re: 全志 SOC » 全志H618 固件用什么软件可以修改? » 2024-01-17 21:59:02

huaixupeng 说:
哇酷小二 说:

DragonFace V4.1.0 或者以后的版本应该可以。

我必应、谷歌、duckduckgo,全都找了,就是找不到。:(  sad

链接: https://pan.baidu.com/s/12d_495y_8UIK5p2hLBh_fA?pwd=face
提取码:face


v4.1.5:dragonface_v4.1.5.7z

#176 Re: 全志 SOC » f1c100s+4.3寸lcd(480x272)的tf卡固件 » 2024-01-08 17:06:32

感谢@晕哥邀请和测试,发布一个widora tiny200 480x272 5寸电阻屏TF卡固件, 开机跑 emwin,账号root,无密码
https://whycan.com/t_3206.html


分享一个 5寸的 800x480 的 f1c100s 固件, 感谢 @xm1994,   调试串口UART0 (PB8/PB9)
https://whycan.com/t_2689.html

#178 Re: 全志 SOC » 把mp4格式的h.264视频文件解码成NV12格式, 并使用VLC播放 / V3s 摄像头录制成NV12原始数据 » 2020-12-19 19:28:55

linux3.4 bsp linux 摄像头NV12格式原始视频格式数据采集源码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <getopt.h>           
#include <fcntl.h>            
#include <unistd.h>
#include <errno.h>
#include <malloc.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
 
#include <asm/types.h>        
#include <linux/videodev2.h>

#define BUF_NUM                         4
#define FRAMESINBUF                     1

struct CJ_Buffer {
        void *memory;
        int length;
};

struct CJ_Buffer *gpV4l2Buf;
 
int gMemMapLen;

int file_fd;
char *dev_name = "/dev/video0";
int fd;


int getFullSize(int * full_w, int * full_h)
{
    struct v4l2_frmsizeenum size_enum;
    size_enum.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    size_enum.pixel_format = V4L2_PIX_FMT_NV12;
    size_enum.index = 0;
    if (-1 == ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &size_enum))
    {
        perror("VIDIOC_ENUM_FRAMESIZES failed");  
        return 0;   
    }
    
    *full_w = size_enum.discrete.width;
    *full_h = size_enum.discrete.height;

        printf("getFullSize: %dx%d\n", *full_w, *full_h);
    
    return 1;
}

int tryFmtSize(int *width, int *height)
{
    int ret = -1;
    struct v4l2_format fmt;

    printf("%dx%d", *width, *height);

    memset(&fmt, 0, sizeof(fmt));
    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    fmt.fmt.pix.width  = *width;
    fmt.fmt.pix.height = *height;

    //fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
    //fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
    //fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_H264;
    fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;

    fmt.fmt.pix.field = V4L2_FIELD_NONE;

    ret = ioctl(fd, VIDIOC_TRY_FMT, &fmt);
    if (ret < 0)
    {
        perror("VIDIOC_TRY_FMT failed");
        return ret;
    }

    // driver surpport this size
    *width = fmt.fmt.pix.width;
    *height = fmt.fmt.pix.height;

    return 0;
}

int setContrastValue(int value)
{
    int ret = -1;
    struct v4l2_control ctrl;

    ctrl.id = V4L2_CID_CONTRAST;
    ctrl.value = value;
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0) {
        perror("VIDIOC_S_CTRL failed");
    } else {
        printf("setContrastValue ok\n");
    }

    return ret;
}
int setBrightnessValue(int value)
{
    struct v4l2_control ctrl;
    int ret = -1;

    ctrl.id = V4L2_CID_BRIGHTNESS;
    ctrl.value = value;
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0) {
        perror("VIDIOC_S_CTRL failed");
    } else {
        printf("setBrightnessValue ok\n");
    }
    return ret;
}

int setSaturationValue(int value)
{
    struct v4l2_control ctrl;
    int ret = -1;

    ctrl.id = V4L2_CID_SATURATION;
    ctrl.value = value;
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0) {
        perror("VIDIOC_S_CTRL failed");
    } else {
        printf("setSaturationValue ok\n");
    }
    return ret;
}

int setSharpnessValue(int value)
{
    struct v4l2_control ctrl;
    int ret = -1;

    ctrl.id = V4L2_CID_SHARPNESS;
    ctrl.value = value;
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0) {
        perror("VIDIOC_S_CTRL failed");
    } else {
        printf("setSharpnessValue ok\n");
    }
    return ret;
}

int setHueValue(int value)
{
    struct v4l2_control ctrl;
    int ret = -1;

    ctrl.id = V4L2_CID_HUE;
    ctrl.value = value;
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0) {
        perror("VIDIOC_S_CTRL failed");
    } else {
        printf("setHueValue ok\n");
    }

    return ret;
}

int setHflip(int value)
{
    struct v4l2_control ctrl;
    int ret = -1;
    
    ctrl.id = V4L2_CID_HFLIP_THUMB;
    ctrl.value = value;
    printf("V4L2CameraDevice::setHflip value=%d\n", value);
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0)
    {
        //setSharpnessValue failed
        perror("setHflip thumb failed\n");
    }
    ctrl.id = V4L2_CID_HFLIP;
    ctrl.value = value;
    printf("V4L2CameraDevice::setHflip value=%d\n", value);
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0)
    {
        //setSharpnessValue failed
        perror("setHflip failed\n");
    }
    return ret;
}

int setVflip(int value)
{
    struct v4l2_control ctrl;
    int ret = -1;
    
    ctrl.id = V4L2_CID_VFLIP_THUMB;
    ctrl.value = value;
    printf("V4L2CameraDevice::setVflip value=%d\n", value);
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0)
    {
        //setSharpnessValue failed
        perror("setVflip thumb failed111\n");
    }
    ctrl.id = V4L2_CID_VFLIP;
    ctrl.value = value;
    printf("V4L2CameraDevice::setVflip value=%d\n", value);
    ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
    if (ret < 0)
    {
        //setSharpnessValue failed
        perror("setVflip failed111\n");
    }

    return ret;
}

int v4l2setCaptureParams(int framerate)
{
    printf("framerate=%d", framerate);
    int ret = -1;
    
    struct v4l2_streamparm params;
    params.parm.capture.timeperframe.numerator = 1;
    params.parm.capture.timeperframe.denominator = framerate;
    params.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    params.parm.capture.capturemode = V4L2_MODE_VIDEO;

    printf("VIDIOC_S_PARM mFrameRate: %d, capture mode: %d\n", framerate, params.parm.capture.capturemode);

    ret = ioctl(fd, VIDIOC_S_PARM, &params);
    if (ret < 0) {
        perror("VIDIOC_S_PARM failed");
    } else {
        printf("v4l2setCaptureParams ok\n");
    }

    return ret;
}

void v4l2SetVideoParams(int width, int height, int sub_w, int sub_h, unsigned int pix_fmt)
{
    struct v4l2_format format;

    printf("main:%dx%d, sub:%dx%d, pfmt: 0x%x\n", width, height, sub_w, sub_h, pix_fmt);
    memset(&format, 0, sizeof(format));
    format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    format.fmt.pix.width  = width;
    format.fmt.pix.height = height;
    //format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
    //format.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
    //format.fmt.pix.pixelformat = V4L2_PIX_FMT_H264;
    format.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
    format.fmt.pix.field = V4L2_FIELD_NONE;

    if ((sub_w > 0 && sub_w < width) && (sub_h > 0 && sub_h < height)) {
        struct v4l2_pix_format sub_fmt;
        memset(&sub_fmt, 0, sizeof(sub_fmt));
        format.fmt.pix.subchannel = &sub_fmt;
        format.fmt.pix.subchannel->width = sub_w;
        format.fmt.pix.subchannel->height = sub_h;
        format.fmt.pix.subchannel->pixelformat = pix_fmt;
        format.fmt.pix.subchannel->field = V4L2_FIELD_NONE;
        format.fmt.pix.subchannel->rot_angle = 0;
        printf("sub_w=%d, sub_h=%d\n", sub_w, sub_h);
    }

    if (ioctl(fd, VIDIOC_S_FMT, &format) < 0)
    {
        perror("VIDIOC_S_FMT failed");
        return;
    }

    return;
}

void initV4l2Buffer()
{
    gpV4l2Buf = (struct CJ_Buffer *)malloc(sizeof(struct CJ_Buffer) * BUF_NUM);
    if (gpV4l2Buf == NULL) {
        perror("alloc V4l2Buffer_tag error!!");
        return;
    }
    memset(gpV4l2Buf, 0, sizeof(struct CJ_Buffer) * BUF_NUM);
}

void setFramesInV4L2BufNum()
{
        unsigned int nFramesInBuf = FRAMESINBUF;
    printf("mFramesInV4l2buf=%u\n", FRAMESINBUF);
    if (ioctl (fd, VIDIOC_SET_NFRAME_BUF, &nFramesInBuf) < 0) {
        perror("VIDIOC_SET_NFRAME_BUF failed");
    }
}

int v4l2ReqBufs(int * buf_cnt)
{
    int ret = 0;
    struct v4l2_requestbuffers rb;

    printf("TO VIDIOC_REQBUFS count: %d\n", *buf_cnt);

    memset(&rb, 0, sizeof(rb));
    rb.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    rb.memory = V4L2_MEMORY_MMAP;
    rb.count  = *buf_cnt;

    ret = ioctl(fd, VIDIOC_REQBUFS, &rb);
    if (ret < 0)
    {
        perror("VIDIOC_REQBUFS failed");
        return ret;
    }

    *buf_cnt = rb.count;
    printf("VIDIOC_REQBUFS count: %d\n", *buf_cnt);

    return 1;
}

int v4l2QueryBuf()
{
        int i;
    int ret = 0;
    struct v4l2_buffer buf;

    for (i = 0; i < BUF_NUM; i++)
    {
        memset (&buf, 0, sizeof (struct v4l2_buffer));
        buf.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        buf.memory = V4L2_MEMORY_MMAP;
        buf.index  = i;

        ret = ioctl (fd, VIDIOC_QUERYBUF, &buf);
        if (ret < 0)
        {
            perror("VIDIOC_QUERYBUF failed");
            return ret;
        }

        gpV4l2Buf[i].memory = mmap(0, buf.length,
                                PROT_READ | PROT_WRITE, 
                                MAP_SHARED, 
                                fd, 
                                buf.m.offset);

                gMemMapLen = buf.length;
        printf("index: %d, mem: %x, len: %d, offset: %x\n", i, (int)gpV4l2Buf[i].memory, buf.length, buf.m.offset);
 
        if (gpV4l2Buf[i].memory == MAP_FAILED)
        {
            perror("mmap failed");
            return -1;
        }
        }

    for (i = 0; i < BUF_NUM; i++)
    {
        memset (&buf, 0, sizeof (struct v4l2_buffer));
        buf.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        buf.memory = V4L2_MEMORY_MMAP;
        buf.index  = i;
        // start with all buffers in queue
        ret = ioctl(fd, VIDIOC_QBUF, &buf);
        if (ret < 0)
        {
            perror("VIDIOC_QBUF failed");
            return ret;
        }
    }

    return 1;
}

int v4l2StartStreaming()
{
    int ret = 0;
    enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

    ret = ioctl (fd, VIDIOC_STREAMON, &type);
    if (ret < 0)
    {
        perror("VIDIOC_STREAMON failed");
        return ret;
    }

    return 1;
}

int v4l2StopStreaming()
{
    int ret = 0;
    enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

    ret = ioctl (fd, VIDIOC_STREAMOFF, &type);
    if (ret < 0)
    {
        perror("VIDIOC_STREAMOFF failed");
        return ret;
    }
    printf("V4L2Camera::v4l2StopStreaming ok\n");

    return 1;
}

int v4l2UnmapBuf()
{
        int i;
    int ret = 0;

    for (i = 0; i < BUF_NUM; i++)
    {
        ret = munmap(gpV4l2Buf[i].memory, gMemMapLen);
        if (ret < 0)
        {
            perror("munmap failed");
            return ret;
        }

        gpV4l2Buf[i].memory = NULL;
    }

    return 1;
}

int main (int argc,char ** argv)
{
        struct v4l2_capability cap;
        struct v4l2_format fmt;
        struct v4l2_pix_format sub_fmt;
        struct v4l2_requestbuffers req;
        struct v4l2_buffer buf; 
    struct v4l2_input inp;
        unsigned int i;
        enum v4l2_buf_type type;
        
        int width, height;
     
     
        fd = open(dev_name, O_RDWR | O_NONBLOCK, 0);

        ioctl (fd, VIDIOC_QUERYCAP, &cap);
        printf("Driver Name:%s\n Card Name:%s\n Bus info:%s\n\n", cap.driver, cap.card, cap.bus_info);
        printf("capabilities:%d\n", cap.capabilities);
        
    if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0 &&
                (cap.capabilities & V4L2_CAP_STREAMING) == 0) 
    {
        perror("cap capabilities format fail");  
        return -2 ;   
    }


    inp.index = 0;
    if (-1 == ioctl(fd, VIDIOC_S_INPUT, &inp))
    {
        perror("VIDIOC_S_INPUT error!");  
        return -2 ;   
    }
        
        getFullSize(&width, &height);
        
        width = 640; height = 480;
        /*tryFmtSize(&width, &height);
        setContrastValue(50);
        setBrightnessValue(50);
        setSaturationValue(0);
        setSharpnessValue(10);
        setHueValue(30);
        setHflip(0);
        setVflip(0);*/
        
        v4l2setCaptureParams(30);
        v4l2SetVideoParams(640, 480, 320, 240, V4L2_PIX_FMT_NV12);
        
        initV4l2Buffer();
        setFramesInV4L2BufNum();

    int buf_cnt = BUF_NUM;
    v4l2ReqBufs(&buf_cnt);
        
        v4l2QueryBuf();
        v4l2StartStreaming();
        
        //for (i = 0; i < 10; i++)
        //      sleep(1);

    //struct v4l2_control ctrl;

   // ctrl.id = V4L2_CID_TAKE_PICTURE;
    //if (ioctl(fd, VIDIOC_S_CTRL, &ctrl) < 0) {
  //      perror("VIDIOC_S_CTRL failed");
  //  } else {
  //      perror("setTakePictureCtrl ok\n");
 //   }
        
        
        FILE* fp = fopen("test2.nv12", "w");
        if(fp == NULL)
        {
                printf("open file error.\n");
                goto end;
        }

        for (i = 0; i < 200; i++)
        {
                fd_set fds;

                FD_ZERO(&fds);
                FD_SET(fd, &fds);

                select(fd + 1, &fds, NULL, NULL, NULL);

            memset(&buf, 0, sizeof(struct v4l2_buffer));
                buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
                buf.memory = V4L2_MEMORY_MMAP;
                ioctl(fd, VIDIOC_DQBUF, &buf);

            void *pMem = gpV4l2Buf[buf.index].memory;
                printf("frame addr = %x, length=%d, %d\n", (unsigned int)pMem, gpV4l2Buf[buf.index].length, buf.length);

                fwrite(pMem, 640 * 480 * 3 / 2, 1, fp);
#if 0
                if (i == 199)
                {
                        file_fd = open("test.jpg", O_RDWR | O_CREAT, 0777);
                        write(file_fd, pMem, 640 * 480 * 3 / 2);
                        close (file_fd);
                        printf("frame index = %d, size = %d.\n", buf.index, buf.length);
                }
#endif
                ioctl(fd, VIDIOC_QBUF, &buf);
        }

end:
        fclose(fp);     
        v4l2StopStreaming();
        v4l2UnmapBuf();
        

        close (fd);
        printf("Camera Done.\n");


        return 0;
}

b5fdce65aa04d77f1066453a0468ffe8.png

1a3b4bb98783a39ad0c052ba7c25e45f.png

NV12录像文件下载: nv12_data.7z

#179 Re: 全志 SOC » V3s/S3/f1c100s通过USB启动Linux,并把SD NAND/TF卡挂载为U盘, 可以dd或Win32DiskImager任烧写 » 2020-09-21 22:10:18

启动之后无法挂载sd nand到pc   看不到是哪的问题  能帮忙分析一下嘛 信息

usb id引脚在dts是怎么配置的?

#180 Re: 全志 SOC » 小智科技X3卡片电脑,仅有银行卡一半大,像艺术品般的硬件,多图慎入~ (开放购买) » 2020-05-28 12:21:16

小智科技 说:

论坛好久没见到晕哥出现,谢谢晕哥的支持,我还以为晕哥改名哇酷小二了哈哈~

说来话长,由于挖坑不填,吹牛不干活,被老板禁言了。

#182 Re: 全志 SOC » 编译、安装Windows版本sunxi-fel步骤 (32M spi flash补丁,支持W25Q256/MX25L256) » 2020-04-26 10:07:16

提示什么错误吗?
写一个小一点的文件(如u-boot), 然后读出来看对不对.

#183 Re: 全志 SOC » 荔枝派zero 系统 » 2020-04-23 10:08:00

上面2楼那个固件我记得是有以太网的,你先试一试。

#184 Re: 全志 SOC » V3s licheepi板子启动失败, jffs2: jffs2_scan_eraseblock():Magic bitmask 0x198 » 2020-04-22 23:31:59

ifree64 说:

是要取消这个选项吗?我去试试,谢谢!

对的, 你先取消这个选项试一试.

#186 Re: 全志 SOC » 第一次画全志的板子F1C200S,明天发板 » 2020-04-22 22:32:08

pcb_diy 说:

想请问下晕哥,以前只有STM32基础。如何切换到这个F1C100S跑LINUX的学习上来?论坛有没有入门级的资料供我这种初学者学习?

这个教程不错: https://whycan.cn/t_3138.html

#189 Re: 全志 SOC » @assert 修改后的 f1c100s u-boot 开源了, 可以引导bsp linux » 2020-04-22 19:10:28

wammaw1314 说:

收藏本帖,目前正在新增使用spi nand flash,启动引导主线Linux 4.19,各种学习中。。。

这个帖子更有参考价值: https://whycan.cn/t_3123.html

#190 Re: 全志 SOC » F1C100S裸跑Fatfs » 2020-04-22 17:40:35

wukenaihe 说:

配置sunxi-fel工具出现了如下问题:
fel.c:32:18: fatal error: zlib.h: 没有那个文件或目录
compilation terminated.
fel_lib.c:26:20: fatal error: libusb.h: 没有那个文件或目录
这个怎么破

https://whycan.cn/t_444.html

#193 Re: 全志 SOC » F1C200S入坑手记 » 2020-04-21 20:27:28

Blueskull 说:

Don't really want to necropost on the old thread. PM me with your email and I can send it to you directly.

BTW, I believe posting at least 3 posts here should grant you download privilege. Don't quote on me.

大神神速,现在涨到7个了,笑哭.gif

#194 Re: 全志 SOC » F1C200S入坑手记 » 2020-04-21 20:26:01

认真回复7个帖子,可以解锁下载权限

Seriously reply to 7 posts, you can unlock the download rights

Thanks.

#195 Re: 全志 SOC » 感谢 widora @mango 友情赠送的精致小巧TINY200开发板套件, 主控全志 F1C200s » 2020-04-20 17:38:08

xingjxuan 说:

晕哥。。。这个板子是不是不能用PhoenixSuit来烧写

对 这个烧录方法和sdk不同。

#196 Re: 站务公告/网站建设 » 感觉最近帖子变水了? » 2020-04-20 17:15:55

jiangming1399 说:

其实我个人是觉得,没有意义的回帖还不如不回……主要是我会定期看我被回复的贴子,要是水占大部分的话那就纯粹是浪费时间了

嗯嗯,大部分无意义的回复我都删了。

以后加入新用户审帖功能,尽管水,只要审核不通过都不会显示。

#197 Re: 站务公告/网站建设 » 感觉最近帖子变水了? » 2020-04-20 15:03:24

达克罗德 说:

精华帖可以加多点积分,然后按分数搞个等级勋章啥的,增加荣誉感,鼓励发帖

嗯嗯,小本本记下来了。

#198 Re: 站务公告/网站建设 » 感觉最近帖子变水了? » 2020-04-20 14:57:00

达克罗德 说:

好像是满多少积分才能下载了

七分。好像不是很多,认真回复几句骚话就解决了。

#199 Re: 站务公告/网站建设 » 感觉最近帖子变水了? » 2020-04-20 14:50:37

嗯,每天下载3G左右,但是跟帖很少,所以稍改了一点点规则,

七分解锁下载权限,当时考虑到可能会水一波,只是没想到这么水,笑哭.gif

#200 Re: 全志 SOC » 分享自制的使用USB网卡的F1C200S开发板 » 2020-04-20 13:41:33

asdfwyg 说:

老大有没有用过rtl8189这种sdio的模块呢,这个稳定性怎么样

螃蟹的 RTL8723BS sdio网卡玩过 ,貌似不是很稳定,连linux驱动都在stating目录。

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn