From aaff3610116bab246906ad929b5f0179cbe09577 Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Fri, 29 May 2015 16:06:09 -0700 Subject: flash_ec: split interface config from chip configs rename setup_openocd -> flash_openocd refactor so that flash_npcx and flash_lm4 set OCD_CMDS and call flash_openocd BRANCH=none BUG=chrome-os-partner:22990 TEST=run flash_ec before and after and compare the sequence of calls to dut-control and the command-line args to openocd tested with ryu (non-lm4), samus, link, npcx_evb, and peppy Change-Id: I7a05e3219d4b324bcf19a20f86b149f8e3377465 Signed-off-by: Myles Watson Reviewed-on: https://chromium-review.googlesource.com/273907 Reviewed-by: Randall Spangler --- util/flash_ec | 37 ++++++++++++++++--------------------- util/openocd/lm4_chip.cfg | 4 ++++ util/openocd/npcx_chip.cfg | 2 +- util/openocd/servo.cfg | 5 ++--- 4 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 util/openocd/lm4_chip.cfg diff --git a/util/flash_ec b/util/flash_ec index a7eef4efc2..b94ed556d9 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -312,19 +312,26 @@ function claim_pty() { # Board specific flashing scripts -# helper function for setting up servo v2/3 with openocd paths -function setup_openocd() { +# helper function for using servo v2/3 with openocd +function flash_openocd() { + OCD_CFG="servo.cfg" if [[ -z "${EC_DIR}" ]]; then # check if we're on beaglebone if [[ -e "/usr/bin/lib" ]]; then - OCD_CFG="servo_v3.cfg" OCD_PATH="/usr/bin/lib" else die "Cannot locate openocd configs" fi else - OCD_CFG="servo_v2.cfg" + OCD_PATH="${EC_DIR}/util/openocd" fi + + dut_control jtag_buf_on_flex_en:on + dut_control jtag_buf_en:on + + sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -f "${OCD_CHIP_CFG}" \ + -c "${OCD_CMDS}" || \ + die "Failed to program ${IMG}" } function flash_stm32() { @@ -384,37 +391,25 @@ function flash_stm32_dfu() { } function flash_lm4() { - OCD_PATH="${EC_DIR}/chip/lm4/openocd" - setup_openocd - + OCD_CHIP_CFG="lm4_chip.cfg" OCD_CMDS="init; flash_lm4 ${IMG} ${FLAGS_offset}; shutdown;" - dut_control jtag_buf_on_flex_en:on - dut_control jtag_buf_en:on + flash_openocd - sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -c "${OCD_CMDS}" || \ - die "Failed to program ${IMG}" } function flash_npcx() { - OCD_PATH="${EC_DIR}/chip/npcx/openocd" IMG_PATH="${EC_DIR}/build/${BOARD}" - setup_openocd - - dut_control jtag_buf_on_flex_en:on - dut_control jtag_buf_en:on - + OCD_CHIP_CFG="npcx_chip.cfg" if [ "${FLAGS_ro}" = ${FLAGS_TRUE} ] ; then # Program RO region only OCD_CMDS="init; flash_npcx_ro ${IMG_PATH} ${FLAGS_offset}; shutdown;" - sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -c "${OCD_CMDS}" || \ - die "Failed to program ${IMG}" else # Program all EC regions OCD_CMDS="init; flash_npcx_all ${IMG_PATH} ${FLAGS_offset}; shutdown;" - sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -c "${OCD_CMDS}" || \ - die "Failed to program ${IMG}" fi + + flash_openocd } function flash_mec1322() { diff --git a/util/openocd/lm4_chip.cfg b/util/openocd/lm4_chip.cfg new file mode 100644 index 0000000000..ec3bb4143c --- /dev/null +++ b/util/openocd/lm4_chip.cfg @@ -0,0 +1,4 @@ + +source [find target/stellaris.cfg] +source [find lm4x_cmds.tcl] + diff --git a/util/openocd/npcx_chip.cfg b/util/openocd/npcx_chip.cfg index 5294b733fd..8e137307e5 100644 --- a/util/openocd/npcx_chip.cfg +++ b/util/openocd/npcx_chip.cfg @@ -1,4 +1,4 @@ -interface jlink source [find npcx.cfg] source [find npcx_cmds.tcl] + diff --git a/util/openocd/servo.cfg b/util/openocd/servo.cfg index 7d8fd77f7c..362e4f814d 100644 --- a/util/openocd/servo.cfg +++ b/util/openocd/servo.cfg @@ -4,10 +4,9 @@ gdb_memory_map enable gdb_flash_program enable interface ftdi -ftdi_vid_pid 0x18d1 0x5002 +# VID/PID for servo v2, servo v3 +ftdi_vid_pid 0x18d1 0x5002 0x18d1 0x5004 0x18d1 0x500d ftdi_layout_init 0x0c08 0x0f1b ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400 ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800 -source [find target/stellaris.cfg] -source [find lm4x_cmds.tcl] -- cgit v1.2.1