stlink-v1: fix memory writes 78/478/2
authorSzymon Modzelewski <szmodzelewski@gmail.com>
Tue, 21 Feb 2012 12:44:00 +0000 (13:44 +0100)
committerSzymon Modzelewski <szmodzelewski@gmail.com>
Tue, 21 Feb 2012 18:19:45 +0000 (19:19 +0100)
implement stlink_usb_send and use it to fix stlink_usb_write_mem

using two calls to stlink_usb_recv is inappropriate since each
call issues a SG command on stlink-v1, resulting in errors

Change-Id: I52ff9ee8f5d9ae0d47356477468eb98952205c99
Signed-off-by: Szymon Modzelewski <szmodzelewski@gmail.com>
src/jtag/drivers/stlink_usb.c

index f7ad7c034588eb137208bea26acbec1006ce7e79..e3c005e4ad42997d42009cd2c985d1a9ca8e477a 100644 (file)
@@ -368,6 +368,13 @@ static int stlink_usb_recv(void *handle, const uint8_t *cmd, int cmdsize, uint8_
        return stlink_usb_xfer(handle, cmd, cmdsize, STLINK_RX_EP, rxbuf, rxsize);
 }
 
+/** */
+static int stlink_usb_send(void *handle, const uint8_t *cmd, int cmdsize, uint8_t *txbuf,
+                   int txsize)
+{
+       return stlink_usb_xfer(handle, cmd, cmdsize, STLINK_TX_EP, txbuf, txsize);
+}
+
 /** */
 static void stlink_usb_init_buffer(void *handle)
 {
@@ -971,12 +978,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len,
        h_u32_to_le(h->txbuf + 2, addr);
        h_u16_to_le(h->txbuf + 2 + 4, len);
 
-       res = stlink_usb_recv(handle, h->txbuf, STLINK_CMD_SIZE, 0, 0);
-
-       if (res != ERROR_OK)
-               return res;
-
-       res = stlink_usb_recv(handle, (uint8_t *) buffer, len, 0, 0);
+       res = stlink_usb_send(handle, h->txbuf, STLINK_CMD_SIZE, (uint8_t *) buffer, len);
 
        if (res != ERROR_OK)
                return res;
@@ -1034,12 +1036,7 @@ static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
        h_u32_to_le(h->txbuf + 2, addr);
        h_u16_to_le(h->txbuf + 2 + 4, len);
 
-       res = stlink_usb_recv(handle, h->txbuf, STLINK_CMD_SIZE, 0, 0);
-
-       if (res != ERROR_OK)
-               return res;
-
-       res = stlink_usb_recv(handle, (uint8_t *) buffer, len, 0, 0);
+       res = stlink_usb_send(handle, h->txbuf, STLINK_CMD_SIZE, (uint8_t *) buffer, len);
 
        if (res != ERROR_OK)
                return res;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)