4.4 海思SS928开发 - uboot开发 - 构建脚本

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,打印帮助。
  • 27
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

专注的罗哈哈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值