aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSzymon Modzelewski <szmodzelewski@gmail.com>2012-02-21 13:44:00 +0100
committerSpencer Oliver <spen@spen-soft.co.uk>2012-02-29 11:19:18 +0000
commit6dfd56a7432fd7daa60ef8caa78f13576049de03 (patch)
tree29f9c476d87d4efed3ae0edaa15898048dce9033 /src
parent30a4271b414ca0931cb485785f3c6834f966b345 (diff)
downloadriscv-openocd-6dfd56a7432fd7daa60ef8caa78f13576049de03.zip
riscv-openocd-6dfd56a7432fd7daa60ef8caa78f13576049de03.tar.gz
riscv-openocd-6dfd56a7432fd7daa60ef8caa78f13576049de03.tar.bz2
stlink-v1: fix memory writes
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> Reviewed-on: http://openocd.zylin.com/478 Tested-by: jenkins Reviewed-by: Mathias Küster <kesmtp@freenet.de> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/jtag/drivers/stlink_usb.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 3cb2434..087e7bf 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -351,6 +351,13 @@ static int stlink_usb_recv(void *handle, const uint8_t *txbuf, int txsize, uint8
}
/** */
+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)
{
struct stlink_usb_handle_s *h;
@@ -953,12 +960,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;
@@ -1016,12 +1018,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;