summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-07-24 15:44:25 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-30 05:31:50 +0000
commit5871a19f5cf7687afdc66134be2ce61694461090 (patch)
tree42b0e50382f984a7248018206298c621f7f72a5a
parent139a9c6880709586e677554643bb1b301da84c77 (diff)
downloadchrome-ec-5871a19f5cf7687afdc66134be2ce61694461090.tar.gz
Remove dependency of flash_ec on crosutils
The script currently depends on common.sh from crosutils, which is not installed on beaglebone and also pulls in dependency on other repositories. Let's switch to shared shflags library and include output formatting functions in flash_ec script. This way we are independent from crosutils. BUG=chromium:397202 TEST=Run the script to flash EC BRANCH=None Change-Id: Ib18987410eb32d773d55fb4e53133adf230167b9 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209827 Reviewed-by: Dan Shi <dshi@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rwxr-xr-xutil/flash_ec44
1 files changed, 39 insertions, 5 deletions
diff --git a/util/flash_ec b/util/flash_ec
index e3b2d6fdce..4854846be1 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -1,11 +1,43 @@
#!/bin/bash
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-COMMON_SH=/usr/lib/crosutils/common.sh
-. "${COMMON_SH}" || exit 1
+SCRIPT="$(readlink -f "$0")"
+SCRIPT_DIR="$(dirname "$SCRIPT")"
+
+# Loads script libraries.
+. "/usr/share/misc/shflags" || exit 1
+
+# Redirects tput to stderr, and drop any error messages.
+tput2() {
+ tput "$@" 1>&2 2>/dev/null || true
+}
+
+error() {
+ tput2 bold && tput2 setaf 1
+ echo "ERROR: $*" >&2
+ tput2 sgr0
+}
+
+
+info() {
+ tput2 bold && tput2 setaf 2
+ echo "INFO: $*" >&2
+ tput2 sgr0
+}
+
+warn() {
+ tput2 bold && tput2 setaf 3
+ echo "WARNING: $*" >&2
+ tput2 sgr0
+}
+
+die() {
+ [ -z "$*" ] || error "$@"
+ exit 1
+}
# Flags
DEFINE_string board "${DEFAULT_BOARD}" \
@@ -25,7 +57,9 @@ DEFINE_boolean unprotect "${FLAGS_FALSE}" \
FLAGS_HELP="usage: $0 [flags]"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
-check_flags_only_and_allow_null_arg "$@" && set --
+if [[ $# -gt 0 ]]; then
+ die "invalid arguments: \"$*\""
+fi
set -e
@@ -101,7 +135,7 @@ else
EC_FILE=ec.bin
fi
EMERGE_BUILD=${BOARD_ROOT}/firmware/${EC_FILE}
-LOCAL_BUILD=${SRC_ROOT}/platform/ec/build/${BOARD}/${EC_FILE}
+LOCAL_BUILD="$(readlink -f "${SCRIPT_DIR}/../build/${BOARD}/${EC_FILE}")"
# Find the EC image to use
function ec_image() {