This is an automated email from Gerrit. Antonio Borneo ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/5691
-- gerrit commit 659e5fa685c490c08011b9908a15f180a541fa17 Author: Antonio Borneo <[email protected]> Date: Thu May 21 13:24:32 2020 +0200 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 mode. Change-Id: I576955b5094bd41d63ff1fbad7b4fd9433253321 Signed-off-by: Antonio Borneo <[email protected]> Reported-by: Andreas Bolsch <[email protected]> diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index 03d3da7..845949c 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -360,6 +360,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) @@ -2989,6 +2990,7 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd) 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); @@ -3211,13 +3213,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) @@ -3226,7 +3228,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; @@ -3235,6 +3237,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) { -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
