blob: 55c95eb1ae8c383e40858ecacdd47d6a1c79eeb5 [file] [log] [blame] [edit]
#!/bin/bash
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#### CATEGORY=Device management
### flash and, optionally, pave a connected device
## usage: fx flash [-s <serial>] [--pave]
## -s Serial of device you wish to flash to (only necessary if multiple
## devices in fastboot mode)
## --pave Pave device after flashing (recommended)
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/image_build_vars.sh || exit $?
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/fx-flash.sh || exit $?
usage() {
fx-command-help
echo "Available devices:"
fastboot devices -l
exit 1
}
pave=false
serial=
device=$(get-device-name)
while [[ $# -ge 1 ]]; do
case "$1" in
-h|--help)
usage
;;
--pave)
pave=true
;;
--nopave)
pave=false
;;
-s)
shift
serial="$1"
;;
-device)
shift
device="$1"
;;
*)
break
esac
shift
done
cd "${FUCHSIA_BUILD_DIR}"
fx-flash "${serial}" "${device}"
if [[ "${pave}" == "true" ]]; then
fx-command-exec pave -1
fi