diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2020-05-21 13:24:32 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2020-05-24 21:36:02 +0100 |
commit | 7456e6bac5a3f13818d16660f3cd049a73a6e3fb (patch) | |
tree | 4cf8e80a296da18e68c55828b8224b6f04632020 | |
parent | b342c67f7786fd17734763902dcb0c39286834a0 (diff) | |
download | riscv-openocd-7456e6bac5a3f13818d16660f3cd049a73a6e3fb.zip riscv-openocd-7456e6bac5a3f13818d16660f3cd049a73a6e3fb.tar.gz riscv-openocd-7456e6bac5a3f13818d16660f3cd049a73a6e3fb.tar.bz2 |
stlink: fix open AP for v2j37 and v3j7
The new stlink firmware requires opening the AP before issuing
any operation.
In the current code we have a 'questionable' check about the core
model to set the TAR autoincrement, that is issued without opening
the AP, thus causing a STLINK_BAD_AP_ERROR.
Modify the AP open API to handle this case and open AP#0 before
the memory access to check the core model.
Change-Id: I576955b5094bd41d63ff1fbad7b4fd9433253321
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: http://openocd.zylin.com/5691
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
-rw-r--r-- | src/jtag/drivers/stlink_usb.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index 116d71c..3fdb126 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -361,6 +361,7 @@ static int stlink_swim_status(void *handle); void stlink_dump_speed_map(const struct speed_map *map, unsigned int map_size); static int stlink_get_com_freq(void *handle, bool is_jtag, struct speed_map *map); static int stlink_speed(void *handle, int khz, bool query); +static int stlink_usb_open_ap(void *handle, unsigned short apsel); /** */ static unsigned int stlink_usb_block(void *handle) @@ -2972,6 +2973,7 @@ static int stlink_usb_open(struct hl_interface_param_s *param, enum stlink_mode h->max_mem_packet = (1 << 10); uint8_t buffer[4]; + stlink_usb_open_ap(h, 0); err = stlink_usb_read_mem32(h, CPUID, 4, buffer); if (err == ERROR_OK) { uint32_t cpuid = le_to_h_u32(buffer); @@ -3204,13 +3206,13 @@ static int stlink_dap_get_and_clear_error(void) return retval; } -/** */ -static int stlink_dap_open_ap(unsigned short apsel) +static int stlink_usb_open_ap(void *handle, unsigned short apsel) { + struct stlink_usb_handle_s *h = handle; int retval; /* nothing to do on old versions */ - if (!(stlink_dap_handle->version.flags & STLINK_F_HAS_AP_INIT)) + if (!(h->version.flags & STLINK_F_HAS_AP_INIT)) return ERROR_OK; if (apsel > DP_APSEL_MAX) @@ -3219,7 +3221,7 @@ static int stlink_dap_open_ap(unsigned short apsel) if (test_bit(apsel, opened_ap)) return ERROR_OK; - retval = stlink_usb_init_access_port(stlink_dap_handle, apsel); + retval = stlink_usb_init_access_port(h, apsel); if (retval != ERROR_OK) return retval; @@ -3228,6 +3230,11 @@ static int stlink_dap_open_ap(unsigned short apsel) return ERROR_OK; } +static int stlink_dap_open_ap(unsigned short apsel) +{ + return stlink_usb_open_ap(stlink_dap_handle, apsel); +} + /** */ static int stlink_dap_closeall_ap(void) { |