summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-07-11 17:02:56 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-07-19 19:03:54 -0700
commit3a7a739b38b566bddb4f97755a699b3688a8744c (patch)
treeb94b9e3752b8982273236260a15b85b351353650
parent8288cea242f895ce65645c917f89b0844653d11a (diff)
downloadchrome-ec-3a7a739b38b566bddb4f97755a699b3688a8744c.tar.gz
flash_ec: Add support for servo micro.
BUG=chromium:740026 BRANCH=maybe some FW branches. TEST=Use a servo_micro, flash kevin, verify kevin boots. TEST=Repeat above test with a servo_v2. Change-Id: I377384f44e85c4a6032871aa4eebd208fd6e3336 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/572142 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rwxr-xr-xutil/flash_ec83
1 files changed, 53 insertions, 30 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 2e99ab8d37..97689083eb 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -168,7 +168,6 @@ DEFINE_string offset "0" \
"Offset where to program the image from."
DEFINE_integer port 9999 \
"Port to communicate to servo on."
-# TODO(aaboagye): It's not just for SPI.
DEFINE_boolean raiden "${FLAGS_FALSE}" \
"Use raiden_debug_spi programmer"
DEFINE_boolean ro "${FLAGS_FALSE}" \
@@ -296,9 +295,8 @@ toad_ec_boot0() {
}
servo_ec_boot0() {
- ## This is a stupid hack.
if [[ "${SERVO_TYPE}" =~ "_with_ccd" ]] ; then
- info "Using CCD"
+ info "Using CCD."
dut_control ccd_ec_boot_mode:on
else
dut_control ec_boot_mode:on
@@ -323,7 +321,6 @@ ec_enable_boot0() {
else
stype=${SERVO_TYPE}
fi
- # eval ${SERVO_TYPE}_${MCU}_boot0
eval ${stype}_${MCU}_boot0
}
@@ -335,6 +332,10 @@ on_servov3() {
# Returns 0 on success (if raiden should be used instead of servo)
error_reported= # Avoid double printing the error message.
on_raiden() {
+ if [[ "${SERVO_TYPE}" =~ "servo_v4" ]] || \
+ [[ "${SERVO_TYPE}" =~ "servo_micro" ]]; then
+ return 0
+ fi
if [ -z "${BOARD}" ]; then
[ "${FLAGS_raiden}" = ${FLAGS_TRUE} ] && return 0 || return 1
fi
@@ -363,7 +364,7 @@ cleanup() {
kill -CONT ${pid}
done
- if ! on_raiden; then
+ if ! on_raiden || [[ "${SERVO_TYPE}" =~ "servo_micro" ]] ; then
ec_reset
fi
}
@@ -423,28 +424,37 @@ case "${BOARD}" in
*) MCU="ec" ;;
esac
-# Not every control is supported on every servo type. Therfore, define which
+# Not every control is supported on every servo type. Therefore, define which
# controls are supported by each servo type.
-common_servo_VARS="${MCU}_uart_en ${MCU}_uart_parity ${MCU}_uart_baudrate"
-servo_v2_VARS="${common_servo_VARS} jtag_buf_on_flex_en jtag_buf_en dev_mode"
+servo_v2_VARS="jtag_buf_on_flex_en jtag_buf_en"
+servo_micro_VARS=
+servo_v4_with_ccd_cr50_VARS=
+# Flashing an STM32 over the UART requires modifying the UART properties along
+# with the boot mode pin.
if [ "${CHIP}" = "stm32" ] ; then
+ common_stm32_VARS=" ${MCU}_uart_en ${MCU}_uart_parity " \
+ "${MCU}_uart_baudrate"
+ servo_v2_VARS+=$common_stm32_VARS
servo_v2_VARS+=" ${MCU}_boot_mode"
+ servo_micro_VARS+=$common_stm32_VARS
+ servo_micro_VARS+=" ${MCU}_boot_mode"
+ servo_v4_with_ccd_cr50_VARS+=$common_stm32_VARS
+ servo_v4_with_ccd_cr50_VARS+=" ccd_${MCU}_boot_mode ec_uart_bitbang_en"
fi
if $(in_array "${BOARDS_STM32_PROG_EN[@]}" "${BOARD}"); then
servo_v2_VARS+=" prog_en"
fi
-servo_v3_VARS="${servo_v2_VARS}"
-servo_micro_VARS="${common_servo_VARS} ${MCU}_boot_mode dev_mode"
-servo_v4_with_ccd_cr50_VARS="${common_servo_VARS} ccd_${MCU}_boot_mode \
-ec_uart_bitbang_en"
-servo_v4_with_servo_micro_VARS="${servo_micro_VARS}"
toad_VARS="${MCU}_uart_parity ${MCU}_uart_baudrate boot_mode"
-SERVO_TYPE="$(get_servo_type)"
+# Some servo boards use the same controls.
+servo_v3_VARS="${servo_v2_VARS}"
+servo_v4_with_servo_micro_VARS="${servo_micro_VARS}"
function servo_save() {
SERVO_VARS_NAME=${SERVO_TYPE}_VARS
- $DUT_CONTROL_CMD ${!SERVO_VARS_NAME}
+ if [[ -n "${!SERVO_VARS_NAME}" ]]; then
+ $DUT_CONTROL_CMD ${!SERVO_VARS_NAME}
+ fi
}
function servo_restore() {
@@ -507,7 +517,7 @@ function flash_openocd() {
die "Failed to program ${IMG}"
}
-# helper function for using servo v2/3 with flashrom
+# helper function for using servo with flashrom
function flash_flashrom() {
TOOL_PATH="${EC_DIR}/build/${BOARD}/util:/usr/sbin/:$PATH"
FLASHROM=$(PATH="${TOOL_PATH}" which flashrom)
@@ -515,22 +525,26 @@ function flash_flashrom() {
if on_servov3; then
FLASHROM_PARAM="-p linux_spi"
elif on_raiden; then
- info "Using raiden debug cable."
- FLASHROM_PARAM="-p raiden_debug_spi:target=EC"
+ if [[ "${SERVO_TYPE}" =~ "servo_micro" ]]; then
+ # Servo micro doesn't use the "target" parameter.
+ FLASHROM_PARAM="-p raiden_debug_spi:"
+ else
+ FLASHROM_PARAM="-p raiden_debug_spi:target=EC,"
+ fi
else
- FLASHROM_PARAM="-p ft2232_spi:type=servo-v2,port=B"
+ FLASHROM_PARAM="-p ft2232_spi:type=servo-v2,port=B,"
fi
if [ ! -x "$FLASHROM" ]; then
die "no flashrom util found."
fi
- if ! on_raiden; then
+ if ! on_raiden || [[ "${SERVO_TYPE}" =~ "servo_micro" ]] ; then
if ! on_servov3; then
SERIALNAME=$(${DUT_CONTROL_CMD} serialname | \
- cut -d: -f2)
+ cut -d: -f2)
if [[ "$SERIALNAME" != "" ]] ; then
- FLASHROM_PARAM+=",serial=${SERIALNAME}"
+ FLASHROM_PARAM+="serial=${SERIALNAME}"
fi
fi
@@ -551,8 +565,11 @@ function flash_flashrom() {
fi
# Turn on SPI1 interface on servo for SPI Flash Chip
- dut_control spi1_vref:${SPI_VOLTAGE} spi1_buf_en:on \
- spi1_buf_on_flex_en:on
+ dut_control spi1_vref:${SPI_VOLTAGE} spi1_buf_en:on
+ if [[ ! "${SERVO_TYPE}" =~ "servo_micro" ]]; then
+ # Servo micro doesn't support this control.
+ dut_control spi1_buf_on_flex_en:on
+ fi
else
# Temp layout
L=/tmp/flash_spi_layout_$$
@@ -563,8 +580,12 @@ function flash_flashrom() {
--fast-verify"
fi
- SPI_SIZE=$(sudo ${FLASHROM} ${FLASHROM_PARAM} --get-size 2>/dev/null | \
- tail -n 1)
+
+ # flashrom should report the image size at the end of the output.
+ SPI_SIZE=$(sudo ${FLASHROM} ${FLASHROM_PARAM} --get-size 2>/dev/null |\
+ grep -oe '[0-9]\+$') || \
+ die "Failed to determine chip size!"
+
IMG_SIZE=$(stat -c%s "$IMG")
PATCH_SIZE=$((${SPI_SIZE} - ${IMG_SIZE}))
@@ -593,10 +614,12 @@ fi
rm $T
- if ! on_raiden; then
+ if ! on_raiden || [[ "${SERVO_TYPE}" =~ "servo_micro" ]] ; then
# Turn off SPI1 interface on servo
- dut_control spi1_vref:off spi1_buf_en:off \
- spi1_buf_on_flex_en:off
+ dut_control spi1_vref:off spi1_buf_en:off
+ if [[ ! "${SERVO_TYPE}" =~ "servo_micro" ]] ; then
+ dut_control spi1_buf_on_flex_en:off
+ fi
# Set GP_SEL# as default to disable GP mode when ec reboots
if $(in_array "${BOARDS_NPCX_INT_SPI[@]}" "${BOARD}"); then
@@ -756,7 +779,7 @@ if dut_control boot_mode 2>/dev/null ; then
SERVO_TYPE=toad
info "Using a dedicated debug cable"
fi
-info "Using ${SERVO_TYPE}"
+info "Using ${SERVO_TYPE}."
IMG="$(ec_image)"
info "Using ${MCU} image : ${IMG}"