1#!/bin/bash 2# 3# Copyright (c) 2020 Rockchip Electronics Co., Ltd 4# 5# SPDX-License-Identifier: GPL-2.0 6# 7 8set -e 9 10if [ $# -eq 0 ]; then 11 echo "ERROR: No args of $0" 12 exit 1 13fi 14 15while [ $# -gt 0 ]; do 16 case $1 in 17 --load) 18 LOAD_ADDR=$2 19 shift 2 20 ;; 21 --size) 22 SIZE="$1 $2 $3" 23 shift 3 24 ;; 25 *) 26 echo "ERROR: Unknown arg: $1" 27 exit 1 28 ;; 29 esac 30done 31 32rm uboot.img -f 33 34if [ -z "${LOAD_ADDR}" ]; then 35 echo "ERROR: No load address" 36 exit 1 37fi 38 39HEAD_KB=2 40BIN_KB=`ls -l u-boot.bin | awk '{ print $5 }'` 41if [ -z "${SIZE}" ]; then 42 MAX_KB=1046528 43else 44 MAX_KB=`echo ${SIZE} | awk '{print strtonum($2)}'` 45 MAX_KB=$(((MAX_KB-HEAD_KB)*1024)) 46fi 47 48if [ ${BIN_KB} -gt ${MAX_KB} ]; then 49 echo "ERROR: pack uboot failed! u-boot.bin actual: ${BIN_KB} bytes, max limit: ${MAX_KB} bytes" 50 exit 1 51fi 52 53../rkbin/tools/loaderimage --pack --uboot u-boot.bin uboot.img ${LOAD_ADDR} ${SIZE} 54echo "pack uboot okay! Input: u-boot.bin" 55echo 56