diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2020-02-04 11:07:01 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2020-05-24 21:31:21 +0100 |
commit | ac05f929edffd6f1a4491d0b1e6cc95122ec6eb1 (patch) | |
tree | 8ef12de202276c0cb2c756e84673f1a57b8fe47e | |
parent | ac18e960ce79f06b22e71a17415be0feb741a482 (diff) | |
download | riscv-openocd-ac05f929edffd6f1a4491d0b1e6cc95122ec6eb1.zip riscv-openocd-ac05f929edffd6f1a4491d0b1e6cc95122ec6eb1.tar.gz riscv-openocd-ac05f929edffd6f1a4491d0b1e6cc95122ec6eb1.tar.bz2 |
swim: fix adapter speed handling
SWIM transport only supports two adapter speeds:
- "low speed" equal to 363 kHz (8 MHz / 22)
- "high speed" equal to 800 kHz (8 MHz / 10)
Replace the previous convention that use "0" or "1" for "low" or
"high" speed with the effective speed in kHz.
Rework the implementation of stlink_speed_swim().
Set low speed in the stm8 config files, because only low speed is
permitted at debug connection; the previous code ignores the
initial value.
Change-Id: I2484c9419a2c554c59eb6b9216339393ab0b54f3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5529
Tested-by: jenkins
-rw-r--r-- | src/jtag/drivers/stlink_usb.c | 16 | ||||
-rw-r--r-- | src/jtag/swim.h | 3 | ||||
-rw-r--r-- | src/target/stm8.c | 2 | ||||
-rw-r--r-- | tcl/target/stm8l.cfg | 4 | ||||
-rw-r--r-- | tcl/target/stm8s.cfg | 4 |
5 files changed, 18 insertions, 11 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index aef02c5..485a95c 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -36,6 +36,7 @@ #include <jtag/hla/hla_layout.h> #include <jtag/hla/hla_transport.h> #include <jtag/hla/hla_interface.h> +#include <jtag/swim.h> #include <target/target.h> #include <transport/transport.h> @@ -2478,17 +2479,20 @@ static int stlink_usb_override_target(const char *targetname) static int stlink_speed_swim(void *handle, int khz, bool query) { + int retval; + /* - we dont care what the khz rate is we only have low and high speed... before changing speed the SWIM_CSR HS bit must be updated */ - if (khz == 0) - stlink_swim_speed(handle, 0); - else - stlink_swim_speed(handle, 1); - return khz; + if (!query) { + retval = stlink_swim_speed(handle, (khz < SWIM_FREQ_HIGH) ? 0 : 1); + if (retval != ERROR_OK) + LOG_ERROR("Unable to set adapter speed"); + } + + return (khz < SWIM_FREQ_HIGH) ? SWIM_FREQ_LOW : SWIM_FREQ_HIGH; } static int stlink_match_speed_map(const struct speed_map *map, unsigned int map_size, int khz, bool query) diff --git a/src/jtag/swim.h b/src/jtag/swim.h index d0ae18e..186e0cc 100644 --- a/src/jtag/swim.h +++ b/src/jtag/swim.h @@ -13,6 +13,9 @@ #ifndef OPENOCD_JTAG_SWIM_H #define OPENOCD_JTAG_SWIM_H +#define SWIM_FREQ_LOW 363 +#define SWIM_FREQ_HIGH 800 + struct swim_driver { /** * Send SRST (system reset) command to target. diff --git a/src/target/stm8.c b/src/target/stm8.c index ad05b54..c06e0fa 100644 --- a/src/target/stm8.c +++ b/src/target/stm8.c @@ -1670,7 +1670,7 @@ static int stm8_examine(struct target *target) retval = stm8_write_u8(target, SWIM_CSR, SAFE_MASK + SWIM_DM + HS); if (retval != ERROR_OK) return retval; - jtag_config_khz(1); + jtag_config_khz(SWIM_FREQ_HIGH); stm8->swim_configured = true; /* Now is the time to deassert reset if connect_under_reset. diff --git a/tcl/target/stm8l.cfg b/tcl/target/stm8l.cfg index 386f371..f3c9428 100644 --- a/tcl/target/stm8l.cfg +++ b/tcl/target/stm8l.cfg @@ -78,8 +78,8 @@ $_TARGETNAME configure -optionstart $_OPTIONSTART -optionend $_OPTIONEND -blocks # Set stm8l type $_TARGETNAME configure -enable_stm8l -# The khz rate does not apply here, only slow <0> and fast <1> -adapter speed 1 +# Set low speed at debug entry +adapter speed 363 reset_config srst_only diff --git a/tcl/target/stm8s.cfg b/tcl/target/stm8s.cfg index 4768068..5d52aea 100644 --- a/tcl/target/stm8s.cfg +++ b/tcl/target/stm8s.cfg @@ -75,8 +75,8 @@ $_TARGETNAME configure -optionstart $_OPTIONSTART -optionend $_OPTIONEND -blocks # Uncomment this line to enable interrupts while instruction step #$_TARGETNAME configure -enable_step_irq -# The khz rate does not apply here, only slow <0> and fast <1> -adapter speed 1 +# Set low speed at debug entry +adapter speed 363 reset_config srst_only |