From df50d228d1d8f0e6bb6035fd5089b4f2d93674d6 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 16 Jan 2013 14:29:37 -0800 Subject: Cherry-Pick: Add 'unprotect' flag for flashing link ec. BRANCH=link BUG=chromium-os:37967 TEST=Remove write protect, reflash without 'unprotect', flag and verify the write protect flag is stil enabled with flashrom -p internal:bus=lpc --wp-status. Power down, then reflash with the --unprotect flag. Now verify the write protect status flag is disabled. Original-Change-Id: Ie05b5dc85dd31d29ab43a392fe948a52d547fff3 Signed-off-by: Dave Parker Reviewed-on: https://gerrit.chromium.org/gerrit/41477 Reviewed-by: Randall Spangler Conflicts: util/flash_ec Change-Id: Id25104f40cfcccc4c53cbf1b8d02346f7f1322c6 Reviewed-on: https://gerrit.chromium.org/gerrit/41663 Reviewed-by: Walter Murphy Reviewed-by: Randall Spangler Commit-Queue: Dave Parker Tested-by: Dave Parker --- chip/lm4/openocd/lm4x_cmds.tcl | 6 ++++++ util/flash_ec | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/chip/lm4/openocd/lm4x_cmds.tcl b/chip/lm4/openocd/lm4x_cmds.tcl index 00bec7f7b5..beb9fdbfde 100644 --- a/chip/lm4/openocd/lm4x_cmds.tcl +++ b/chip/lm4/openocd/lm4x_cmds.tcl @@ -31,6 +31,12 @@ proc flash_bds { } { flash_lm4 ../../../build/bds/ec.bin 0 262144 } +proc unprotect_link { } { + reset halt + flash erase_sector 0 254 255 + reset +} + # Boot a software using internal RAM only proc ramboot_lm4 {path} { diff --git a/util/flash_ec b/util/flash_ec index 417a823fd5..854700b099 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -14,6 +14,8 @@ DEFINE_string image "" \ "Full pathname of the EC firmware image to flash." DEFINE_boolean ro "${FLAGS_FALSE}" \ "Write only the read-only partition" +DEFINE_boolean unprotect "${FLAGS_FALSE}" \ + "Clear the protect flag." # Parse command line FLAGS_HELP="usage: $0 [flags]" @@ -90,6 +92,10 @@ function flash_daisy() { die "no stm32mon util found." fi + if [ "${FLAGS_unprotect}" = ${FLAGS_TRUE} ] ; then + die "--unprotect not supported for this board." + fi + info "Using serial flasher : ${STM32MON}" dut_control uart1_en:on @@ -107,12 +113,18 @@ function flash_link() { IMG_SIZE=262144 OCD_CFG="servo_v2_slower.cfg" OCD_PATH="${SRC_ROOT}/platform/ec/chip/lm4/openocd" - OCD_CMDS="init ; flash_lm4 ${IMG} 0 262144 ; exit" + OCD_CMDS="init ; flash_lm4 ${IMG} 0 262144 ;" + if [ "${FLAGS_unprotect}" = ${FLAGS_TRUE} ] ; then + info "Clearing write protect flag." + OCD_CMDS="${OCD_CMDS} unprotect_link;" + fi + OCD_CMDS="${OCD_CMDS} shutdown;" dut_control jtag_buf_on_flex_en:on dut_control jtag_buf_en:on - sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -c "${OCD_CMDS}" + sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -c "${OCD_CMDS}" || \ + die "Failed to program ${IMG}" } IMG="$(ec_image)" -- cgit v1.2.1