1# 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 16DEVICE_DIR=device/linaro/hikey/ 17DEVICE=hikey960 18PRODUCT=hikey960 19 20BUILD=eng.`whoami` 21BUILDNAME=`ls ${ANDROID_BUILD_TOP}/${PRODUCT}-img-${BUILD}.zip 2> /dev/null` 22if [ $? -ne 0 ]; then 23 VERSION=linaro-`date +"%Y.%m.%d"` 24else 25 BUILDNAME=`ls ${ANDROID_BUILD_TOP}/${PRODUCT}-img-*.zip 2> /dev/null` 26 BUILD=`basename ${BUILDNAME} | cut -f3 -d'-' | cut -f1 -d'.'` 27 VERSION=$BUILD 28fi 29 30# Prepare the staging directory 31rm -rf tmp 32mkdir -p tmp/$PRODUCT-$VERSION 33 34# copy over bootloader binaries 35cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-bl31.bin tmp/$PRODUCT-$VERSION/ 36cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-fastboot.img tmp/$PRODUCT-$VERSION/ 37cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-lpm3.img tmp/$PRODUCT-$VERSION/ 38cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-nvme.img tmp/$PRODUCT-$VERSION/ 39cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-ptable.img tmp/$PRODUCT-$VERSION/ 40cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-sec_xloader.img tmp/$PRODUCT-$VERSION/ 41cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/README tmp/$PRODUCT-$VERSION/ 42 43# copy over dts.img 44cp $ANDROID_BUILD_TOP/out/target/product/hikey960/dt.img tmp/$PRODUCT-$VERSION/ 45 46# copy over the update image 47cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip 48 49# XXX hikey960's fastboot update currently doesn't format cache/userdata, so do it manually 50# XXX Remove this when the bug is fixed. 51cp $ANDROID_BUILD_TOP/out/target/product/hikey960/cache.img tmp/$PRODUCT-$VERSION/ 52cp $ANDROID_BUILD_TOP/out/target/product/hikey960/userdata.img tmp/$PRODUCT-$VERSION/ 53 54 55# Write flash-all.sh 56cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 57#!/bin/bash 58 59# Copyright 2012, 2016 The Android Open Source Project 60# 61# Licensed under the Apache License, Version 2.0 (the "License"); 62# you may not use this file except in compliance with the License. 63# You may obtain a copy of the License at 64# 65# http://www.apache.org/licenses/LICENSE-2.0 66# 67# Unless required by applicable law or agreed to in writing, software 68# distributed under the License is distributed on an "AS IS" BASIS, 69# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 70# See the License for the specific language governing permissions and 71# limitations under the License. 72 73 74 75fastboot flash xloader hisi-sec_xloader.img 76fastboot flash ptable hisi-ptable.img 77fastboot flash fastboot hisi-fastboot.img 78fastboot reboot-bootloader 79fastboot flash nvme hisi-nvme.img 80fastboot flash fw_lpm3 hisi-lpm3.img 81fastboot flash trustfirmware hisi-bl31.bin 82fastboot flash dts dt.img 83 84# XXX fastboot update doesn't format cache and userdata 85# XXX so flash those manually. Remove this later. 86fastboot flash cache cache.img 87fastboot flash userdata userdata.img 88 89fastboot update image-$PRODUCT-$VERSION.zip 90EOF 91 92chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh 93 94# Create the distributable package 95(cd tmp ; zip -r ../$PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION) 96mv $PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION-factory-$(sha256sum < $PRODUCT-$VERSION-factory.zip | cut -b -8).zip 97 98# Clean up 99rm -rf tmp 100