summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2018-08-08 16:36:33 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-17 20:39:04 -0700
commit98a8eff7f650f0d68c4f5b9720dce1b4330e1461 (patch)
treef690fce17a06828879868a0a222f2edf669cb439 /util
parentb244deb45b4051a8166824abdccf8cb40b8e2e75 (diff)
downloadchrome-ec-98a8eff7f650f0d68c4f5b9720dce1b4330e1461.tar.gz
stm32: fix flash_ec stm32 serial EC programming mode
Proper sequence of events when enabling STM32 monitor mode is as follows: - bootp0 pin level is set to 'high' - chip is reset - the programmer starts sending sync bytes over the UART This patch implements this sequence in flash_stm32(). In cases when 'cold_reset' control is not available this function will fail, as this means that the STM32 chip can not be reset. When programming over Cr50 a servod control to enter bit bang mode is issued. Newer Cr50 versions support baud rates up to 57600, but until the new Cr50 version is released, 9600 bps should be used as the default. A new command line option is being added to allow specify UART speed when programming in bit bang mode. BRANCH=cr50, cr50-mp BUG=b:62539385 TEST=successfully ran to completion (100 iterations) the following script when programming Scarlet when servo is connected over Cr50: count=0; while ./util/flash_ec --board scarlet --image <image path>; do count=$(( count + 1 )) echo "succeeded $count times" if [ $count == 100 ]; then break fi sleep 3 done Change-Id: Ib3242a92c94f64214ffd1f290b97c2660ce21360 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1171915 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/flash_ec40
1 files changed, 23 insertions, 17 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 32b46978b3..9f6ee74736 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -184,8 +184,12 @@ VALID_CHIP_COMBO["grunt.npcx_uut"]="ccd_cr50"
VALID_CHIP_COMBO["grunt.npcx_spi"]="servo"
DEFAULT_PORT="${SERVOD_PORT:-9999}"
+BITBANG_RATE="9600" # Could be overwritten by a command line option.
# Flags
+DEFINE_integer bitbang_rate "${BITBANG_RATE}" \
+ "UART baud rate to use when bit bang programming, "\
+"standard UART rates from 9600 to 57600 are supported."
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to run debugger on."
DEFINE_string chip "" \
@@ -880,6 +884,11 @@ function flash_flashrom() {
function flash_stm32() {
local log_option
+ local STM32MON
+
+ if ! $(servo_has_cold_reset); then
+ die "Cold reset must be available for STM32 programming"
+ fi
TOOL_PATH="${EC_DIR}/build/${BOARD}/util:$PATH"
STM32MON=$(PATH="${TOOL_PATH}" which stm32mon)
@@ -892,40 +901,37 @@ function flash_stm32() {
info "${MCU} UART pty : ${EC_UART}"
claim_pty ${EC_UART}
+ # Make sure EC reboots in serial monitor mode.
+ ec_enable_boot0 "bitbang"
+
+ # Pulse EC reset.
+ ec_reset
+
if ! on_raiden && [[ "${SERVO_TYPE}" =~ "servo" ]] ; then
dut_control ${MCU}_uart_en:on
fi
dut_control ${MCU}_uart_parity:even
if [[ "${SERVO_TYPE}" =~ "ccd_cr50" ]] ; then
- # TODO(b/77965217): remove when cr50 stops clobbering bitbang
- # when it notices the AP/EC turn off.
- dut_control cold_reset:on
- sleep 2
- dut_control ${MCU}_uart_baudrate:9600
+ case "${FLAGS_bitbang_rate}" in
+ (9600|19200|38400|57600) : ;;
+ (*) die
+ "${FLAGS_bitbang_rate} is not a valid bit bang rate"
+ ;;
+ esac
+ info "Programming at ${FLAGS_bitbang_rate} baud"
+ dut_control ${MCU}_uart_baudrate:"${FLAGS_bitbang_rate}"
dut_control ${MCU}_uart_bitbang_en:on
else
dut_control ${MCU}_uart_baudrate:115200
-
- if $(servo_has_warm_reset); then
- dut_control warm_reset:on
- fi
fi
- # Force the EC to boot in serial monitor mode
- ec_enable_boot0 "bitbang"
-
# Add a delay long enough for cr50 to update the ccdstate. Cr50 updates
# ccdstate once a second, so a 2 second delay should be safe.
if [[ "${SERVO_TYPE}" =~ "ccd_cr50" ]] ; then
sleep 2
fi
- # Reset the EC
- if $(servo_has_cold_reset); then
- ec_reset
- fi
-
if [ -n "${FLAGS_logfile}" ]; then
log_option="-L ${FLAGS_logfile}"
info "Saving log in ${FLAGS_logfile}"