rockchip: support pack resources into resource.img

This script supports pack charge pictures into resource.img

Usage:
 ./pack_resource.sh <input resource.img>

Change-Id: If0577a62d58a0c93826ac6c0db5df7872dced964
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2017-12-13 20:01:19 +08:00 committed by Kever Yang
parent cd7ae718e1
commit d2975239b8
8 changed files with 65 additions and 0 deletions

65
pack_resource.sh Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh
OLD_IMAGE=$1
IMAGE=resource.img
TOOL=../rkbin/tools/resource_tool
RESOURCES=./tools/images/
usage()
{
echo "Usage:"
echo " ./pack_resource <input resource.img>"
}
prepare()
{
echo
if [ "$OLD_IMAGE" = '--help' -o "$OLD_IMAGE" = '-h' -o "$OLD_IMAGE" = '--h' ]; then
usage
exit 0
elif [ ! -f "$TOOL" ];then
echo "Can't find '../rkbin/' Responsity, please download it before pack image!"
echo "How to obtain? 3 ways:"
echo " 1. Login your Rockchip gerrit account: \"Projects\" -> \"List\" -> search \"rk/rkbin\" Responsity"
echo " 2. Github Responsity: https://github.com/rockchip-linux/rkbin"
echo " 3. Download full release SDK Responsity"
exit 1
elif [ ! -d "$RESOURCES" ];then
echo "Can't find resources: $RESOURCES"
exit 1
elif [ -z "$OLD_IMAGE" ];then
echo "Missing: <input image>"
usage
exit 1
elif [ ! -f "$OLD_IMAGE" ];then
echo "Can't find file: $OLD_IMAGE"
usage
exit 1
fi
}
append_resource()
{
local TMP_DIR=.resource_tmp
rm -r $TMP_DIR 2>/dev/null
mkdir $TMP_DIR
echo "Pack $RESOURCES & $OLD_IMAGE to $IMAGE ..."
if [ -f "$OLD_IMAGE" ];then
echo "Unpacking old image($OLD_IMAGE):"
$TOOL --unpack --verbose --image=$OLD_IMAGE $TMP_DIR 2>&1|grep entry|sed "s/^.*://"|xargs echo
fi
if [ -d "$RESOURCES" ];then
cp -r $RESOURCES/* $TMP_DIR
else
cp -r $RESOURCES $TMP_DIR
fi
$TOOL --pack --root=$TMP_DIR --image=$IMAGE `find $TMP_DIR -type f|sort`
echo "Packed resources:"
$TOOL --unpack --verbose --image=$IMAGE $TMP_DIR 2>&1|grep entry|sed "s/^.*://"|xargs echo
rm -r $TMP_DIR 2>/dev/null
echo
echo "resource.img is packed ready"
}
prepare
append_resource

BIN
tools/images/battery_0.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
tools/images/battery_1.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
tools/images/battery_2.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
tools/images/battery_3.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
tools/images/battery_4.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
tools/images/battery_5.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB