This is an automated email from Gerrit.

Ake Rehnman ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/4320

-- gerrit

commit 54ac89f3ac04e80dd1a1295f7c01d33f0611e9fc
Author: Ake Rehnman <[email protected]>
Date:   Tue Jan 2 03:17:08 2018 +0100

    stlink_usb : Resolved a collision with JTAG API v1 and
    error/status checking overwriting SWIM status bytes.
    
    Change-Id: I48919b49ec956348dee6528143b5537306c4b48f
    Signed-off-by: Ake Rehnman <[email protected]>

diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 818bdee..6f720b8 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -425,10 +425,6 @@ static int stlink_usb_error_check(void *handle)
 
        assert(handle != NULL);
 
-       /* TODO: no error checking yet on api V1 */
-       if (h->jtag_api == STLINK_JTAG_API_V1)
-               h->databuf[0] = STLINK_DEBUG_ERR_OK;
-
        if (h->transport == HL_TRANSPORT_SWIM) {
                switch (h->databuf[0]) {
                        case STLINK_SWIM_ERR_OK:
@@ -441,6 +437,10 @@ static int stlink_usb_error_check(void *handle)
                }
        }
 
+       /* TODO: no error checking yet on api V1 */
+       if (h->jtag_api == STLINK_JTAG_API_V1)
+               h->databuf[0] = STLINK_DEBUG_ERR_OK;
+
        switch (h->databuf[0]) {
                case STLINK_DEBUG_ERR_OK:
                        return ERROR_OK;
@@ -1960,9 +1960,10 @@ static int stlink_usb_close(void *handle)
        enum stlink_mode emode;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
-
-       res = stlink_usb_current_mode(handle, &mode);
+       if (h && h->fd)
+               res = stlink_usb_current_mode(handle, &mode);
+       else
+               res = ERROR_FAIL;
        /* do not exit if return code != ERROR_OK,
           it prevents us from closing jtag_libusb */
 

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to