John Stultz | 16acd4a | 2016-09-06 22:08:25 -0700 | [diff] [blame] | 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 | # Prepare the staging directory |
| 17 | rm -rf tmp |
| 18 | mkdir -p tmp/$PRODUCT-$VERSION |
| 19 | |
| 20 | DEVICE_DIR=device/linaro/hikey/ |
| 21 | |
| 22 | # copy over flashing tool, and bootloader binaries |
| 23 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/README tmp/$PRODUCT-$VERSION/ |
| 24 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hisi-idt.py tmp/$PRODUCT-$VERSION/ |
| 25 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/l-loader.bin tmp/$PRODUCT-$VERSION/ |
| 26 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/ptable-aosp-8g.img tmp/$PRODUCT-$VERSION/ |
| 27 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/ptable-aosp-4g.img tmp/$PRODUCT-$VERSION/ |
| 28 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/fip.bin tmp/$PRODUCT-$VERSION/ |
| 29 | cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/nvme.img tmp/$PRODUCT-$VERSION/ |
| 30 | |
| 31 | cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip |
| 32 | |
| 33 | |
| 34 | # Write flash-all.sh |
| 35 | cat > 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 | |
| 53 | if [ \$# -eq 0 ] |
| 54 | then |
| 55 | echo "Provide the right /dev/ttyUSBX specific to recovery device" |
| 56 | exit |
| 57 | fi |
| 58 | |
| 59 | if [ ! -e "\${1}" ] |
| 60 | then |
| 61 | echo "device: \${1} does not exist" |
| 62 | exit |
| 63 | fi |
| 64 | DEVICE_PORT="\${1}" |
| 65 | |
| 66 | PTABLE=ptable-aosp-8g.img |
| 67 | if [ \$# -gt 1 ] |
| 68 | then |
| 69 | if [ "\${2}" = '4g' ] |
| 70 | then |
| 71 | PTABLE=ptable-aosp-4g.img |
| 72 | fi |
| 73 | fi |
| 74 | |
| 75 | python hisi-idt.py --img1=l-loader.bin -d "\${DEVICE_PORT}" |
| 76 | sleep 3 |
| 77 | # set a unique serial number |
| 78 | serialno=\`fastboot getvar serialno 2>&1 > /dev/null\` |
| 79 | if [ "\${serialno:10:6}" == "(null)" ]; then |
| 80 | fastboot oem serialno |
| 81 | else |
| 82 | if [ "\${serialno:10:15}" == "0123456789abcde" ]; then |
| 83 | fastboot oem serialno |
| 84 | fi |
| 85 | fi |
| 86 | fastboot flash ptable "\${PTABLE}" |
| 87 | fastboot flash fastboot fip.bin |
| 88 | fastboot flash nvme nvme.img |
| 89 | fastboot format userdata |
| 90 | fastboot format cache |
| 91 | fastboot update image-$PRODUCT-$VERSION.zip |
| 92 | EOF |
| 93 | |
| 94 | chmod 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) |
| 98 | mv $PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION-factory-$(sha256sum < $PRODUCT-$VERSION-factory.zip | cut -b -8).zip |
| 99 | |
| 100 | # Clean up |
| 101 | rm -rf tmp |