stlink: fix connect under reset issues
We need to make sure that srst is asserted before we attempt to switch into jtag or swd mode otherwise we receive a error (-9) - invalid device id. Change-Id: I625166c751cfba8e8a5290f40122bb9afc9dbb39 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/1315 Tested-by: jenkins
This commit is contained in:
@@ -579,8 +579,10 @@ static int stlink_usb_mode_leave(void *handle, enum stlink_mode type)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int stlink_usb_assert_srst(void *handle, int srst);
|
||||
|
||||
/** */
|
||||
static int stlink_usb_init_mode(void *handle)
|
||||
static int stlink_usb_init_mode(void *handle, bool connect_under_reset)
|
||||
{
|
||||
int res;
|
||||
uint8_t mode;
|
||||
@@ -674,6 +676,12 @@ static int stlink_usb_init_mode(void *handle)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
if (connect_under_reset) {
|
||||
res = stlink_usb_assert_srst(handle, 0);
|
||||
if (res != ERROR_OK)
|
||||
return res;
|
||||
}
|
||||
|
||||
res = stlink_usb_mode_enter(handle, emode);
|
||||
|
||||
if (res != ERROR_OK)
|
||||
@@ -1314,7 +1322,7 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
h->jtag_api = api;
|
||||
|
||||
/* initialize the debug hardware */
|
||||
err = stlink_usb_init_mode(h);
|
||||
err = stlink_usb_init_mode(h, param->connect_under_reset);
|
||||
|
||||
if (err != ERROR_OK) {
|
||||
LOG_ERROR("init mode failed");
|
||||
|
||||
Reference in New Issue
Block a user