RP-PX30平台编译和原始的原厂编译还是有点不一样的,贴上make.sh
#!/bin/bash
MAKE_THEARD=`cat /proc/cpuinfo | grep "processor" | wc -l` #获得主机CPU线程数量
MAKE_TOTAL=`cat /proc/meminfo | grep "MemTotal" | tr -cd "[0-9]"` #获得内存大小 按KB 算
MAKE_MEM=` expr $MAKE_TOTAL / 1048576` #内存字节数除以1048576 获得多少个G 的内存
#echo $MAKE_MEM
jvm_set_mem()# jvm 设置内存函数 设置 JACK_SERVER_VM_ARGUMENTS 并给出警告,小于8G内存不能编译
{
if [ $MAKE_MEM -gt 32 ] #如果内存大于32G
then
{
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx32768m"
}
elif [ $MAKE_MEM -gt 16 ]
then
{
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx16384m"
}
elif [ $MAKE_MEM -gt 8 ]
then
{
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx8192m"
}
elif [ $MAKE_MEM -ge 6 ]
then
{
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
}
else
echo "/***************************************************/"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "memory less than 7GB, can not compile"
echo "/***************************************************/"
exit 1
fi
#./prebuilts/sdk/tools/jack-admin start-server
}
path_set()# 设置JDK路径 的 函数 source 一下编译环境envsetup.sh lunch 为 rk3326_evb-userdebug
{
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
source build/envsetup.sh
lunch rk3326_evb-userdebug
}
if [ $1 == "clean" ]#如果第一个参数是 clean, 比如make.sh clean
then
{
if [ $2 == "u-boot" -o $2 == "u-boot/" -o $2 == "uboot" ]#怕你多打少打,让你兼容一下
then
{
echo make clean u-boot
pushd u-boot/
make distclean
popd
pushd linux_update/rockdev/
rm MiniLoaderAll.bin
popd
pushd linux_update/rockdev/Image/
rm trust.img uboot.img
popd
}
elif [ $2 == "kernel" -o $2 == "kernel/" ]#怕你多打少打,让你兼容一下
then
{
echo make clean kernel
pushd kernel/
make clean
popd
pushd linux_update/rockdev/Image/
rm kernel.img resource.img
popd
}
elif [ $2 == "android" -o $2 == "android/" ]#怕你多打少打,让你兼容一下
then
{
echo make clean android
path_set
make clean
pushd linux_update/rockdev/Image/
rm misc.img boot.img recovery.img system.img
popd
rm out -rf
}
else#如果你执行./make.sh clean 那全干掉
{
echo make clean u-boot
pushd u-boot/
make distclean
popd
echo make clean kernel
pushd kernel/
make clean
popd
echo make clean android
path_set
make clean
rm out -rf
pushd rockdev/Image-rk3326_evb/
rm *.img
popd
popd linux_update/rockdev/
rm MiniLoaderAll.bin update.img
popd
pushd linux_update/rockdev/Image/
rm kernel.img resource.img misc.img boot.img recovery.img system.img update.img trust.img uboot.img
popd
echo clean Img oK
}
fi
}
elif [ $1 == "u-boot" -o $1 == "u-boot/" -o $1 == "uboot" ]#如果是执行uboot编译
then
{
pushd u-boot/
make mrproper #清配置,清编译文件
./make.sh evb-px30 -j8 #编译, 这里怎么把线程加进去了,这如果是4线程的CPU呢
if [ $? -eq 0 ]; then #如果编译没报错
echo "Build uboot ok!"
else
echo "Build uboot failed!"
exit 1
fi
popd
}
elif [ $1 == "kernel" -o $1 == "kernel/" ] #如果是执行内核编译
then
{
pushd kernel/
if [ ! -e .config ]; then #如果没有配置文件,加载默认配置文件
make ARCH=arm64 rpdzkj_px30_defconfig
fi
make ARCH=arm64 rp-px30.img -j$MAKE_THEARD #多线程编译
#make ARCH=arm64 px30-evb-ddr3-v10.img -j8
if [ $? -eq 0 ]; then #如果编译没报错
echo "Build kernel ok!"
else
echo "Build kernel failed!"
exit 1
fi
popd
cp kernel/resource.img rockdev/Image-rk3326_evb/
cp kernel/kernel.img rockdev/Image-rk3326_evb/
#path_set
#./mkimage.sh
}
elif [ $1 == "android" -o $1 == "android/" ] #如果编译安卓
then
{
jvm_set_mem #配置java 参数
path_set #配置java路径
make -j $MAKE_THEARD #多线程编译
if [ $? -eq 0 ]; then #如果编译没有报错
echo "Build android ok!"
else
echo "Build android failed!"
exit 1
fi
cp kernel/drivers/net/wireless/rockchip_wlan/rtl8723bu/wlan.ko out/target/product/rk3326_evb/vendor/lib/modules/wifi/8723bu.ko
./mkimage.sh
}
elif [ $1 == "ota" ] #如果编译OTA
then
{
path_set
./mkimage.sh ota
}
else #如果只执行 ./make.sh 那么全部编译到底
{
pushd u-boot/
make mrproper
./make.sh evb-px30 -j8
if [ $? -eq 0 ]; then
echo "Build uboot ok!"
else
echo "Build uboot failed!"
exit 1
fi
popd
pushd kernel/
if [ ! -e .config ]; then
make ARCH=arm64 rpdzkj_px30_defconfig
fi
make ARCH=arm64 rp-px30.img -j $MAKE_THEARD
#make ARCH=arm64 px30-evb-ddr3-v10.img -j8
if [ $? -eq 0 ]; then
echo "Build kernel ok!"
else
echo "Build kernel failed!"
exit 1
fi
popd
jvm_set_mem
path_set
make -j $MAKE_THEARD
if [ $? -eq 0 ]; then
echo "Build android ok!"
else
echo "Build android failed!"
exit 1
fi
cp kernel/drivers/net/wireless/rockchip_wlan/rtl8723bu/wlan.ko out/target/product/rk3326_evb/vendor/lib/modules/wifi/8723bu.ko
./mkimage.sh
. rpupdate.sh #生成update.img
}
fi
TE_ET 发布了15 篇原创文章 · 获赞 1 · 访问量 2829 私信 关注