开始编译

注意:在编译前请确定Ubuntu,shell工具是否为bash,防止出现-e错误。
1、查看sh默认选项

ls -l /bin/sh

2、切换sh为bash

sudo dpkg-reconfigure dash

然后选择NO,可以解决脚本编译-e的问题


可以看到Release_to_customer.sh脚本执行时需要传递3个参数(-f、-p、-q);

  • -f 表示flash的类型,可选nand、nor;
  • -p 表示芯片型号,可选ssd201、ssd202;
  • -q 表示快速启动模式,可选fastboot或空;

while getopts "f:p:q:" opt; do
  case $opt in
    f)
      flashtype=$OPTARG
      ;;
    p)
      project=$OPTARG
      ;;
    q)
      fastboot=$OPTARG
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      ;;
  esac
done

这里以nand+ssd201为例,开始编译源码:

# ./Release_to_customer.sh -f nand -p ssd201

编译完成后,将在images目录下生成系统镜像,接着我们就可以通过第三章的操作将这些镜像烧录到芯片中。

在编译过一次后,如果不换芯片型号,可以把Release_to_customer.sh中uboot和kernel的makeclean注释。
脚本代码如下:

#!/bin/bash

while getopts "f:p:q:" opt; do
  case $opt in
    f)
      flashtype=$OPTARG
      ;;
    p)
      project=$OPTARG
      ;;
    q)
      fastboot=$OPTARG
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      ;;
  esac
done

DATE=$(date +%m%d)
#RELEASEDIR=ReleaseToCus_${DATE}
#images will output in ${RELEASEDIR}/images/
RELEASEDIR=/home/ronnie/work3/ssd201
#release source code
#find ./boot/ | grep -v boot/.git | cpio -pdm ${RELEASEDIR}/
#find ./project/ | grep -v project/.git | cpio -pdm ${RELEASEDIR}/
#find ./kernel/ | grep -v kernel/.git | cpio -pdm ${RELEASEDIR}/
#find ./sdk/ | grep sdk/verify | grep -v sdk/verify/application/smarttalk | cpio -pdm ${RELEASEDIR}/

#save code version
#repo manifest -o snapshot.xml -r
#cp snapshot.xml ${RELEASEDIR}/sdk_version.xml

export ARCH=arm

echo chose ${flashtype}

# build uboot
cd ${RELEASEDIR}/u-boot-2015.01
declare -x ARCH="arm"
declare -x CROSS_COMPILE="arm-linux-gnueabihf-"
if [ "${flashtype}" = "nor" ]; then
    make infinity2m_defconfig
else
    make infinity2m_spinand_defconfig
fi
#make clean
make -j16

if [ "${flashtype}" = "nor" ]; then
    if [ -d ../project/board/i2m/boot/nor/uboot ]; then
        cp u-boot.xz.img.bin ../project/board/i2m/boot/nor/uboot
    fi
else
    if [ -d ../project/board/i2m/boot/spinand/uboot ]; then
        cp u-boot_spinand.xz.img.bin ../project/board/i2m/boot/spinand/uboot/
    fi
fi

#build kernel
cd ${RELEASEDIR}/linux-4.9.84
declare -x ARCH="arm"
declare -x CROSS_COMPILE="arm-linux-gnueabihf-"
if [ "${flashtype}" = "nor" ]; then
    if [ "${fastboot}" = "fastboot" ]; then
        make infinity2m_ssc011a_s01a_fastboot_defconfig
    else
        make infinity2m_ssc011a_s01a_minigui_defconfig
    fi

else
    if [ "${fastboot}" = "fastboot" ]; then
        echo fast kernel
        make infinity2m_spinand_ssc011a_s01a_minigui_fastboot_defconfig
    else
        make infinity2m_spinand_ssc011a_s01a_minigui_defconfig
    fi

fi
#make clean
make -j16

#build project
cd ${RELEASEDIR}/project
if [ "${flashtype}" = "nor" ]; then
    if [ "${fastboot}" = "fastboot" ]; then
        echo test fastboot
        ./setup_config.sh ./configs/nvr/i2m/8.2.1/nor.glibc-ramfs.011a.64
    else
        if [ "${project}" = "ssd201" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/nor.glibc-squashfs.011a.64
        fi
        if [ "${project}" = "ssd202" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/nor.glibc-squashfs.011a.128
        fi
    fi
else
    if [ "${fastboot}" = "fastboot" ]; then
        echo fast project
        if [ "${project}" = "ssd201" ]; then 
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.ram-glibc-squashfs.011a.64
        elif [ "${project}" = "ssd202" ]; then    
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.ram-glibc-squashfs.011a.128
        fi
    else
        if [ "${project}" = "ssd201" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.glibc.011a.64
        fi
        if [ "${project}" = "ssd202" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.glibc.011a.128
        fi
    fi

fi

cd ${RELEASEDIR}/project/kbuild/4.9.84
if [ "${flashtype}" = "nor" ]; then
    if [ "${fastboot}" = "fastboot" ]; then
        ./release.sh -k ${RELEASEDIR}/linux-4.9.84 -b 011A-fastboot -p nvr -f nor -c i2m -l glibc -v 8.2.1
    else
        ./release.sh -k ${RELEASEDIR}/linux-4.9.84 -b 011A -p nvr -f nor -c i2m -l glibc -v 8.2.1
    fi
else
    if [ "${fastboot}" = "fastboot" ]; then
        echo fast release
        ./release.sh -k ${RELEASEDIR}/linux-4.9.84 -b 011A-fastboot -p nvr -f spinand -c i2m -l glibc -v 8.2.1
    else
        ./release.sh -k ${RELEASEDIR}/linux-4.9.84 -b 011A -p nvr -f spinand -c i2m -l glibc -v 8.2.1
    fi

fi

cd ${RELEASEDIR}/project
make clean;make image-nocheck

#install Image
cd ${RELEASEDIR}
rm -rf ${RELEASEDIR}/images
cp ${RELEASEDIR}/project/image/output/images . -rf

#tar -cvzf boot_${DATE}.tar.gz boot
#tar -cvzf kernel_${DATE}.tar.gz kernel
#tar -cvzf project_${DATE}.tar.gz project
#tar -cvzf sdk_${DATE}.tar.gz sdk


文档更新时间: 2021-02-22 15:37   作者:Aeeditor