xref: /OK3568_Linux_fs/u-boot/scripts/fit-msg.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/bash
2#
3# Copyright (c) 2020 Rockchip Electronics Co., Ltd
4#
5# SPDX-License-Identifier: GPL-2.0
6#
7set -e
8
9function usage()
10{
11	echo
12	echo "usage:"
13	echo "    $0 -f [uboot.img]"
14	echo
15}
16
17function args_process()
18{
19	if [ $# -ne 2 ]; then
20		usage
21		exit 1
22	fi
23
24	while [ $# -gt 0 ]; do
25		case $1 in
26			-f)
27				IMG=$2
28				shift 2
29				;;
30			*)
31				usage
32				exit 1
33				;;
34		esac
35	done
36
37	if [ ! -f ${IMG} ]; then
38		echo "ERROR: No ${IMG}"
39		exit 1
40	elif ! file ${IMG} | grep 'Device Tree Blob' ; then
41		echo "ERROR: ${IMG} is not FIT image"
42		exit 1
43	fi
44}
45
46function image_msg()
47{
48	echo "[Commit version]:"
49	strings ${IMG} | grep '\-g[0-9,a-f][0-9,a-f][0-9,a-f][0-9,a-f][0-9,a-f][0-9,a-f][0-9,a-f]' | sort --uniq
50	strings ${IMG} | grep 'Built :' | sort --uniq
51}
52
53args_process $*
54image_msg
55