-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheimdall_flash.sh
More file actions
executable file
·69 lines (55 loc) · 978 Bytes
/
heimdall_flash.sh
File metadata and controls
executable file
·69 lines (55 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -e
if [[ -z "$1" ]]
then
echo "$0 <firmware.zip>" >&2
echo "$0 <dir>" >&2
exit 1
fi
UNPACK="files"
if [[ -f "$1" ]]
then
rm -fr "$UNPACK"
set -x
# Extract zip
unzip "$1" -d "$UNPACK"
cd "$UNPACK"
# Rename md5
for i in *; do mv $i ${i/.md5/}; done
# Extract all files
for i in *;
do
dir=$(echo $i | cut -d '_' -f 1)
# Skip HOME_CSC
if [[ $dir == HOME ]]
then
rm $i
continue
fi
mkdir -p $dir
tar xf $i -C $dir
cd $dir
lz4 --rm -dm *.lz4
cd -
rm $i
done
cd ..
set +x
elif [[ -d "$1" ]]
then
UNPACK="$1"
else
echo "'$1' not a dir nor a file" >&2
exit 2
fi
# find pit file
PITFILE=$(find "$UNPACK" -type f -name '*.pit')
if [[ ! -r $PITFILE ]]
then
echo "Can't find PIT file in dir '$UNPACK'" >&2
exit 3
fi
HM_ARGS=$(./find_flash_files.pl \
<(heimdall print-pit --file $PITFILE --no-reboot) \
<(find "$UNPACK" -type f \( -name '*.img' -or -name '*.bin' \)))
echo heimdall flash --pit $PITFILE $HM_ARGS