summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-07-30 13:09:51 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-04 03:14:45 +0000
commit9bc0a4c152dbac6a8adef02843529d5120a6e198 (patch)
tree9c67f36335186d8d8f24f3bd4291bba03e9be040
parent68f56b3ba6def3535eb5fae4a4b1f14a1ae00fc1 (diff)
downloadchrome-ec-9bc0a4c152dbac6a8adef02843529d5120a6e198.tar.gz
Fix LM4 flashing in flash_ec
This fixes the bug that SRC_ROOT is not set. This should be the last fix for flash_ec. DEFAULT_BOARD is intentionally left as is. For developers who don't want to use --board option every time, they need to set DEFAULT_BOARD in their environment variables. BUG=chromium:397202 TEST=util/flash_ec --board=link BRANCH=None Change-Id: If23f73adbd37f2a79cb5176e3665562e278f46db Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/210523 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
-rwxr-xr-xutil/flash_ec46
1 files changed, 30 insertions, 16 deletions
diff --git a/util/flash_ec b/util/flash_ec
index ee311e8243..9e91d20233 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -7,36 +7,41 @@
SCRIPT="$(readlink -f "$0")"
SCRIPT_DIR="$(dirname "$SCRIPT")"
+EC_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
+if [[ "$(basename "${EC_DIR}")" != "ec" ]]; then
+ EC_DIR=
+fi
+
# 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
+ tput "$@" 1>&2 2>/dev/null || true
}
error() {
- tput2 bold && tput2 setaf 1
- echo "ERROR: $*" >&2
- tput2 sgr0
+ tput2 bold && tput2 setaf 1
+ echo "ERROR: $*" >&2
+ tput2 sgr0
}
info() {
- tput2 bold && tput2 setaf 2
- echo "INFO: $*" >&2
- tput2 sgr0
+ tput2 bold && tput2 setaf 2
+ echo "INFO: $*" >&2
+ tput2 sgr0
}
warn() {
- tput2 bold && tput2 setaf 3
- echo "WARNING: $*" >&2
- tput2 sgr0
+ tput2 bold && tput2 setaf 3
+ echo "WARNING: $*" >&2
+ tput2 sgr0
}
die() {
- [ -z "$*" ] || error "$@"
- exit 1
+ [ -z "$*" ] || error "$@"
+ exit 1
}
# Note: Link is a special case and is not included here.
@@ -177,8 +182,13 @@ if [ "${FLAGS_ro}" = ${FLAGS_TRUE} ] ; then
else
EC_FILE=ec.bin
fi
+
EMERGE_BUILD=${BOARD_ROOT}/firmware/${EC_FILE}
-LOCAL_BUILD="$(readlink -f "${SCRIPT_DIR}/../build/${BOARD}/${EC_FILE}")"
+
+LOCAL_BUILD=
+if [[ -n "${EC_DIR}" ]]; then
+ LOCAL_BUILD="${EC_DIR}/build/${BOARD}/${EC_FILE}"
+fi
# Find the EC image to use
function ec_image() {
@@ -271,7 +281,7 @@ function free_pty() {
# Board specific flashing scripts
function flash_stm32() {
- TOOL_PATH="${SCRIPT_DIR}/../build/${BOARD}/util:$PATH"
+ TOOL_PATH="${EC_DIR}/build/${BOARD}/util:$PATH"
STM32MON=$(PATH="${TOOL_PATH}" which stm32mon)
if [ ! -x "$STM32MON" ]; then
die "no stm32mon util found."
@@ -320,8 +330,10 @@ function flash_stm32_dfu() {
}
function flash_link() {
+ [[ -n "${EC_DIR}" ]] || die "Cannot locate openocd script"
+
OCD_CFG="servo_v2_slower.cfg"
- OCD_PATH="${SRC_ROOT}/platform/ec/chip/lm4/openocd"
+ OCD_PATH="${EC_DIR}/chip/lm4/openocd"
OCD_CMDS="init; flash_lm4 ${IMG} ${FLAGS_offset};"
if [ "${FLAGS_unprotect}" = ${FLAGS_TRUE} ] ; then
info "Clearing write protect flag."
@@ -337,8 +349,10 @@ function flash_link() {
}
function flash_lm4() {
+ [[ -n "${EC_DIR}" ]] || die "Cannot locate openocd script"
+
OCD_CFG="servo_v2_slower.cfg"
- OCD_PATH="${SRC_ROOT}/platform/ec/chip/lm4/openocd"
+ OCD_PATH="${EC_DIR}/chip/lm4/openocd"
OCD_CMDS="init; flash_lm4 ${IMG} ${FLAGS_offset};"
if [ "${FLAGS_unprotect}" = ${FLAGS_TRUE} ] ; then
# Unprotect exists, but isn't needed because erasing pstate is