| #!/bin/bash |
| # |
| # Copyright 2016 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. |
| |
| # Only execute this script on a Brillo provisioned MinnowBoard. |
| # See your Brillo-MinnowBoard online information for initial provisioning and recovery. |
| |
| set -e |
| |
| function dir_with_file() { |
| local file=${1}; shift |
| local dir; |
| for dir; do |
| if [ -z "${dir}" ]; then continue; fi |
| if [ -r "${dir}/${file}" ]; then |
| echo ${dir} |
| return |
| fi |
| done |
| echo "Could not find ${file}, looked in $@" >&2 |
| return 1 |
| } |
| |
| LOCAL_DIR=$(dirname "${0}") |
| BASE_NAME=$(basename "${0}") |
| |
| IP="${1}" |
| if [ "$IP" == "" ]; then |
| echo "Usage: ${BASE_NAME} <MinnowBoard Board IP address>" |
| exit 0 |
| fi |
| |
| # Location of where the Brillo OS image is built. |
| OS=$(dir_with_file boot.img \ |
| "${ANDROID_PROVISION_OS_PARTITIONS}" \ |
| "${LOCAL_DIR}" \ |
| "${BRILLO_OUT_DIR}" \ |
| "${ANDROID_PRODUCT_OUT}") |
| |
| VENDOR=$(dir_with_file bootloader \ |
| "${ANDROID_PROVISION_VENDOR_PARTITIONS}" \ |
| "${LOCAL_DIR}" \ |
| "${ANDROID_BUILD_TOP}/vendor/bsp/intel/minnowboard/boot_binaries") |
| |
| |
| if [ -x ./fastboot ]; then |
| FASTBOOT=./fastboot |
| else |
| FASTBOOT=fastboot |
| fi |
| |
| $FASTBOOT -s tcp:$IP flash gpt "${VENDOR}"/gpt.ini |
| $FASTBOOT -s tcp:$IP flash bootloader "${VENDOR}"/bootloader |
| $FASTBOOT -s tcp:$IP flash boot_a "${OS}"/boot.img |
| $FASTBOOT -s tcp:$IP flash boot_b "${OS}"/boot.img |
| $FASTBOOT -s tcp:$IP flash system_a "${OS}"/system.img |
| $FASTBOOT -s tcp:$IP flash system_b "${OS}"/system.img |
| $FASTBOOT -s tcp:$IP flash userdata "${OS}"/userdata.img |
| $FASTBOOT -s tcp:$IP flash oemvars "${VENDOR}"/oemvars.txt |
| $FASTBOOT -s tcp:$IP oem set_active 0 |
| |
| echo "Please run the following command to restart your MinnowBoard" |
| echo " $FASTBOOT -s tcp:$IP reboot" |
| echo |