4.4 uboot开发 - 构建脚本
- SS928 uboot 提供了 makefile 用于 uboot 构建。
- 想要得到最后的非安全启动镜像,还要经过许多步骤,每次都手敲命令的话,会把我累死。
- 自己实现一个构建脚本,支持以下常用功能即可:
- 构建非安全启动镜像
- 配置 uboot
- 清理所有的编译产物
构建脚本
-
创建脚本:
cd ~/hiss928/uboot/ss928_uboot_v2020.1/ touch build.sh chmod a+x build.sh
-
脚本内容如下:
#!/bin/bash CUR_PATH=$(pwd) # 编译产物输出目录 OUTPUT_PATH=$(pwd)/output HI_ARCH=arm # 默认使用的配置文件 HI_DEFCONFIG=ss928v100_emmc # 使用的工具链 TOOLCHAIN_PREFIX=aarch64-mix210-linux- print_help() { echo "Usage: $0 [OTIONS] COMMAND" echo "" echo "Options:" echo " -h show this message and exit" echo "" echo "Commands:" echo " -m show menuconfig" echo " -c clean all" } build_unsafe_boot_img() { echo "============Start build unsafe boot img============" echo "ARCH = ${HI_ARCH}" echo "CONFIG = ${HI_DEFCONFIG}_defconfig" echo "==========================================" # 编译 uboot make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} ${HI_DEFCONFIG}_defconfig make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j16 make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} u-boot-z.bin # 拷贝制作非安全启动镜像需要的文件 cp -f gsl.loader image_map/gsl.bin cp -f u-boot-ss928v100.bin image_map/u-boot-original.bin cp -f ss928.reg image_map/.reg # 制作非安全启动镜像 pushd image_map python3 oem/oem_quick_build.py popd # 拷贝非安全启动镜像至 output 目录 test -d ${OUTPUT_PATH} || mkdir -p ${OUTPUT_PATH} cp -f image_map/image/oem/boot_image.bin ${OUTPUT_PATH}/boot_image.bin } if [ "$1" == "-h" ]; then print_help $0 exit 0 fi # 清除所有编译生成的产物 if [ "$1" == "-c" ]; then if [ -f u-boot.bin ]; then make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} u-boot-z.clean fi make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} distclean rm -rf image_map/image rm -rf image_map/oem/tmp rm -rf image_map/.reg image_map/gsl.bin image_map/u-boot-original.bin rm -rf output exit 0 fi # 进入 uboot 图形配置界面 if [ "$1" == "-m" ]; then make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} ${HI_DEFCONFIG}_defconfig make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} menuconfig make ARCH=${HI_ARCH} CROSS_COMPILE=${TOOLCHAIN_PREFIX} savedefconfig cp defconfig configs/${HI_DEFCONFIG}_defconfig exit 0 fi build_unsafe_boot_img
使用方法
./build.sh
,构建非安全启动镜像,输出产物默认放入目录output
。./build.sh -m
,进入menuconfig
,默认会保存更改后的配置。./build.sh -c
,清除所有编译产物。./build.sh -h
,打印帮助。