blob: c844ad93bb768b1c72cb6b6d1e9ee5fb1e25e506 [file] [log] [blame]
John Stultz16acd4a2016-09-06 22:08:25 -07001# Copyright 2011, 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16# Prepare the staging directory
17rm -rf tmp
18mkdir -p tmp/$PRODUCT-$VERSION
19
20DEVICE_DIR=device/linaro/hikey/
21
22# copy over flashing tool, and bootloader binaries
23cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/README tmp/$PRODUCT-$VERSION/
24cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hisi-idt.py tmp/$PRODUCT-$VERSION/
25cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/l-loader.bin tmp/$PRODUCT-$VERSION/
26cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/ptable-aosp-8g.img tmp/$PRODUCT-$VERSION/
27cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/ptable-aosp-4g.img tmp/$PRODUCT-$VERSION/
28cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/fip.bin tmp/$PRODUCT-$VERSION/
29cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/nvme.img tmp/$PRODUCT-$VERSION/
30
31cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip
32
33
34# Write flash-all.sh
35cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
36#!/bin/bash
37
38# Copyright 2012, 2016 The Android Open Source Project
39#
40# Licensed under the Apache License, Version 2.0 (the "License");
41# you may not use this file except in compliance with the License.
42# You may obtain a copy of the License at
43#
44# http://www.apache.org/licenses/LICENSE-2.0
45#
46# Unless required by applicable law or agreed to in writing, software
47# distributed under the License is distributed on an "AS IS" BASIS,
48# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49# See the License for the specific language governing permissions and
50# limitations under the License.
51
52
53if [ \$# -eq 0 ]
54 then
55 echo "Provide the right /dev/ttyUSBX specific to recovery device"
56 exit
57fi
58
59if [ ! -e "\${1}" ]
60 then
61 echo "device: \${1} does not exist"
62 exit
63fi
64DEVICE_PORT="\${1}"
65
66PTABLE=ptable-aosp-8g.img
67if [ \$# -gt 1 ]
68 then
69 if [ "\${2}" = '4g' ]
70 then
71 PTABLE=ptable-aosp-4g.img
72 fi
73fi
74
75python hisi-idt.py --img1=l-loader.bin -d "\${DEVICE_PORT}"
76sleep 3
77# set a unique serial number
78serialno=\`fastboot getvar serialno 2>&1 > /dev/null\`
79if [ "\${serialno:10:6}" == "(null)" ]; then
80 fastboot oem serialno
81else
82 if [ "\${serialno:10:15}" == "0123456789abcde" ]; then
83 fastboot oem serialno
84 fi
85fi
86fastboot flash ptable "\${PTABLE}"
87fastboot flash fastboot fip.bin
88fastboot flash nvme nvme.img
89fastboot format userdata
90fastboot format cache
91fastboot update image-$PRODUCT-$VERSION.zip
92EOF
93
94chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh
95
96# Create the distributable package
97(cd tmp ; zip -r ../$PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION)
98mv $PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION-factory-$(sha256sum < $PRODUCT-$VERSION-factory.zip | cut -b -8).zip
99
100# Clean up
101rm -rf tmp