You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

783 lines
18 KiB

  1. /***************************************************************************
  2. * *
  3. * Copyright (C) 2012 by Spencer Oliver *
  4. * spen@spen-soft.co.uk *
  5. * *
  6. * This program is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 2 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  18. ***************************************************************************/
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. /* project specific includes */
  23. #include <helper/binarybuffer.h>
  24. #include <jtag/interface.h>
  25. #include <jtag/hla/hla_layout.h>
  26. #include <jtag/hla/hla_transport.h>
  27. #include <jtag/hla/hla_interface.h>
  28. #include <target/target.h>
  29. #include <target/cortex_m.h>
  30. #include <libusb.h>
  31. #define ICDI_WRITE_ENDPOINT 0x02
  32. #define ICDI_READ_ENDPOINT 0x83
  33. #define ICDI_WRITE_TIMEOUT 1000
  34. #define ICDI_READ_TIMEOUT 1000
  35. #define ICDI_PACKET_SIZE 2048
  36. #define PACKET_START "$"
  37. #define PACKET_END "#"
  38. struct icdi_usb_handle_s {
  39. libusb_context *usb_ctx;
  40. libusb_device_handle *usb_dev;
  41. char *read_buffer;
  42. char *write_buffer;
  43. int max_packet;
  44. int read_count;
  45. uint32_t max_rw_packet; /* max X packet (read/write memory) transfers */
  46. };
  47. static int icdi_usb_read_mem(void *handle, uint32_t addr, uint32_t size,
  48. uint32_t count, uint8_t *buffer);
  49. static int icdi_usb_write_mem(void *handle, uint32_t addr, uint32_t size,
  50. uint32_t count, const uint8_t *buffer);
  51. static int remote_escape_output(const char *buffer, int len, char *out_buf, int *out_len, int out_maxlen)
  52. {
  53. int input_index, output_index;
  54. output_index = 0;
  55. for (input_index = 0; input_index < len; input_index++) {
  56. char b = buffer[input_index];
  57. if (b == '$' || b == '#' || b == '}' || b == '*') {
  58. /* These must be escaped. */
  59. if (output_index + 2 > out_maxlen)
  60. break;
  61. out_buf[output_index++] = '}';
  62. out_buf[output_index++] = b ^ 0x20;
  63. } else {
  64. if (output_index + 1 > out_maxlen)
  65. break;
  66. out_buf[output_index++] = b;
  67. }
  68. }
  69. *out_len = input_index;
  70. return output_index;
  71. }
  72. static int remote_unescape_input(const char *buffer, int len, char *out_buf, int out_maxlen)
  73. {
  74. int input_index, output_index;
  75. int escaped;
  76. output_index = 0;
  77. escaped = 0;
  78. for (input_index = 0; input_index < len; input_index++) {
  79. char b = buffer[input_index];
  80. if (output_index + 1 > out_maxlen)
  81. LOG_ERROR("Received too much data from the target.");
  82. if (escaped) {
  83. out_buf[output_index++] = b ^ 0x20;
  84. escaped = 0;
  85. } else if (b == '}')
  86. escaped = 1;
  87. else
  88. out_buf[output_index++] = b;
  89. }
  90. if (escaped)
  91. LOG_ERROR("Unmatched escape character in target response.");
  92. return output_index;
  93. }
  94. static int icdi_send_packet(void *handle, int len)
  95. {
  96. unsigned char cksum = 0;
  97. struct icdi_usb_handle_s *h = handle;
  98. int result, retry = 0;
  99. int transferred = 0;
  100. assert(handle != NULL);
  101. /* check we have a large enough buffer for checksum "#00" */
  102. if (len + 3 > h->max_packet) {
  103. LOG_ERROR("packet buffer too small");
  104. return ERROR_FAIL;
  105. }
  106. /* calculate checksum - offset start of packet */
  107. for (int i = 1; i < len; i++)
  108. cksum += h->write_buffer[i];
  109. len += sprintf(&h->write_buffer[len], PACKET_END "%02x", cksum);
  110. #ifdef _DEBUG_USB_COMMS_
  111. char buffer[50];
  112. char ch = h->write_buffer[1];
  113. if (ch == 'x' || ch == 'X')
  114. LOG_DEBUG("writing packet: <binary>");
  115. else {
  116. memcpy(buffer, h->write_buffer, len >= 50 ? 50-1 : len);
  117. buffer[len] = 0;
  118. LOG_DEBUG("writing packet: %s", buffer);
  119. }
  120. #endif
  121. while (1) {
  122. result = libusb_bulk_transfer(h->usb_dev, ICDI_WRITE_ENDPOINT, (unsigned char *)h->write_buffer, len,
  123. &transferred, ICDI_WRITE_TIMEOUT);
  124. if (result != 0 || transferred != len) {
  125. LOG_DEBUG("Error TX Data %d", result);
  126. return ERROR_FAIL;
  127. }
  128. /* check that the client got the message ok, or shall we resend */
  129. result = libusb_bulk_transfer(h->usb_dev, ICDI_READ_ENDPOINT, (unsigned char *)h->read_buffer, h->max_packet,
  130. &transferred, ICDI_READ_TIMEOUT);
  131. if (result != 0 || transferred < 1) {
  132. LOG_DEBUG("Error RX Data %d", result);
  133. return ERROR_FAIL;
  134. }
  135. #ifdef _DEBUG_USB_COMMS_
  136. LOG_DEBUG("received reply: '%c' : count %d", h->read_buffer[0], transferred);
  137. #endif
  138. if (h->read_buffer[0] == '-') {
  139. LOG_DEBUG("Resending packet %d", ++retry);
  140. } else {
  141. if (h->read_buffer[0] != '+')
  142. LOG_DEBUG("Unexpected Reply from ICDI: %c", h->read_buffer[0]);
  143. break;
  144. }
  145. if (retry == 3) {
  146. LOG_DEBUG("maximum nack retries attempted");
  147. return ERROR_FAIL;
  148. }
  149. }
  150. retry = 0;
  151. h->read_count = transferred;
  152. while (1) {
  153. /* read reply from icdi */
  154. result = libusb_bulk_transfer(h->usb_dev, ICDI_READ_ENDPOINT, (unsigned char *)h->read_buffer + h->read_count,
  155. h->max_packet - h->read_count, &transferred, ICDI_READ_TIMEOUT);
  156. #ifdef _DEBUG_USB_COMMS_
  157. LOG_DEBUG("received data: count %d", transferred);
  158. #endif
  159. /* check for errors but retry for timeout */
  160. if (result != 0) {
  161. if (result == LIBUSB_ERROR_TIMEOUT) {
  162. LOG_DEBUG("Error RX timeout %d", result);
  163. } else {
  164. LOG_DEBUG("Error RX Data %d", result);
  165. return ERROR_FAIL;
  166. }
  167. }
  168. h->read_count += transferred;
  169. /* we need to make sure we have a full packet, including checksum */
  170. if (h->read_count > 5) {
  171. /* check that we have received an packet delimiter
  172. * we do not validate the checksum
  173. * reply should contain $...#AA - so we check for # */
  174. if (h->read_buffer[h->read_count - 3] == '#')
  175. return ERROR_OK;
  176. }
  177. if (retry++ == 3) {
  178. LOG_DEBUG("maximum data retries attempted");
  179. break;
  180. }
  181. }
  182. return ERROR_FAIL;
  183. }
  184. static int icdi_send_cmd(void *handle, const char *cmd)
  185. {
  186. struct icdi_usb_handle_s *h = handle;
  187. int cmd_len = snprintf(h->write_buffer, h->max_packet, PACKET_START "%s", cmd);
  188. return icdi_send_packet(handle, cmd_len);
  189. }
  190. static int icdi_send_remote_cmd(void *handle, const char *data)
  191. {
  192. struct icdi_usb_handle_s *h = handle;
  193. size_t cmd_len = sprintf(h->write_buffer, PACKET_START "qRcmd,");
  194. cmd_len += hexify(h->write_buffer + cmd_len, data, 0, h->max_packet - cmd_len);
  195. return icdi_send_packet(handle, cmd_len);
  196. }
  197. static int icdi_get_cmd_result(void *handle)
  198. {
  199. struct icdi_usb_handle_s *h = handle;
  200. int offset = 0;
  201. char ch;
  202. assert(handle != NULL);
  203. do {
  204. ch = h->read_buffer[offset++];
  205. if (offset > h->read_count)
  206. return ERROR_FAIL;
  207. } while (ch != '$');
  208. if (memcmp("OK", h->read_buffer + offset, 2) == 0)
  209. return ERROR_OK;
  210. if (h->read_buffer[offset] == 'E') {
  211. /* get error code */
  212. uint8_t result;
  213. if (unhexify(&result, h->read_buffer + offset + 1, 1) != 1)
  214. return ERROR_FAIL;
  215. return result;
  216. }
  217. /* for now we assume everything else is ok */
  218. return ERROR_OK;
  219. }
  220. static int icdi_usb_idcode(void *handle, uint32_t *idcode)
  221. {
  222. *idcode = 0;
  223. return ERROR_OK;
  224. }
  225. static int icdi_usb_write_debug_reg(void *handle, uint32_t addr, uint32_t val)
  226. {
  227. uint8_t buf[4];
  228. /* REVISIT: There's no target pointer here so there's no way to use target_buffer_set_u32().
  229. * I guess all supported chips are little-endian anyway. */
  230. h_u32_to_le(buf, val);
  231. return icdi_usb_write_mem(handle, addr, 4, 1, buf);
  232. }
  233. static enum target_state icdi_usb_state(void *handle)
  234. {
  235. int result;
  236. struct icdi_usb_handle_s *h = handle;
  237. uint32_t dhcsr;
  238. uint8_t buf[4];
  239. result = icdi_usb_read_mem(h, DCB_DHCSR, 4, 1, buf);
  240. if (result != ERROR_OK)
  241. return TARGET_UNKNOWN;
  242. /* REVISIT: There's no target pointer here so there's no way to use target_buffer_get_u32().
  243. * I guess all supported chips are little-endian anyway. */
  244. dhcsr = le_to_h_u32(buf);
  245. if (dhcsr & S_HALT)
  246. return TARGET_HALTED;
  247. return TARGET_RUNNING;
  248. }
  249. static int icdi_usb_version(void *handle)
  250. {
  251. struct icdi_usb_handle_s *h = handle;
  252. char version[20];
  253. /* get info about icdi */
  254. int result = icdi_send_remote_cmd(handle, "version");
  255. if (result != ERROR_OK)
  256. return result;
  257. if (h->read_count < 8) {
  258. LOG_ERROR("Invalid Reply Received");
  259. return ERROR_FAIL;
  260. }
  261. /* convert reply */
  262. if (unhexify((uint8_t *)version, h->read_buffer + 2, 4) != 4) {
  263. LOG_WARNING("unable to get ICDI version");
  264. return ERROR_OK;
  265. }
  266. /* null terminate and print info */
  267. version[4] = 0;
  268. LOG_INFO("ICDI Firmware version: %s", version);
  269. return ERROR_OK;
  270. }
  271. static int icdi_usb_query(void *handle)
  272. {
  273. int result;
  274. struct icdi_usb_handle_s *h = handle;
  275. result = icdi_send_cmd(handle, "qSupported");
  276. if (result != ERROR_OK)
  277. return result;
  278. /* check result */
  279. result = icdi_get_cmd_result(handle);
  280. if (result != ERROR_OK) {
  281. LOG_ERROR("query supported failed: 0x%x", result);
  282. return ERROR_FAIL;
  283. }
  284. /* from this we can get the max packet supported */
  285. /* query packet buffer size */
  286. char *offset = strstr(h->read_buffer, "PacketSize");
  287. if (offset) {
  288. char *separator;
  289. int max_packet;
  290. max_packet = strtol(offset + 11, &separator, 16);
  291. if (!max_packet)
  292. LOG_ERROR("invalid max packet, using defaults");
  293. else
  294. h->max_packet = max_packet;
  295. LOG_DEBUG("max packet supported : %i bytes", h->max_packet);
  296. }
  297. /* if required re allocate packet buffer */
  298. if (h->max_packet != ICDI_PACKET_SIZE) {
  299. h->read_buffer = realloc(h->read_buffer, h->max_packet);
  300. h->write_buffer = realloc(h->write_buffer, h->max_packet);
  301. if (h->read_buffer == 0 || h->write_buffer == 0) {
  302. LOG_ERROR("unable to reallocate memory");
  303. return ERROR_FAIL;
  304. }
  305. }
  306. /* set extended mode */
  307. result = icdi_send_cmd(handle, "!");
  308. if (result != ERROR_OK)
  309. return result;
  310. /* check result */
  311. result = icdi_get_cmd_result(handle);
  312. if (result != ERROR_OK) {
  313. LOG_ERROR("unable to enable extended mode: 0x%x", result);
  314. return ERROR_FAIL;
  315. }
  316. return ERROR_OK;
  317. }
  318. static int icdi_usb_reset(void *handle)
  319. {
  320. /* we do this in hla_target.c */
  321. return ERROR_OK;
  322. }
  323. static int icdi_usb_assert_srst(void *handle, int srst)
  324. {
  325. /* TODO not supported yet */
  326. return ERROR_COMMAND_NOTFOUND;
  327. }
  328. static int icdi_usb_run(void *handle)
  329. {
  330. int result;
  331. /* resume target at current address */
  332. result = icdi_send_cmd(handle, "c");
  333. if (result != ERROR_OK)
  334. return result;
  335. /* check result */
  336. result = icdi_get_cmd_result(handle);
  337. if (result != ERROR_OK) {
  338. LOG_ERROR("continue failed: 0x%x", result);
  339. return ERROR_FAIL;
  340. }
  341. return result;
  342. }
  343. static int icdi_usb_halt(void *handle)
  344. {
  345. int result;
  346. /* this query halts the target ?? */
  347. result = icdi_send_cmd(handle, "?");
  348. if (result != ERROR_OK)
  349. return result;
  350. /* check result */
  351. result = icdi_get_cmd_result(handle);
  352. if (result != ERROR_OK) {
  353. LOG_ERROR("halt failed: 0x%x", result);
  354. return ERROR_FAIL;
  355. }
  356. return result;
  357. }
  358. static int icdi_usb_step(void *handle)
  359. {
  360. int result;
  361. /* step target at current address */
  362. result = icdi_send_cmd(handle, "s");
  363. if (result != ERROR_OK)
  364. return result;
  365. /* check result */
  366. result = icdi_get_cmd_result(handle);
  367. if (result != ERROR_OK) {
  368. LOG_ERROR("step failed: 0x%x", result);
  369. return ERROR_FAIL;
  370. }
  371. return result;
  372. }
  373. static int icdi_usb_read_regs(void *handle)
  374. {
  375. /* currently unsupported */
  376. return ERROR_OK;
  377. }
  378. static int icdi_usb_read_reg(void *handle, int num, uint32_t *val)
  379. {
  380. int result;
  381. struct icdi_usb_handle_s *h = handle;
  382. char cmd[10];
  383. snprintf(cmd, sizeof(cmd), "p%x", num);
  384. result = icdi_send_cmd(handle, cmd);
  385. if (result != ERROR_OK)
  386. return result;
  387. /* check result */
  388. result = icdi_get_cmd_result(handle);
  389. if (result != ERROR_OK) {
  390. LOG_ERROR("register read failed: 0x%x", result);
  391. return ERROR_FAIL;
  392. }
  393. /* convert result */
  394. uint8_t buf[4];
  395. if (unhexify(buf, h->read_buffer + 2, 4) != 4) {
  396. LOG_ERROR("failed to convert result");
  397. return ERROR_FAIL;
  398. }
  399. *val = le_to_h_u32(buf);
  400. return result;
  401. }
  402. static int icdi_usb_write_reg(void *handle, int num, uint32_t val)
  403. {
  404. int result;
  405. char cmd[20];
  406. uint8_t buf[4];
  407. h_u32_to_le(buf, val);
  408. int cmd_len = snprintf(cmd, sizeof(cmd), "P%x=", num);
  409. hexify(cmd + cmd_len, (const char *)buf, 4, sizeof(cmd));
  410. result = icdi_send_cmd(handle, cmd);
  411. if (result != ERROR_OK)
  412. return result;
  413. /* check result */
  414. result = icdi_get_cmd_result(handle);
  415. if (result != ERROR_OK) {
  416. LOG_ERROR("register write failed: 0x%x", result);
  417. return ERROR_FAIL;
  418. }
  419. return result;
  420. }
  421. static int icdi_usb_read_mem_int(void *handle, uint32_t addr, uint32_t len, uint8_t *buffer)
  422. {
  423. int result;
  424. struct icdi_usb_handle_s *h = handle;
  425. char cmd[20];
  426. snprintf(cmd, sizeof(cmd), "x%" PRIx32 ",%" PRIx32, addr, len);
  427. result = icdi_send_cmd(handle, cmd);
  428. if (result != ERROR_OK)
  429. return result;
  430. /* check result */
  431. result = icdi_get_cmd_result(handle);
  432. if (result != ERROR_OK) {
  433. LOG_ERROR("memory read failed: 0x%x", result);
  434. return ERROR_FAIL;
  435. }
  436. /* unescape input */
  437. int read_len = remote_unescape_input(h->read_buffer + 5, h->read_count - 8, (char *)buffer, len);
  438. if (read_len != (int)len) {
  439. LOG_ERROR("read more bytes than expected: actual 0x%x expected 0x%" PRIx32, read_len, len);
  440. return ERROR_FAIL;
  441. }
  442. return ERROR_OK;
  443. }
  444. static int icdi_usb_write_mem_int(void *handle, uint32_t addr, uint32_t len, const uint8_t *buffer)
  445. {
  446. int result;
  447. struct icdi_usb_handle_s *h = handle;
  448. size_t cmd_len = snprintf(h->write_buffer, h->max_packet, PACKET_START "X%" PRIx32 ",%" PRIx32 ":", addr, len);
  449. int out_len;
  450. cmd_len += remote_escape_output((const char *)buffer, len, h->write_buffer + cmd_len,
  451. &out_len, h->max_packet - cmd_len);
  452. if (out_len < (int)len) {
  453. /* for now issue a error as we have no way of allocating a larger buffer */
  454. LOG_ERROR("memory buffer too small: requires 0x%x actual 0x%" PRIx32, out_len, len);
  455. return ERROR_FAIL;
  456. }
  457. result = icdi_send_packet(handle, cmd_len);
  458. if (result != ERROR_OK)
  459. return result;
  460. /* check result */
  461. result = icdi_get_cmd_result(handle);
  462. if (result != ERROR_OK) {
  463. LOG_ERROR("memory write failed: 0x%x", result);
  464. return ERROR_FAIL;
  465. }
  466. return ERROR_OK;
  467. }
  468. static int icdi_usb_read_mem(void *handle, uint32_t addr, uint32_t size,
  469. uint32_t count, uint8_t *buffer)
  470. {
  471. int retval = ERROR_OK;
  472. struct icdi_usb_handle_s *h = handle;
  473. uint32_t bytes_remaining;
  474. /* calculate byte count */
  475. count *= size;
  476. while (count) {
  477. bytes_remaining = h->max_rw_packet;
  478. if (count < bytes_remaining)
  479. bytes_remaining = count;
  480. retval = icdi_usb_read_mem_int(handle, addr, bytes_remaining, buffer);
  481. if (retval != ERROR_OK)
  482. return retval;
  483. buffer += bytes_remaining;
  484. addr += bytes_remaining;
  485. count -= bytes_remaining;
  486. }
  487. return retval;
  488. }
  489. static int icdi_usb_write_mem(void *handle, uint32_t addr, uint32_t size,
  490. uint32_t count, const uint8_t *buffer)
  491. {
  492. int retval = ERROR_OK;
  493. struct icdi_usb_handle_s *h = handle;
  494. uint32_t bytes_remaining;
  495. /* calculate byte count */
  496. count *= size;
  497. while (count) {
  498. bytes_remaining = h->max_rw_packet;
  499. if (count < bytes_remaining)
  500. bytes_remaining = count;
  501. retval = icdi_usb_write_mem_int(handle, addr, bytes_remaining, buffer);
  502. if (retval != ERROR_OK)
  503. return retval;
  504. buffer += bytes_remaining;
  505. addr += bytes_remaining;
  506. count -= bytes_remaining;
  507. }
  508. return retval;
  509. }
  510. static int icdi_usb_override_target(const char *targetname)
  511. {
  512. return !strcmp(targetname, "cortex_m");
  513. }
  514. static int icdi_usb_close(void *handle)
  515. {
  516. struct icdi_usb_handle_s *h = handle;
  517. if (!h)
  518. return ERROR_OK;
  519. if (h->usb_dev)
  520. libusb_close(h->usb_dev);
  521. if (h->usb_ctx)
  522. libusb_exit(h->usb_ctx);
  523. if (h->read_buffer)
  524. free(h->read_buffer);
  525. if (h->write_buffer)
  526. free(h->write_buffer);
  527. free(handle);
  528. return ERROR_OK;
  529. }
  530. static int icdi_usb_open(struct hl_interface_param_s *param, void **fd)
  531. {
  532. int retval;
  533. struct icdi_usb_handle_s *h;
  534. LOG_DEBUG("icdi_usb_open");
  535. h = calloc(1, sizeof(struct icdi_usb_handle_s));
  536. if (h == 0) {
  537. LOG_ERROR("unable to allocate memory");
  538. return ERROR_FAIL;
  539. }
  540. LOG_DEBUG("transport: %d vid: 0x%04x pid: 0x%04x", param->transport,
  541. param->vid, param->pid);
  542. if (libusb_init(&h->usb_ctx) != 0) {
  543. LOG_ERROR("libusb init failed");
  544. goto error_open;
  545. }
  546. h->usb_dev = libusb_open_device_with_vid_pid(h->usb_ctx, param->vid, param->pid);
  547. if (!h->usb_dev) {
  548. LOG_ERROR("open failed");
  549. goto error_open;
  550. }
  551. if (libusb_claim_interface(h->usb_dev, 2)) {
  552. LOG_DEBUG("claim interface failed");
  553. goto error_open;
  554. }
  555. /* check if mode is supported */
  556. retval = ERROR_OK;
  557. switch (param->transport) {
  558. #if 0
  559. /* TODO place holder as swd is not currently supported */
  560. case HL_TRANSPORT_SWD:
  561. #endif
  562. case HL_TRANSPORT_JTAG:
  563. break;
  564. default:
  565. retval = ERROR_FAIL;
  566. break;
  567. }
  568. if (retval != ERROR_OK) {
  569. LOG_ERROR("mode (transport) not supported by device");
  570. goto error_open;
  571. }
  572. /* allocate buffer */
  573. h->read_buffer = malloc(ICDI_PACKET_SIZE);
  574. h->write_buffer = malloc(ICDI_PACKET_SIZE);
  575. h->max_packet = ICDI_PACKET_SIZE;
  576. if (h->read_buffer == 0 || h->write_buffer == 0) {
  577. LOG_DEBUG("malloc failed");
  578. goto error_open;
  579. }
  580. /* query icdi version etc */
  581. retval = icdi_usb_version(h);
  582. if (retval != ERROR_OK)
  583. goto error_open;
  584. /* query icdi support */
  585. retval = icdi_usb_query(h);
  586. if (retval != ERROR_OK)
  587. goto error_open;
  588. *fd = h;
  589. /* set the max target read/write buffer in bytes
  590. * as we are using gdb binary packets to transfer memory we have to
  591. * reserve half the buffer for any possible escape chars plus
  592. * at least 64 bytes for the gdb packet header */
  593. h->max_rw_packet = (((h->max_packet - 64) / 4) * 4) / 2;
  594. return ERROR_OK;
  595. error_open:
  596. icdi_usb_close(h);
  597. return ERROR_FAIL;
  598. }
  599. struct hl_layout_api_s icdi_usb_layout_api = {
  600. .open = icdi_usb_open,
  601. .close = icdi_usb_close,
  602. .idcode = icdi_usb_idcode,
  603. .state = icdi_usb_state,
  604. .reset = icdi_usb_reset,
  605. .assert_srst = icdi_usb_assert_srst,
  606. .run = icdi_usb_run,
  607. .halt = icdi_usb_halt,
  608. .step = icdi_usb_step,
  609. .read_regs = icdi_usb_read_regs,
  610. .read_reg = icdi_usb_read_reg,
  611. .write_reg = icdi_usb_write_reg,
  612. .read_mem = icdi_usb_read_mem,
  613. .write_mem = icdi_usb_write_mem,
  614. .write_debug_reg = icdi_usb_write_debug_reg,
  615. .override_target = icdi_usb_override_target,
  616. .custom_command = icdi_send_remote_cmd,
  617. };