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