summaryrefslogtreecommitdiff
path: root/factory-images/generate-factory-images-db820c.sh
blob: fe24c6c2406a8f7038b70c7a5e33d672fb1c83d2 (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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PRODUCT=db820c
DEVICE_DIR=device/linaro/dragonboard/
PRODUCT_OUT_DIR=$ANDROID_BUILD_TOP/out/target/product/$PRODUCT

# Prepare the staging directory
rm -rf tmp
mkdir tmp

BUILD=eng.`whoami`
BUILDNAME=`ls ${ANDROID_BUILD_TOP}/${PRODUCT}-img-${BUILD}.zip 2> /dev/null`
if [ $? -ne 0 ]; then
  VERSION=linaro-`date +"%Y.%m.%d"`
else
  # Installing an existing ${ANDROID_BUILD_TOP}/${PRODUCT}-img-*.zip image package?
  echo "Installing from prebuilt zip image package $BUILDNAME"
  BUILDNAME=`ls ${ANDROID_BUILD_TOP}/${PRODUCT}-img-*.zip 2> /dev/null`
  BUILD=`basename ${BUILDNAME} | cut -f3 -d'-' | cut -f1 -d'.'`
  VERSION=$BUILD

  # unzip the existing image package to tmp and copy AOSP images from there
  unzip -d tmp $BUILDNAME
  PRODUCT_OUT_DIR=tmp
fi

# The staging directory
mkdir tmp/$PRODUCT-$VERSION

# copy over bootloader binaries
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/README tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/gpt_both0.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/gpt_both1.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/gpt_both2.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/gpt_both3.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/gpt_both4.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/gpt_both5.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/sbc_1.0_8096.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/xbl.elf tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/rpm.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/tz.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/hyp.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/pmic.elf tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/emmc_appsboot.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/devcfg.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/cmnlib64.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/cmnlib.mbn tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/db820c/keymaster.mbn tmp/$PRODUCT-$VERSION/

# "fastboot update <zip>" is not flashing cache and userdata partitions
# for some reason. So copy over AOSP images and flash them separately instead.
cp $PRODUCT_OUT_DIR/boot.img tmp/$PRODUCT-$VERSION/
cp $PRODUCT_OUT_DIR/system.img tmp/$PRODUCT-$VERSION/
cp $PRODUCT_OUT_DIR/vendor.img tmp/$PRODUCT-$VERSION/
cp $PRODUCT_OUT_DIR/cache.img tmp/$PRODUCT-$VERSION/
cp $PRODUCT_OUT_DIR/userdata.img tmp/$PRODUCT-$VERSION/

# Write flash-all.sh
cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
#!/bin/bash

# Copyright 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Flash GPT and bootloader firmware files
fastboot flash partition:0 gpt_both0.bin
fastboot flash partition:1 gpt_both1.bin
fastboot flash partition:2 gpt_both2.bin
fastboot flash partition:3 gpt_both3.bin
fastboot flash partition:4 gpt_both4.bin
fastboot flash partition:5 gpt_both5.bin

fastboot erase ddr

fastboot flash cdt sbc_1.0_8096.bin
fastboot flash xbl xbl.elf
fastboot flash rpm rpm.mbn
fastboot flash tz tz.mbn
fastboot flash hyp hyp.mbn
fastboot flash pmic pmic.elf
fastboot flash aboot emmc_appsboot.mbn
fastboot flash devcfg devcfg.mbn
fastboot flash cmnlib64 cmnlib64.mbn
fastboot flash cmnlib cmnlib.mbn
fastboot flash keymaster keymaster.mbn

fastboot reboot-bootloader

# "fastboot update <zip>" is not flashing cache and userdata partitions
# for some reason. So don't do "fastboot update" and use "fastboot flash"
# instructions instead. #FIXME
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash vendor vendor.img
fastboot flash cache cache.img
fastboot flash userdata userdata.img

fastboot reboot
EOF

chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh

# Create the distributable package
(cd tmp ; zip -r ../$PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION)
mv $PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION-factory-$(sha256sum < $PRODUCT-$VERSION-factory.zip | cut -b -8).zip

# Clean up
rm -rf tmp