[fix] flash tool. not working for stm32l, ok with stm32vl
[fw/stlink] / src / stlink-usb.c
index 6eb456c88011d4f5687c69a696aac7c8751eb4df..533a632ea081ca461e14aa4dd3aa0dc02219be91 100644 (file)
@@ -398,10 +398,8 @@ 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);
     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) {
@@ -702,6 +700,20 @@ on_libusb_error:
 
     sl->backend = &_stlink_usb_backend;
     sl->backend_data = slu;
+
+    /* flash memory settings */
+    sl->flash_base = STM32_FLASH_BASE;
+    sl->flash_size = STM32_FLASH_SIZE;
+    sl->flash_pgsz = STM32_FLASH_PGSZ;
+
+    /* system memory */
+    sl->sys_base = STM32_SYSTEM_BASE;
+    sl->sys_size = STM32_SYSTEM_SIZE;
+
+    /* sram memory settings */
+    sl->sram_base = STM32_SRAM_BASE;
+    sl->sram_size = STM32L_SRAM_SIZE;
+
     /* success */
     return sl;