diff options
-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 |