aboutsummaryrefslogtreecommitdiff
path: root/flash.sh
blob: c4d19431dbf6b0d32d3effe1599bdb5b0b6b73a3 (plain)
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
#!/bin/bash

DIRPATH=imgs
BOARD=$1

if [ $# -eq 0 ]; then
   echo "Error: No arguments"
   echo "Usage: ./flash.sh <valid board name>"
   exit -1
fi


if [ ! -d "$DIRPATH/$BOARD" ]; then
  echo "ERROR: No such path: $DIRPATH/$BOARD"
  exit -1
fi

pushd $DIRPATH/$BOARD > /dev/null

echo "Extracting images"

IMGS="boot.img system.img cache.img userdata.img dt.img"
for i in $IMGS; do
  xz -k -d $i.xz
done

echo "Flashing $BOARD"
#special case for hikey960 dts partition
if [$BOARD -eq "hikey960" ] ; then
   fastboot flash dts dt.img
fi
fastboot flash boot boot.img
fastboot flash cache cache.img
fastboot flash system system.img  
# we skip flashing userdata here

fastboot reboot

#cleanup
rm -f $IMGS

popd >/dev/null