Index: umsboot/src/protocol/usb/usb.c |
— | — | @@ -377,7 +377,7 @@ |
378 | 378 | { |
379 | 379 | int epidx; |
380 | 380 | int ifidx; |
381 | | - const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &epidx, &ifidx); |
| 381 | + const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &ifidx, &epidx); |
382 | 382 | if (!endpoint) data->driver->unconfigure_ep(data, epnum); |
383 | 383 | else if (endpoint->timeout) endpoint->timeout(data, ifidx, epidx, bytesleft); |
384 | 384 | } |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | { |
406 | 406 | int epidx; |
407 | 407 | int ifidx; |
408 | | - const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &epidx, &ifidx); |
| 408 | + const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &ifidx, &epidx); |
409 | 409 | if (!endpoint) usb_unconfigure_ep(data, epnum); |
410 | 410 | else if (endpoint->xfer_complete) endpoint->xfer_complete(data, ifidx, epidx, bytesleft); |
411 | 411 | } |
— | — | @@ -420,7 +420,7 @@ |
421 | 421 | { |
422 | 422 | int epidx; |
423 | 423 | int ifidx; |
424 | | - const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &epidx, &ifidx); |
| 424 | + const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &ifidx, &epidx); |
425 | 425 | if (!endpoint) usb_unconfigure_ep(data, epnum); |
426 | 426 | else if (endpoint->setup_received) endpoint->setup_received(data, ifidx, epidx); |
427 | 427 | } |
Index: emcore/trunk/usb/usbdebug.c |
— | — | @@ -174,9 +174,9 @@ |
175 | 175 | case 1: // START MEMORY TRANSFER
|
176 | 176 | bulk_state[bulk_ctrlreq_ep].addr = (void*)buf[1];
|
177 | 177 | bulk_state[bulk_ctrlreq_ep].size = buf[2];
|
178 | | - usbdebug_bulk_xfer_complete(data, 0, bulk_ctrlreq_ep, 0); // Convenient way to start a transfer.
|
179 | 178 | usb_set_stall(data, ep0out, true);
|
180 | 179 | usb_ep0_start_tx(data, NULL, 0, NULL);
|
| 180 | + usbdebug_bulk_xfer_complete(data, 0, bulk_ctrlreq_ep, 0); // Convenient way to start a transfer.
|
181 | 181 | break;
|
182 | 182 | default:
|
183 | 183 | usb_set_stall(data, ep0out, true);
|
Index: emcore/trunk/usb/usb.c |
— | — | @@ -377,7 +377,7 @@ |
378 | 378 | { |
379 | 379 | int epidx; |
380 | 380 | int ifidx; |
381 | | - const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &epidx, &ifidx); |
| 381 | + const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &ifidx, &epidx); |
382 | 382 | if (!endpoint) data->driver->unconfigure_ep(data, epnum); |
383 | 383 | else if (endpoint->timeout) endpoint->timeout(data, ifidx, epidx, bytesleft); |
384 | 384 | } |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | { |
406 | 406 | int epidx; |
407 | 407 | int ifidx; |
408 | | - const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &epidx, &ifidx); |
| 408 | + const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &ifidx, &epidx); |
409 | 409 | if (!endpoint) usb_unconfigure_ep(data, epnum); |
410 | 410 | else if (endpoint->xfer_complete) endpoint->xfer_complete(data, ifidx, epidx, bytesleft); |
411 | 411 | } |
— | — | @@ -420,7 +420,7 @@ |
421 | 421 | { |
422 | 422 | int epidx; |
423 | 423 | int ifidx; |
424 | | - const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &epidx, &ifidx); |
| 424 | + const struct usb_endpoint* endpoint = usb_find_endpoint(data, epnum, &ifidx, &epidx); |
425 | 425 | if (!endpoint) usb_unconfigure_ep(data, epnum); |
426 | 426 | else if (endpoint->setup_received) endpoint->setup_received(data, ifidx, epidx); |
427 | 427 | } |
Index: emcore/trunk/tools/libemcore.py |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | """
|
129 | 129 | return self.lib.monitorcommand(struct.pack("<IIII%ds" % len(data), 5, addr, len(data), 0, data), "III", (None, None, None))
|
130 | 130 |
|
131 | | - @command()
|
| 131 | + @command(timeout = 10000)
|
132 | 132 | def _readmem_bulk(self, addr, size):
|
133 | 133 | """ Reads the memory from location 'addr' with size 'size'
|
134 | 134 | from the device. Can handle unlimited amounts of bytes,
|
— | — | @@ -135,7 +135,7 @@ |
136 | 136 | """
|
137 | 137 | return self.lib.recvbulk(struct.pack("<III", 1, addr, size), size)
|
138 | 138 |
|
139 | | - @command()
|
| 139 | + @command(timeout = 10000)
|
140 | 140 | def _writemem_bulk(self, addr, data):
|
141 | 141 | """ Writes the data in 'data' to the location 'addr'
|
142 | 142 | in the memory of the device. Can handle unlimited amounts of bytes,
|
— | — | @@ -199,10 +199,11 @@ |
200 | 200 | size -= align
|
201 | 201 | align = size & 63
|
202 | 202 | size -= align
|
203 | | - data += self._readmem_bulk(addr, size)
|
204 | | - addr += size
|
| 203 | + if size:
|
| 204 | + data += self._readmem_bulk(addr, size)
|
| 205 | + addr += size
|
205 | 206 | size = align
|
206 | | - except: self.logger.warn("Bulk read interface failed, falling back to slow reads\n")
|
| 207 | + except: raise#self.logger.warn("Bulk read interface failed, falling back to slow reads\n")
|
207 | 208 | while size > 0:
|
208 | 209 | readsize = min(size, 0xf00)
|
209 | 210 | data += self._readmem(addr, readsize)
|
— | — | @@ -228,9 +229,10 @@ |
229 | 230 | size -= align
|
230 | 231 | align = size & 63
|
231 | 232 | size -= align
|
232 | | - self._writemem_bulk(addr, data[offset:offset+size])
|
233 | | - offset += size
|
234 | | - addr += size
|
| 233 | + if size:
|
| 234 | + self._writemem_bulk(addr, data[offset:offset+size])
|
| 235 | + offset += size
|
| 236 | + addr += size
|
235 | 237 | size = align
|
236 | 238 | except: self.logger.warn("Bulk write interface failed, falling back to slow writes\n")
|
237 | 239 | while size > 0:
|
— | — | @@ -1104,11 +1106,11 @@ |
1105 | 1107 | return writelen
|
1106 | 1108 |
|
1107 | 1109 | def sendbulk(self, cmd, data):
|
1108 | | - self.logger.debug("Sending bulk command [0x%s]\n" % base64.b16encode(cmd[3::-1]).decode("ascii"))
|
| 1110 | + self.logger.debug("Sending bulk command [0x%s] with %d bytes\n" % (base64.b16encode(cmd[3::-1]).decode("ascii"), len(data)))
|
1109 | 1111 | return self.dev.sendbulk(cmd, data)
|
1110 | 1112 |
|
1111 | 1113 | def recvbulk(self, cmd, size):
|
1112 | | - self.logger.debug("Receiving bulk command [0x%s]\n" % base64.b16encode(cmd[3::-1]).decode("ascii"))
|
| 1114 | + self.logger.debug("Receiving bulk command [0x%s] with %d bytes\n" % (base64.b16encode(cmd[3::-1]).decode("ascii"), size))
|
1113 | 1115 | return self.dev.recvbulk(cmd, size)
|
1114 | 1116 |
|
1115 | 1117 |
|
— | — | @@ -1198,9 +1200,9 @@ |
1199 | 1201 | return data
|
1200 | 1202 |
|
1201 | 1203 | def sendbulk(self, cmd, data):
|
1202 | | - size = self.dev.ctrl_transfer(0x42, 0x00, 0, self.bulkout.bEndpointAddress, cmd, self.timeout)
|
1203 | | - if size != len(cmd):
|
1204 | | - raise SendError("Bulk send command could not be fully sent (%d of %d)!" % (size, len(cmd)))
|
| 1204 | + cmdsize = self.dev.ctrl_transfer(0x42, 0x00, 0, self.bulkout.bEndpointAddress, cmd, self.timeout)
|
| 1205 | + if cmdsize != len(cmd):
|
| 1206 | + raise SendError("Bulk send command could not be fully sent (%d of %d)!" % (cmdsize, len(cmd)))
|
1205 | 1207 | size = self.bulkout.write(data, self.timeout)
|
1206 | 1208 | if size != len(data):
|
1207 | 1209 | raise SendError("Bulk data could not be fully sent (%d of %d)!" % (size, len(data)))
|
— | — | @@ -1207,12 +1209,12 @@ |
1208 | 1210 | return size
|
1209 | 1211 |
|
1210 | 1212 | def recvbulk(self, cmd, size):
|
1211 | | - size = self.dev.ctrl_transfer(0x42, 0x00, 0, self.bulkin.bEndpointAddress, cmd, self.timeout)
|
1212 | | - if size != len(cmd):
|
1213 | | - raise ReceiveError("Bulk receive command could not be fully sent (%d of %d)!" % (size, len(cmd)))
|
| 1213 | + cmdsize = self.dev.ctrl_transfer(0x42, 0x00, 0, self.bulkin.bEndpointAddress, cmd, self.timeout)
|
| 1214 | + if cmdsize != len(cmd):
|
| 1215 | + raise ReceiveError("Bulk receive command could not be fully sent (%d of %d)!" % (cmdsize, len(cmd)))
|
1214 | 1216 | data = self.bulkin.read(size, self.timeout)
|
1215 | 1217 | if len(data) != size:
|
1216 | | - raise SendError("Bulk data could not be fully received (%d of %d)!" % (len(cmd), size))
|
| 1218 | + raise SendError("Bulk data could not be fully received (%d of %d)!" % (len(data), size))
|
1217 | 1219 | return data
|
1218 | 1220 |
|
1219 | 1221 |
|