diff options
author | Mary Ruthven <mruthven@google.com> | 2018-04-09 16:47:48 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-04-12 18:03:06 -0700 |
commit | 69d3059d761f6e0e7be54b3797fab7949e995b9a (patch) | |
tree | 8347dfee32fc58f8f73514896bf817639a5ed3b5 | |
parent | 2dcd5c19c1b4fe49c7cfd82bee9df3105ddf73d0 (diff) | |
download | chrome-ec-69d3059d761f6e0e7be54b3797fab7949e995b9a.tar.gz |
flash_ec: fix UART bitbang flashing with ccd
Cr50 is pretty slow to update it's ccd state right now. Add some delays
when flashing devices using uart bitbang, so cr50 will have enough time
to enable bitbang and configure the uarts correctly.
Also add some commands to cleanup to cleanup the cr50 state.
BUG=b:77825616
BRANCH=none
TEST=run util/flash_ec using ccd on reef and scarlet.
Change-Id: I1c84e36c9bb290c49fd15971c7f61f9e1151a424
Signed-off-by: Mary Ruthven <mruthven@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1006484
Commit-Ready: Mary Ruthven <mruthven@chromium.org>
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rwxr-xr-x | util/flash_ec | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/util/flash_ec b/util/flash_ec index 889852ae1a..fa4845d26b 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -329,13 +329,13 @@ toad_ec_boot0() { dut_control boot_mode:yes } +ccd_ec_boot0() { + info "Using CCD." + dut_control ccd_ec_boot_mode:on +} + servo_ec_boot0() { - if [[ "${SERVO_TYPE}" =~ "_with_ccd" ]] ; then - info "Using CCD." - dut_control ccd_ec_boot_mode:on - else - dut_control ec_boot_mode:on - fi + dut_control ec_boot_mode:on } servo_usbpd_boot0() { @@ -351,7 +351,9 @@ ec_enable_boot0() { if $(in_array "${BOARDS_STM32_PROG_EN[@]}" "${BOARD}"); then dut_control prog_en:yes fi - if [[ "${SERVO_TYPE}" =~ "servo" ]] ; then + if [[ "${SERVO_TYPE}" =~ "ccd_cr50" ]] ; then + stype=ccd + elif [[ "${SERVO_TYPE}" =~ "servo" ]] ; then stype=servo else stype=${SERVO_TYPE} @@ -406,6 +408,10 @@ cleanup() { dut_control --ftdii2c open dut_control --ftdii2c setclock fi + if [[ "${SERVO_TYPE}" =~ "ccd_cr50" ]] ; then + dut_control ccd_ec_boot_mode:off + dut_control ${MCU}_uart_bitbang_en:off + fi if ! on_raiden || $(servo_has_cold_reset); then ec_reset @@ -776,23 +782,35 @@ function flash_stm32() { info "${MCU} UART pty : ${EC_UART}" claim_pty ${EC_UART} - if [[ "${SERVO_TYPE}" =~ "servo" ]] ; then + if ! on_raiden && [ "${SERVO_TYPE}" =~ "servo" ] ; then dut_control ${MCU}_uart_en:on fi dut_control ${MCU}_uart_parity:even - if [ "${SERVO_TYPE}" == "servo_v4_with_ccd_cr50" ] ; then + 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 dut_control ${MCU}_uart_bitbang_en:on else dut_control ${MCU}_uart_baudrate:115200 - fi - if $(servo_has_warm_reset); then - dut_control warm_reset:on + 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 + + # 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 |