From a47bda8042f988929d6f981944e75146cbab2dd5 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 24 May 2013 15:40:32 -0700 Subject: Make flash_ec capable of writing to an incorrectly-protected STM32 If EC-RO protects itself via the WRPx option bytes, flash_ec will fail to reprogram it. And if EC-RO is broken/unbootable, it won't be able to clear the WRPx option bytes itself when it sees the write protect GPIO is not asserted. Add the -u flag to stm32mon so that it will automatically attempt to unprotect the flash via the option bytes. BUG=chrome-os-partner:19723 BRANCH=none TEST=enable write protect GPIO. Then from console, 'flashwp enable'. Then from the chroot: ./util/flash_ec --board=pit --ro --image=build/pit/ec.RO.flat That should successfully reflash the board. Change-Id: Ic356d29104294d04d5e2a36dc75fd0206b89bd34 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/56659 --- util/flash_ec | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/util/flash_ec b/util/flash_ec index 32301315f0..4ee207dfd1 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -152,8 +152,8 @@ function flash_daisy() { fi if [ "${FLAGS_unprotect}" = ${FLAGS_TRUE} ] ; then - # Unprotect exists, but isn't needed because it's implicit - # in writing the entire image + # Unprotect exists, but isn't needed because erasing pstate is + # implicit in writing the entire image die "--unprotect not supported for this board." fi @@ -169,10 +169,8 @@ function flash_daisy() { ec_enable_boot0 # Reset the EC ec_reset - # TODO: add -u flag to unprotect the flash so that writes will succeed - # on a chip which has temporarily protected itself via the WRPx option - # bytes. - ${STM32MON} -d ${EC_UART} -e -w ${IMG} + # Unprotect flash, erase, and write + ${STM32MON} -d ${EC_UART} -u -e -w ${IMG} } function flash_link() { @@ -197,8 +195,8 @@ function flash_slippy() { OCD_PATH="${SRC_ROOT}/platform/ec/chip/lm4/openocd" OCD_CMDS="init; flash_lm4 ${IMG} ${FLAGS_offset};" if [ "${FLAGS_unprotect}" = ${FLAGS_TRUE} ] ; then - # Unprotect exists, but isn't needed because it's implicit - # in writing the entire image + # Unprotect exists, but isn't needed because erasing pstate is + # implicit in writing the entire image die "--unprotect not supported for this board." fi OCD_CMDS="${OCD_CMDS} shutdown;" -- cgit v1.2.1