post-image.sh

c 复制代码
#!/usr/bin/env bash

set -e 

VERSION=$1

TOP_PATH=$(pwd)/..
CHIP_GROUP=${CHIP_NAME:0:5}X
PROJECT_PATH=$TOP_PATH/build/projects/$PROJECT

XML_FILE=$TOP_PATH/build/projects/$PROJECT/axp.xml

IMG_PATH=$TOP_PATH/build/out/$PROJECT/
TOOL_PATH=$TOP_PATH/tools/mkaxp/make_axp.py
VERSION_EXT=${VERSION}_$(date "+%Y%m%d%H%M%S")
AXP_FILE=$TOP_PATH/build/out/${PROJECT}_${VERSION_EXT}.axp

CMM_POOL_PARAM=anonymous,0,0x50000000,240M

FS_TYPE=ubifs

rm -rf $IMG_PATH/rootfs_opt
rm -rf $IMG_PATH/rootfs_soc
rm -rf $IMG_PATH/rootfs_without_soc_opt
rm -rf $IMG_PATH/rootfs_with_soc_opt
rm -rf $IMG_PATH/rootfs
	
	# rootfs_without_soc_opt
mkdir -p $IMG_PATH/rootfs_without_soc_opt
cp -rfp $TOP_PATH/rootfs/rootfs/* $IMG_PATH/rootfs_without_soc_opt/
rm -rf $IMG_PATH/rootfs_without_soc_opt/lib/modules
rm -rf $IMG_PATH/rootfs_without_soc_opt/soc
rm -rf $IMG_PATH/rootfs_without_soc_opt/opt

	# rootfs_soc
mkdir -p $IMG_PATH/rootfs_soc
mkdir -p $IMG_PATH/rootfs_soc/bin
mkdir -p $IMG_PATH/rootfs_soc/lib
cp -rf $TOP_PATH/kernel/osdrv/out/ko $IMG_PATH/rootfs_soc
cp -rf $TOP_PATH/msp/out/lib/*.so* $IMG_PATH/rootfs_soc/lib
cp -rf $TOP_PATH/rootfs/rootfs/opt/scripts $IMG_PATH/rootfs_soc/
rm -rf $IMG_PATH/rootfs_soc/lib/libmcvsdk_*.so
rm -rf $IMG_PATH/rootfs_soc/lib/libmegsearch.so
rm -rf $IMG_PATH/rootfs_soc/lib/libsns*.so*
rm -rf $IMG_PATH/rootfs_soc/lib/libact_dummy.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_eis.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_audio_3a.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_audio.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_channel.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_cipher.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_detect.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_eis.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_event_mediarecord.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_ives.so
rm -rf $IMG_PATH/rootfs_soc/lib/libax_vdec.so
rm -rf $IMG_PATH/rootfs_soc/lib/liblens_dciris.so

#cp -rf $TOP_PATH/msp/out/lib/libsns_ov2775.so $IMG_PATH/rootfs_soc/lib
cp -rf $TOP_PATH/msp/out/lib/libsns_ox02d10.so $IMG_PATH/rootfs_soc/lib

	# rootfs_opt
rm -rf $IMG_PATH/rootfs_opt
mkdir -p $IMG_PATH/rootfs_opt
cp -rfp $TOP_PATH/rootfs/rootfs/opt/* $IMG_PATH/rootfs_opt/

mkdir -p $IMG_PATH/rootfs_opt/ko
cp -rfp $TOP_PATH/rootfs/rootfs/lib/modules/4.19.125/kernel/* $IMG_PATH/rootfs_opt/ko
# remove unused kernel ko
DIRS=(`ls $IMG_PATH/rootfs_opt/ko`)
for((i=0; i<${#DIRS[@]}; i++))
do
    if [ "${DIRS[i]}" != "drivers"  ]; then
        rm -rf $IMG_PATH/rootfs_opt/ko/${DIRS[i]}
    fi
    SUBDIRS=(`ls $IMG_PATH/rootfs_opt/ko/drivers`)
    for((j=0; j<${#SUBDIRS[@]}; j++))
    do
        if [ "${SUBDIRS[j]}" != "usb" ] && [ "${SUBDIRS[j]}" != "uio"  ]; then
            rm -rf $IMG_PATH/rootfs_opt/ko/drivers/${SUBDIRS[j]}
        fi
    done
done

rm -rf $IMG_PATH/rootfs_opt/etc/*
rm -rf $IMG_PATH/rootfs_opt/lib/*
rm -rf $IMG_PATH/rootfs_opt/scripts/*
rm -rf $IMG_PATH/rootfs_opt/data/*
rm -rf $IMG_PATH/rootfs_opt/bin/*

cp -rf $TOP_PATH/app/IPCDemo/bin/ $IMG_PATH/rootfs_opt/bin/IPCDemo/
cp -rf $TOP_PATH/msp/out/bin/sample_uvc $IMG_PATH/rootfs_opt/bin/
#cp -rf $TOP_PATH/msp/out/etc/ov2775*.pro $IMG_PATH/rootfs_opt/etc/
#cp -rf $TOP_PATH/msp/out/etc/ov2775*.ini $IMG_PATH/rootfs_opt/etc/
cp -rf $TOP_PATH/msp/out/etc/ox02d10*.pro $IMG_PATH/rootfs_opt/etc/
cp -rf $TOP_PATH/msp/out/etc/ox02d10*.ini $IMG_PATH/rootfs_opt/etc/
cp -rf $TOP_PATH/msp/out/bin/tuning-server $IMG_PATH/rootfs_opt/bin/
cp -rf $TOP_PATH/msp/out/bin/dump_tools $IMG_PATH/rootfs_opt/bin/

mv $IMG_PATH/rootfs_without_soc_opt $IMG_PATH/rootfs_with_soc_opt
mv $IMG_PATH/rootfs_opt $IMG_PATH/rootfs_with_soc_opt/opt
mv $IMG_PATH/rootfs_soc $IMG_PATH/rootfs_with_soc_opt/soc
mkdir -p $IMG_PATH/rootfs_with_soc_opt/opt/data/AXSyslog/kernel
rm -rf $IMG_PATH/rootfs_with_soc_opt/opt/ko/*.ko

if [[ -d $PROJECT_PATH/rootfs_overlay ]]; then
	cp -rpf $PROJECT_PATH/rootfs_overlay/* $IMG_PATH/rootfs_with_soc_opt/
fi
	
sed -i "s/cmmpool*=.*/cmmpool=${CMM_POOL_PARAM}/g" $IMG_PATH/rootfs_with_soc_opt/soc/scripts/auto_load_pre_drv.sh

if [[ "$FS_TYPE" == "ubifs" ]]; then
	cp -f $PROJECT_PATH/ubinize.cfg $IMG_PATH/

	cp -f $PROJECT_PATH/fstab_ubifs $IMG_PATH/rootfs_with_soc_opt/etc/fstab

	mv $IMG_PATH/rootfs_with_soc_opt/soc $IMG_PATH/rootfs_soc
	mv $IMG_PATH/rootfs_with_soc_opt/opt $IMG_PATH/rootfs_opt
	mv $IMG_PATH/rootfs_with_soc_opt $IMG_PATH/rootfs_without_soc_opt
	mkdir -p $IMG_PATH/rootfs_without_soc_opt/opt
	mkdir -p $IMG_PATH/rootfs_without_soc_opt/soc

	$TOP_PATH/tools/mkubifs/mkfs.ubifs -F -q -r $IMG_PATH/rootfs_soc -m 2048 -e 126976 -c 2047 -o $IMG_PATH/rootfs_soc.img
	$TOP_PATH/tools/mkubifs/mkfs.ubifs -F -q -r $IMG_PATH/rootfs_opt -m 2048 -e 126976 -c 2047 -o $IMG_PATH/rootfs_opt.img
	$TOP_PATH/tools/mkubifs/mkfs.ubifs -F -q -r $IMG_PATH/rootfs_without_soc_opt -m 2048 -e 126976 -c 2047 -o $IMG_PATH/rootfs_without_soc_opt.img

	cd $IMG_PATH
	$TOP_PATH/tools/mkubifs/ubinize -o $IMG_PATH/rootfs_with_soc_opt.img -m 2048 -p 128KiB ubinize.cfg
	cd -

	ROOTFS_PATH=$IMG_PATH/rootfs_with_soc_opt.img

elif [[ "$FS_TYPE" == "squashfs" ]]; then
	# squashfs

	rm -rf $IMG_PATH/rootfs.img
	rm -rf $IMG_PATH/rootfs
	mv $IMG_PATH/rootfs_with_soc_opt $IMG_PATH/rootfs
	cp -f $PROJECT_PATH/fstab_squashfs $IMG_PATH/rootfs/etc/fstab

	#rm -rf $IMG_PATH/rootfs/etc/inittab
	#rm -rf $IMG_PATH/rootfs/etc/fstab
	#rm -rf $IMG_PATH/rootfs/etc/init.d/*
	#rm -rf $IMG_PATH/rootfs/lib/modules
	#rm -rf $IMG_PATH/rootfs/usr/lib
	#rm -rf $IMG_PATH/rootfs/usr/lib32
	#rm -rf $IMG_PATH/rootfs/usr/local
	#rm -rf $IMG_PATH/rootfs/usr/sbin
	#rm -rf $IMG_PATH/rootfs/usr/share

	#cp -rfp $TOP_PATH/rootfs/rootfs/usr/sbin/lrz $IMG_PATH/rootfs/bin/
	#cp -rfp $TOP_PATH/rootfs/rootfs/usr/sbin/lsz $IMG_PATH/rootfs/bin/
	#rm -rf $IMG_PATH/rootfs/opt/*

	mksquashfs $IMG_PATH/rootfs/ $IMG_PATH/rootfs.img
	ROOTFS_PATH=$IMG_PATH/rootfs.img
else
	echo "Not Support $FS_TYPE filesystem NOW!"
fi

DTB_PATH=$IMG_PATH/${PROJECT}.dtb
EIP_PATH=$IMG_PATH/eip.bin
FDL1_PATH=$IMG_PATH/fdl_${PROJECT}_signed.bin
FDL2_PATH=$IMG_PATH/fdl2_signed.bin
UBOOT_PATH=$IMG_PATH/u-boot_signed.bin
KERNEL_PATH=$IMG_PATH/uImage
SPL_PATH=$IMG_PATH/spl_${PROJECT}_signed.bin


python3 $TOOL_PATH -p $CHIP_GROUP -v $VERSION_EXT -x $XML_FILE -o $AXP_FILE $EIP_PATH $FDL1_PATH $FDL2_PATH $UBOOT_PATH $DTB_PATH $KERNEL_PATH $ROOTFS_PATH $SPL_PATH
相关推荐
矛取矛求3 小时前
Linux如何更优质调节系统性能
linux
内核程序员kevin4 小时前
在Linux环境下使用Docker打包和发布.NET程序并配合MySQL部署
linux·mysql·docker·.net
kayotin4 小时前
Wordpress博客配置2024
linux·mysql·docker
Ztiddler5 小时前
【Linux Shell命令-不定期更新】
linux·运维·服务器·ssh
小小不董5 小时前
Oracle OCP认证考试考点详解082系列16
linux·运维·服务器·数据库·oracle·dba
a1denzzz5 小时前
Linux系统的网络设置
linux·服务器·网络
ac.char6 小时前
在CentOS下安装RabbitMQ
linux·centos·rabbitmq
m0_519523106 小时前
Linux——简单认识vim、gcc以及make/Makefile
linux·运维·vim
mit6.8247 小时前
[Docker#4] 镜像仓库 | 部分常用命令
linux·运维·docker·容器·架构
zyp2468107 小时前
Linux之DNS服务器
linux·运维·服务器