]> git.gag.com Git - fw/stlink/blobdiff - src/stlink-usb.c
[fix] read_mem32 needs to add +1 to len
[fw/stlink] / src / stlink-usb.c
index 2ed5320e971f920542bac6f1df05520d231c4850..9c28e9f3bceff283d7f8bff54bcf16e2c3c5d2b5 100644 (file)
@@ -398,10 +398,11 @@ void _stlink_usb_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len) {
     buf[0] = STLINK_DEBUG_COMMAND;
     buf[1] = STLINK_DEBUG_READMEM_32BIT;
     write_uint32(buf + 2, addr);
-    /* windows usb logs show only one byte is used for length ... */
-    // Presumably, this is because usb transfers can't be 16 bits worth of bytes long...
-    assert (len < 256);
+
+    /* need to add +1 to len, otherwise get residue errors */
+    len += 1;
     buf[6] = (uint8_t) len;
+    buf[7] = (uint8_t) (len >> 8);
 
     size = send_recv(slu, buf, STLINK_CMD_SIZE, buf, sizeof (sl->q_buf));
     if (size == -1) {