1 /***************************************************************************
2 * Copyright (C) 2006 by Magnus Lundin *
5 * Copyright (C) 2008 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
8 * Copyright (C) 2009 by Oyvind Harboe *
9 * oyvind.harboe@zylin.com *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 ***************************************************************************/
29 * This file implements support for the ARM Debug Interface version 5 (ADIv5)
30 * debugging architecture. Compared with previous versions, this includes
31 * a low pin-count Serial Wire Debug (SWD) alternative to JTAG for message
32 * transport, and focusses on memory mapped resources as defined by the
33 * CoreSight architecture.
35 * A key concept in ADIv5 is the Debug Access Port, or DAP. A DAP has two
36 * basic components: a Debug Port (DP) transporting messages to and from a
37 * debugger, and an Access Port (AP) accessing resources. Three types of DP
38 * are defined. One uses only JTAG for communication, and is called JTAG-DP.
39 * One uses only SWD for communication, and is called SW-DP. The third can
40 * use either SWD or JTAG, and is called SWJ-DP. The most common type of AP
41 * is used to access memory mapped resources and is called a MEM-AP. Also a
42 * JTAG-AP is also defined, bridging to JTAG resources; those are uncommon.
46 * Relevant specifications from ARM include:
48 * ARM(tm) Debug Interface v5 Architecture Specification ARM IHI 0031A
49 * CoreSight(tm) v1.0 Architecture Specification ARM IHI 0029B
51 * CoreSight(tm) DAP-Lite TRM, ARM DDI 0316D
52 * Cortex-M3(tm) TRM, ARM DDI 0337G
59 #include "arm_adi_v5.h"
60 #include <helper/time_support.h>
64 * swjdp->trans_mode = TRANS_MODE_COMPOSITE;
65 * Uses Overrun checking mode and does not do actual JTAG send/receive or transaction
66 * result checking until swjdp_end_transaction()
67 * This must be done before using or deallocating any return variables.
68 * swjdp->trans_mode == TRANS_MODE_ATOMIC
69 * All reads and writes to the AHB bus are checked for valid completion, and return values
70 * are immediatley available.
74 /* ARM ADI Specification requires at least 10 bits used for TAR autoincrement */
77 uint32_t tar_block_size(uint32_t address)
78 Return the largest block starting at address that does not cross a tar block size alignment boundary
80 static uint32_t max_tar_block_size(uint32_t tar_autoincr_block
, uint32_t address
)
82 return (tar_autoincr_block
- ((tar_autoincr_block
- 1) & address
)) >> 2;
85 /***************************************************************************
87 * DPACC and APACC scanchain access through JTAG-DP *
89 ***************************************************************************/
91 /* Scan out and in from target ordered uint8_t buffers */
92 static int adi_jtag_dp_scan(struct swjdp_common
*swjdp
,
93 uint8_t instr
, uint8_t reg_addr
, uint8_t RnW
,
94 uint8_t *outvalue
, uint8_t *invalue
, uint8_t *ack
)
96 struct arm_jtag
*jtag_info
= swjdp
->jtag_info
;
97 struct scan_field fields
[2];
100 jtag_set_end_state(TAP_IDLE
);
101 arm_jtag_set_instr(jtag_info
, instr
, NULL
);
103 /* Add specified number of tck clocks before accessing memory bus */
104 if ((instr
== DAP_IR_APACC
) && ((reg_addr
== AP_REG_DRW
)||((reg_addr
&0xF0) == AP_REG_BD0
))&& (swjdp
->memaccess_tck
!= 0))
105 jtag_add_runtest(swjdp
->memaccess_tck
, jtag_set_end_state(TAP_IDLE
));
107 fields
[0].tap
= jtag_info
->tap
;
108 fields
[0].num_bits
= 3;
109 buf_set_u32(&out_addr_buf
, 0, 3, ((reg_addr
>> 1) & 0x6) | (RnW
& 0x1));
110 fields
[0].out_value
= &out_addr_buf
;
111 fields
[0].in_value
= ack
;
113 fields
[1].tap
= jtag_info
->tap
;
114 fields
[1].num_bits
= 32;
115 fields
[1].out_value
= outvalue
;
116 fields
[1].in_value
= invalue
;
118 jtag_add_dr_scan(2, fields
, jtag_get_end_state());
123 /* Scan out and in from host ordered uint32_t variables */
124 static int adi_jtag_dp_scan_u32(struct swjdp_common
*swjdp
,
125 uint8_t instr
, uint8_t reg_addr
, uint8_t RnW
,
126 uint32_t outvalue
, uint32_t *invalue
, uint8_t *ack
)
128 struct arm_jtag
*jtag_info
= swjdp
->jtag_info
;
129 struct scan_field fields
[2];
130 uint8_t out_value_buf
[4];
131 uint8_t out_addr_buf
;
133 jtag_set_end_state(TAP_IDLE
);
134 arm_jtag_set_instr(jtag_info
, instr
, NULL
);
136 /* Add specified number of tck clocks before accessing memory bus */
137 if ((instr
== DAP_IR_APACC
) && ((reg_addr
== AP_REG_DRW
)||((reg_addr
&0xF0) == AP_REG_BD0
))&& (swjdp
->memaccess_tck
!= 0))
138 jtag_add_runtest(swjdp
->memaccess_tck
, jtag_set_end_state(TAP_IDLE
));
140 fields
[0].tap
= jtag_info
->tap
;
141 fields
[0].num_bits
= 3;
142 buf_set_u32(&out_addr_buf
, 0, 3, ((reg_addr
>> 1) & 0x6) | (RnW
& 0x1));
143 fields
[0].out_value
= &out_addr_buf
;
144 fields
[0].in_value
= ack
;
146 fields
[1].tap
= jtag_info
->tap
;
147 fields
[1].num_bits
= 32;
148 buf_set_u32(out_value_buf
, 0, 32, outvalue
);
149 fields
[1].out_value
= out_value_buf
;
150 fields
[1].in_value
= NULL
;
154 fields
[1].in_value
= (uint8_t *)invalue
;
155 jtag_add_dr_scan(2, fields
, jtag_get_end_state());
157 jtag_add_callback(arm_le_to_h_u32
, (jtag_callback_data_t
) invalue
);
161 jtag_add_dr_scan(2, fields
, jtag_get_end_state());
167 /* scan_inout_check adds one extra inscan for DPAP_READ commands to read variables */
168 static int scan_inout_check(struct swjdp_common
*swjdp
,
169 uint8_t instr
, uint8_t reg_addr
, uint8_t RnW
,
170 uint8_t *outvalue
, uint8_t *invalue
)
172 adi_jtag_dp_scan(swjdp
, instr
, reg_addr
, RnW
, outvalue
, NULL
, NULL
);
174 if ((RnW
== DPAP_READ
) && (invalue
!= NULL
))
176 adi_jtag_dp_scan(swjdp
, DAP_IR_DPACC
, DP_RDBUFF
, DPAP_READ
, 0, invalue
, &swjdp
->ack
);
179 /* In TRANS_MODE_ATOMIC all DAP_IR_APACC transactions wait for ack = OK/FAULT and the check CTRL_STAT */
180 if ((instr
== DAP_IR_APACC
) && (swjdp
->trans_mode
== TRANS_MODE_ATOMIC
))
182 return swjdp_transaction_endcheck(swjdp
);
188 static int scan_inout_check_u32(struct swjdp_common
*swjdp
,
189 uint8_t instr
, uint8_t reg_addr
, uint8_t RnW
,
190 uint32_t outvalue
, uint32_t *invalue
)
192 adi_jtag_dp_scan_u32(swjdp
, instr
, reg_addr
, RnW
, outvalue
, NULL
, NULL
);
194 if ((RnW
== DPAP_READ
) && (invalue
!= NULL
))
196 adi_jtag_dp_scan_u32(swjdp
, DAP_IR_DPACC
, DP_RDBUFF
, DPAP_READ
, 0, invalue
, &swjdp
->ack
);
199 /* In TRANS_MODE_ATOMIC all DAP_IR_APACC transactions wait for ack = OK/FAULT and then check CTRL_STAT */
200 if ((instr
== DAP_IR_APACC
) && (swjdp
->trans_mode
== TRANS_MODE_ATOMIC
))
202 return swjdp_transaction_endcheck(swjdp
);
208 int swjdp_transaction_endcheck(struct swjdp_common
*swjdp
)
213 /* too expensive to call keep_alive() here */
216 /* Danger!!!! BROKEN!!!! */
217 scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, DP_CTRL_STAT
, DPAP_READ
, 0, &ctrlstat
);
218 /* Danger!!!! BROKEN!!!! Why will jtag_execute_queue() fail here????
219 R956 introduced the check on return value here and now Michael Schwingen reports
220 that this code no longer works....
222 https://lists.berlios.de/pipermail/openocd-development/2008-September/003107.html
224 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
226 LOG_ERROR("BUG: Why does this fail the first time????");
228 /* Why??? second time it works??? */
231 scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, DP_CTRL_STAT
, DPAP_READ
, 0, &ctrlstat
);
232 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
235 swjdp
->ack
= swjdp
->ack
& 0x7;
239 long long then
= timeval_ms();
240 while (swjdp
->ack
!= 2)
244 if ((timeval_ms()-then
) > 1000)
246 LOG_WARNING("Timeout (1000ms) waiting for ACK = OK/FAULT in SWJDP transaction");
247 return ERROR_JTAG_DEVICE_ERROR
;
252 LOG_WARNING("Invalid ACK in SWJDP transaction");
253 return ERROR_JTAG_DEVICE_ERROR
;
256 scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, DP_CTRL_STAT
, DPAP_READ
, 0, &ctrlstat
);
257 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
259 swjdp
->ack
= swjdp
->ack
& 0x7;
263 /* common code path avoids fn to timeval_ms() */
266 /* Check for STICKYERR and STICKYORUN */
267 if (ctrlstat
& (SSTICKYORUN
| SSTICKYERR
))
269 LOG_DEBUG("swjdp: CTRL/STAT error 0x%" PRIx32
"", ctrlstat
);
270 /* Check power to debug regions */
271 if ((ctrlstat
& 0xf0000000) != 0xf0000000)
273 ahbap_debugport_init(swjdp
);
277 uint32_t mem_ap_csw
, mem_ap_tar
;
279 /* Print information about last AHBAP access */
280 LOG_ERROR("AHBAP Cached values: dp_select 0x%" PRIx32
", ap_csw 0x%" PRIx32
", ap_tar 0x%" PRIx32
"", swjdp
->dp_select_value
, swjdp
->ap_csw_value
, swjdp
->ap_tar_value
);
281 if (ctrlstat
& SSTICKYORUN
)
282 LOG_ERROR("SWJ-DP OVERRUN - check clock or reduce jtag speed");
284 if (ctrlstat
& SSTICKYERR
)
285 LOG_ERROR("SWJ-DP STICKY ERROR");
287 /* Clear Sticky Error Bits */
288 scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, DP_CTRL_STAT
, DPAP_WRITE
, swjdp
->dp_ctrl_stat
| SSTICKYORUN
| SSTICKYERR
, NULL
);
289 scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, DP_CTRL_STAT
, DPAP_READ
, 0, &ctrlstat
);
290 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
293 LOG_DEBUG("swjdp: status 0x%" PRIx32
"", ctrlstat
);
295 dap_ap_read_reg_u32(swjdp
, AP_REG_CSW
, &mem_ap_csw
);
296 dap_ap_read_reg_u32(swjdp
, AP_REG_TAR
, &mem_ap_tar
);
297 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
299 LOG_ERROR("Read MEM_AP_CSW 0x%" PRIx32
", MEM_AP_TAR 0x%" PRIx32
"", mem_ap_csw
, mem_ap_tar
);
302 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
304 return ERROR_JTAG_DEVICE_ERROR
;
310 /***************************************************************************
312 * DP and MEM-AP register access through APACC and DPACC *
314 ***************************************************************************/
316 static int dap_dp_write_reg(struct swjdp_common
*swjdp
,
317 uint32_t value
, uint8_t reg_addr
)
319 return scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, reg_addr
, DPAP_WRITE
, value
, NULL
);
322 static int dap_dp_read_reg(struct swjdp_common
*swjdp
,
323 uint32_t *value
, uint8_t reg_addr
)
325 return scan_inout_check_u32(swjdp
, DAP_IR_DPACC
, reg_addr
, DPAP_READ
, 0, value
);
328 int dap_ap_select(struct swjdp_common
*swjdp
,uint8_t apsel
)
331 select
= (apsel
<< 24) & 0xFF000000;
333 if (select
!= swjdp
->apsel
)
335 swjdp
->apsel
= select
;
336 /* Switching AP invalidates cached values */
337 swjdp
->dp_select_value
= -1;
338 swjdp
->ap_csw_value
= -1;
339 swjdp
->ap_tar_value
= -1;
345 static int dap_dp_bankselect(struct swjdp_common
*swjdp
, uint32_t ap_reg
)
348 select
= (ap_reg
& 0x000000F0);
350 if (select
!= swjdp
->dp_select_value
)
352 dap_dp_write_reg(swjdp
, select
| swjdp
->apsel
, DP_SELECT
);
353 swjdp
->dp_select_value
= select
;
359 static int dap_ap_write_reg(struct swjdp_common
*swjdp
,
360 uint32_t reg_addr
, uint8_t *out_value_buf
)
362 dap_dp_bankselect(swjdp
, reg_addr
);
363 scan_inout_check(swjdp
, DAP_IR_APACC
, reg_addr
, DPAP_WRITE
, out_value_buf
, NULL
);
368 int dap_ap_write_reg_u32(struct swjdp_common
*swjdp
, uint32_t reg_addr
, uint32_t value
)
370 uint8_t out_value_buf
[4];
372 buf_set_u32(out_value_buf
, 0, 32, value
);
373 dap_dp_bankselect(swjdp
, reg_addr
);
374 scan_inout_check(swjdp
, DAP_IR_APACC
, reg_addr
, DPAP_WRITE
, out_value_buf
, NULL
);
379 int dap_ap_read_reg_u32(struct swjdp_common
*swjdp
, uint32_t reg_addr
, uint32_t *value
)
381 dap_dp_bankselect(swjdp
, reg_addr
);
382 scan_inout_check_u32(swjdp
, DAP_IR_APACC
, reg_addr
, DPAP_READ
, 0, value
);
387 /***************************************************************************
389 * AHB-AP access to memory and system registers on AHB bus *
391 ***************************************************************************/
393 int dap_setup_accessport(struct swjdp_common
*swjdp
, uint32_t csw
, uint32_t tar
)
395 csw
= csw
| CSW_DBGSWENABLE
| CSW_MASTER_DEBUG
| CSW_HPROT
;
396 if (csw
!= swjdp
->ap_csw_value
)
398 /* LOG_DEBUG("swjdp : Set CSW %x",csw); */
399 dap_ap_write_reg_u32(swjdp
, AP_REG_CSW
, csw
);
400 swjdp
->ap_csw_value
= csw
;
402 if (tar
!= swjdp
->ap_tar_value
)
404 /* LOG_DEBUG("swjdp : Set TAR %x",tar); */
405 dap_ap_write_reg_u32(swjdp
, AP_REG_TAR
, tar
);
406 swjdp
->ap_tar_value
= tar
;
408 if (csw
& CSW_ADDRINC_MASK
)
410 /* Do not cache TAR value when autoincrementing */
411 swjdp
->ap_tar_value
= -1;
416 /*****************************************************************************
418 * mem_ap_read_u32(struct swjdp_common *swjdp, uint32_t address, uint32_t *value) *
420 * Read a uint32_t value from memory or system register *
421 * Functionally equivalent to target_read_u32(target, address, uint32_t *value), *
422 * but with less overhead *
423 *****************************************************************************/
424 int mem_ap_read_u32(struct swjdp_common
*swjdp
, uint32_t address
, uint32_t *value
)
426 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
428 dap_setup_accessport(swjdp
, CSW_32BIT
| CSW_ADDRINC_OFF
, address
& 0xFFFFFFF0);
429 dap_ap_read_reg_u32(swjdp
, AP_REG_BD0
| (address
& 0xC), value
);
434 int mem_ap_read_atomic_u32(struct swjdp_common
*swjdp
, uint32_t address
, uint32_t *value
)
436 mem_ap_read_u32(swjdp
, address
, value
);
438 return swjdp_transaction_endcheck(swjdp
);
441 /*****************************************************************************
443 * mem_ap_write_u32(struct swjdp_common *swjdp, uint32_t address, uint32_t value) *
445 * Write a uint32_t value to memory or memory mapped register *
447 *****************************************************************************/
448 int mem_ap_write_u32(struct swjdp_common
*swjdp
, uint32_t address
, uint32_t value
)
450 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
452 dap_setup_accessport(swjdp
, CSW_32BIT
| CSW_ADDRINC_OFF
, address
& 0xFFFFFFF0);
453 dap_ap_write_reg_u32(swjdp
, AP_REG_BD0
| (address
& 0xC), value
);
458 int mem_ap_write_atomic_u32(struct swjdp_common
*swjdp
, uint32_t address
, uint32_t value
)
460 mem_ap_write_u32(swjdp
, address
, value
);
462 return swjdp_transaction_endcheck(swjdp
);
465 /*****************************************************************************
467 * mem_ap_write_buf(struct swjdp_common *swjdp, uint8_t *buffer, int count, uint32_t address) *
469 * Write a buffer in target order (little endian) *
471 *****************************************************************************/
472 int mem_ap_write_buf_u32(struct swjdp_common
*swjdp
, uint8_t *buffer
, int count
, uint32_t address
)
474 int wcount
, blocksize
, writecount
, errorcount
= 0, retval
= ERROR_OK
;
475 uint32_t adr
= address
;
476 uint8_t* pBuffer
= buffer
;
478 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
483 /* if we have an unaligned access - reorder data */
486 for (writecount
= 0; writecount
< count
; writecount
++)
490 memcpy(&outvalue
, pBuffer
, sizeof(uint32_t));
492 for (i
= 0; i
< 4; i
++)
494 *((uint8_t*)pBuffer
+ (adr
& 0x3)) = outvalue
;
498 pBuffer
+= sizeof(uint32_t);
504 /* Adjust to write blocks within boundaries aligned to the TAR autoincremnent size*/
505 blocksize
= max_tar_block_size(swjdp
->tar_autoincr_block
, address
);
506 if (wcount
< blocksize
)
509 /* handle unaligned data at 4k boundary */
513 dap_setup_accessport(swjdp
, CSW_32BIT
| CSW_ADDRINC_SINGLE
, address
);
515 for (writecount
= 0; writecount
< blocksize
; writecount
++)
517 dap_ap_write_reg(swjdp
, AP_REG_DRW
, buffer
+ 4 * writecount
);
520 if (swjdp_transaction_endcheck(swjdp
) == ERROR_OK
)
522 wcount
= wcount
- blocksize
;
523 address
= address
+ 4 * blocksize
;
524 buffer
= buffer
+ 4 * blocksize
;
533 LOG_WARNING("Block write error address 0x%" PRIx32
", wcount 0x%x", address
, wcount
);
534 return ERROR_JTAG_DEVICE_ERROR
;
541 static int mem_ap_write_buf_packed_u16(struct swjdp_common
*swjdp
,
542 uint8_t *buffer
, int count
, uint32_t address
)
544 int retval
= ERROR_OK
;
545 int wcount
, blocksize
, writecount
, i
;
547 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
555 /* Adjust to write blocks within boundaries aligned to the TAR autoincremnent size*/
556 blocksize
= max_tar_block_size(swjdp
->tar_autoincr_block
, address
);
558 if (wcount
< blocksize
)
561 /* handle unaligned data at 4k boundary */
565 dap_setup_accessport(swjdp
, CSW_16BIT
| CSW_ADDRINC_PACKED
, address
);
566 writecount
= blocksize
;
570 nbytes
= MIN((writecount
<< 1), 4);
574 if (mem_ap_write_buf_u16(swjdp
, buffer
, nbytes
, address
) != ERROR_OK
)
576 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
577 return ERROR_JTAG_DEVICE_ERROR
;
580 address
+= nbytes
>> 1;
585 memcpy(&outvalue
, buffer
, sizeof(uint32_t));
587 for (i
= 0; i
< nbytes
; i
++)
589 *((uint8_t*)buffer
+ (address
& 0x3)) = outvalue
;
594 memcpy(&outvalue
, buffer
, sizeof(uint32_t));
595 dap_ap_write_reg_u32(swjdp
, AP_REG_DRW
, outvalue
);
596 if (swjdp_transaction_endcheck(swjdp
) != ERROR_OK
)
598 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
599 return ERROR_JTAG_DEVICE_ERROR
;
603 buffer
+= nbytes
>> 1;
604 writecount
-= nbytes
>> 1;
606 } while (writecount
);
613 int mem_ap_write_buf_u16(struct swjdp_common
*swjdp
, uint8_t *buffer
, int count
, uint32_t address
)
615 int retval
= ERROR_OK
;
618 return mem_ap_write_buf_packed_u16(swjdp
, buffer
, count
, address
);
620 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
624 dap_setup_accessport(swjdp
, CSW_16BIT
| CSW_ADDRINC_SINGLE
, address
);
626 memcpy(&svalue
, buffer
, sizeof(uint16_t));
627 uint32_t outvalue
= (uint32_t)svalue
<< 8 * (address
& 0x3);
628 dap_ap_write_reg_u32(swjdp
, AP_REG_DRW
, outvalue
);
629 retval
= swjdp_transaction_endcheck(swjdp
);
638 static int mem_ap_write_buf_packed_u8(struct swjdp_common
*swjdp
,
639 uint8_t *buffer
, int count
, uint32_t address
)
641 int retval
= ERROR_OK
;
642 int wcount
, blocksize
, writecount
, i
;
644 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
652 /* Adjust to write blocks within boundaries aligned to the TAR autoincremnent size*/
653 blocksize
= max_tar_block_size(swjdp
->tar_autoincr_block
, address
);
655 if (wcount
< blocksize
)
658 dap_setup_accessport(swjdp
, CSW_8BIT
| CSW_ADDRINC_PACKED
, address
);
659 writecount
= blocksize
;
663 nbytes
= MIN(writecount
, 4);
667 if (mem_ap_write_buf_u8(swjdp
, buffer
, nbytes
, address
) != ERROR_OK
)
669 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
670 return ERROR_JTAG_DEVICE_ERROR
;
678 memcpy(&outvalue
, buffer
, sizeof(uint32_t));
680 for (i
= 0; i
< nbytes
; i
++)
682 *((uint8_t*)buffer
+ (address
& 0x3)) = outvalue
;
687 memcpy(&outvalue
, buffer
, sizeof(uint32_t));
688 dap_ap_write_reg_u32(swjdp
, AP_REG_DRW
, outvalue
);
689 if (swjdp_transaction_endcheck(swjdp
) != ERROR_OK
)
691 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
692 return ERROR_JTAG_DEVICE_ERROR
;
697 writecount
-= nbytes
;
699 } while (writecount
);
706 int mem_ap_write_buf_u8(struct swjdp_common
*swjdp
, uint8_t *buffer
, int count
, uint32_t address
)
708 int retval
= ERROR_OK
;
711 return mem_ap_write_buf_packed_u8(swjdp
, buffer
, count
, address
);
713 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
717 dap_setup_accessport(swjdp
, CSW_8BIT
| CSW_ADDRINC_SINGLE
, address
);
718 uint32_t outvalue
= (uint32_t)*buffer
<< 8 * (address
& 0x3);
719 dap_ap_write_reg_u32(swjdp
, AP_REG_DRW
, outvalue
);
720 retval
= swjdp_transaction_endcheck(swjdp
);
729 /*********************************************************************************
731 * mem_ap_read_buf_u32(struct swjdp_common *swjdp, uint8_t *buffer, int count, uint32_t address) *
733 * Read block fast in target order (little endian) into a buffer *
735 **********************************************************************************/
736 int mem_ap_read_buf_u32(struct swjdp_common
*swjdp
, uint8_t *buffer
, int count
, uint32_t address
)
738 int wcount
, blocksize
, readcount
, errorcount
= 0, retval
= ERROR_OK
;
739 uint32_t adr
= address
;
740 uint8_t* pBuffer
= buffer
;
742 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
749 /* Adjust to read blocks within boundaries aligned to the TAR autoincremnent size*/
750 blocksize
= max_tar_block_size(swjdp
->tar_autoincr_block
, address
);
751 if (wcount
< blocksize
)
754 /* handle unaligned data at 4k boundary */
758 dap_setup_accessport(swjdp
, CSW_32BIT
| CSW_ADDRINC_SINGLE
, address
);
760 /* Scan out first read */
761 adi_jtag_dp_scan(swjdp
, DAP_IR_APACC
, AP_REG_DRW
, DPAP_READ
, 0, NULL
, NULL
);
762 for (readcount
= 0; readcount
< blocksize
- 1; readcount
++)
764 /* Scan out read instruction and scan in previous value */
765 adi_jtag_dp_scan(swjdp
, DAP_IR_APACC
, AP_REG_DRW
, DPAP_READ
, 0, buffer
+ 4 * readcount
, &swjdp
->ack
);
768 /* Scan in last value */
769 adi_jtag_dp_scan(swjdp
, DAP_IR_DPACC
, DP_RDBUFF
, DPAP_READ
, 0, buffer
+ 4 * readcount
, &swjdp
->ack
);
770 if (swjdp_transaction_endcheck(swjdp
) == ERROR_OK
)
772 wcount
= wcount
- blocksize
;
773 address
+= 4 * blocksize
;
774 buffer
+= 4 * blocksize
;
783 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
784 return ERROR_JTAG_DEVICE_ERROR
;
788 /* if we have an unaligned access - reorder data */
791 for (readcount
= 0; readcount
< count
; readcount
++)
795 memcpy(&data
, pBuffer
, sizeof(uint32_t));
797 for (i
= 0; i
< 4; i
++)
799 *((uint8_t*)pBuffer
) = (data
>> 8 * (adr
& 0x3));
809 static int mem_ap_read_buf_packed_u16(struct swjdp_common
*swjdp
,
810 uint8_t *buffer
, int count
, uint32_t address
)
813 int retval
= ERROR_OK
;
814 int wcount
, blocksize
, readcount
, i
;
816 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
824 /* Adjust to read blocks within boundaries aligned to the TAR autoincremnent size*/
825 blocksize
= max_tar_block_size(swjdp
->tar_autoincr_block
, address
);
826 if (wcount
< blocksize
)
829 dap_setup_accessport(swjdp
, CSW_16BIT
| CSW_ADDRINC_PACKED
, address
);
831 /* handle unaligned data at 4k boundary */
834 readcount
= blocksize
;
838 dap_ap_read_reg_u32(swjdp
, AP_REG_DRW
, &invalue
);
839 if (swjdp_transaction_endcheck(swjdp
) != ERROR_OK
)
841 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
842 return ERROR_JTAG_DEVICE_ERROR
;
845 nbytes
= MIN((readcount
<< 1), 4);
847 for (i
= 0; i
< nbytes
; i
++)
849 *((uint8_t*)buffer
) = (invalue
>> 8 * (address
& 0x3));
854 readcount
-= (nbytes
>> 1);
862 int mem_ap_read_buf_u16(struct swjdp_common
*swjdp
, uint8_t *buffer
, int count
, uint32_t address
)
865 int retval
= ERROR_OK
;
868 return mem_ap_read_buf_packed_u16(swjdp
, buffer
, count
, address
);
870 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
874 dap_setup_accessport(swjdp
, CSW_16BIT
| CSW_ADDRINC_SINGLE
, address
);
875 dap_ap_read_reg_u32(swjdp
, AP_REG_DRW
, &invalue
);
876 retval
= swjdp_transaction_endcheck(swjdp
);
879 for (i
= 0; i
< 2; i
++)
881 *((uint8_t*)buffer
) = (invalue
>> 8 * (address
& 0x3));
888 uint16_t svalue
= (invalue
>> 8 * (address
& 0x3));
889 memcpy(buffer
, &svalue
, sizeof(uint16_t));
899 /* FIX!!! is this a potential performance bottleneck w.r.t. requiring too many
900 * roundtrips when jtag_execute_queue() has a large overhead(e.g. for USB)s?
902 * The solution is to arrange for a large out/in scan in this loop and
903 * and convert data afterwards.
905 static int mem_ap_read_buf_packed_u8(struct swjdp_common
*swjdp
,
906 uint8_t *buffer
, int count
, uint32_t address
)
909 int retval
= ERROR_OK
;
910 int wcount
, blocksize
, readcount
, i
;
912 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
920 /* Adjust to read blocks within boundaries aligned to the TAR autoincremnent size*/
921 blocksize
= max_tar_block_size(swjdp
->tar_autoincr_block
, address
);
923 if (wcount
< blocksize
)
926 dap_setup_accessport(swjdp
, CSW_8BIT
| CSW_ADDRINC_PACKED
, address
);
927 readcount
= blocksize
;
931 dap_ap_read_reg_u32(swjdp
, AP_REG_DRW
, &invalue
);
932 if (swjdp_transaction_endcheck(swjdp
) != ERROR_OK
)
934 LOG_WARNING("Block read error address 0x%" PRIx32
", count 0x%x", address
, count
);
935 return ERROR_JTAG_DEVICE_ERROR
;
938 nbytes
= MIN(readcount
, 4);
940 for (i
= 0; i
< nbytes
; i
++)
942 *((uint8_t*)buffer
) = (invalue
>> 8 * (address
& 0x3));
955 int mem_ap_read_buf_u8(struct swjdp_common
*swjdp
, uint8_t *buffer
, int count
, uint32_t address
)
958 int retval
= ERROR_OK
;
961 return mem_ap_read_buf_packed_u8(swjdp
, buffer
, count
, address
);
963 swjdp
->trans_mode
= TRANS_MODE_COMPOSITE
;
967 dap_setup_accessport(swjdp
, CSW_8BIT
| CSW_ADDRINC_SINGLE
, address
);
968 dap_ap_read_reg_u32(swjdp
, AP_REG_DRW
, &invalue
);
969 retval
= swjdp_transaction_endcheck(swjdp
);
970 *((uint8_t*)buffer
) = (invalue
>> 8 * (address
& 0x3));
982 * @todo Rename this. We also need an initialization scheme which account
983 * for SWD transports not just JTAG; that will need to address differences
984 * in layering. (JTAG is useful without any debug target; but not SWD.)
986 int ahbap_debugport_init(struct swjdp_common
*swjdp
)
988 uint32_t idreg
, romaddr
, dummy
;
995 /* Default MEM-AP setup.
997 * REVISIT AP #0 may be an inappropriate default for this.
998 * Should we probe, or receve a hint from the caller?
999 * Presumably we can ignore the possibility of multiple APs.
1002 swjdp
->ap_csw_value
= -1;
1003 swjdp
->ap_tar_value
= -1;
1005 /* DP initialization */
1006 swjdp
->trans_mode
= TRANS_MODE_ATOMIC
;
1007 dap_dp_read_reg(swjdp
, &dummy
, DP_CTRL_STAT
);
1008 dap_dp_write_reg(swjdp
, SSTICKYERR
, DP_CTRL_STAT
);
1009 dap_dp_read_reg(swjdp
, &dummy
, DP_CTRL_STAT
);
1011 swjdp
->dp_ctrl_stat
= CDBGPWRUPREQ
| CSYSPWRUPREQ
;
1013 dap_dp_write_reg(swjdp
, swjdp
->dp_ctrl_stat
, DP_CTRL_STAT
);
1014 dap_dp_read_reg(swjdp
, &ctrlstat
, DP_CTRL_STAT
);
1015 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
1018 /* Check that we have debug power domains activated */
1019 while (!(ctrlstat
& CDBGPWRUPACK
) && (cnt
++ < 10))
1021 LOG_DEBUG("swjdp: wait CDBGPWRUPACK");
1022 dap_dp_read_reg(swjdp
, &ctrlstat
, DP_CTRL_STAT
);
1023 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
1028 while (!(ctrlstat
& CSYSPWRUPACK
) && (cnt
++ < 10))
1030 LOG_DEBUG("swjdp: wait CSYSPWRUPACK");
1031 dap_dp_read_reg(swjdp
, &ctrlstat
, DP_CTRL_STAT
);
1032 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
1037 dap_dp_read_reg(swjdp
, &dummy
, DP_CTRL_STAT
);
1038 /* With debug power on we can activate OVERRUN checking */
1039 swjdp
->dp_ctrl_stat
= CDBGPWRUPREQ
| CSYSPWRUPREQ
| CORUNDETECT
;
1040 dap_dp_write_reg(swjdp
, swjdp
->dp_ctrl_stat
, DP_CTRL_STAT
);
1041 dap_dp_read_reg(swjdp
, &dummy
, DP_CTRL_STAT
);
1044 * REVISIT this isn't actually *initializing* anything in an AP,
1045 * and doesn't care if it's a MEM-AP at all (much less AHB-AP).
1046 * Should it? If the ROM address is valid, is this the right
1047 * place to scan the table and do any topology detection?
1049 dap_ap_read_reg_u32(swjdp
, AP_REG_IDR
, &idreg
);
1050 dap_ap_read_reg_u32(swjdp
, AP_REG_BASE
, &romaddr
);
1052 LOG_DEBUG("AHB-AP ID Register 0x%" PRIx32
", Debug ROM Address 0x%" PRIx32
"", idreg
, romaddr
);
1057 /* CID interpretation -- see ARM IHI 0029B section 3
1058 * and ARM IHI 0031A table 13-3.
1060 static const char *class_description
[16] ={
1061 "Reserved", "ROM table", "Reserved", "Reserved",
1062 "Reserved", "Reserved", "Reserved", "Reserved",
1063 "Reserved", "CoreSight component", "Reserved", "Peripheral Test Block",
1064 "Reserved", "OptimoDE DESS",
1065 "Generic IP component", "PrimeCell or System component"
1069 is_dap_cid_ok(uint32_t cid3
, uint32_t cid2
, uint32_t cid1
, uint32_t cid0
)
1071 return cid3
== 0xb1 && cid2
== 0x05
1072 && ((cid1
& 0x0f) == 0) && cid0
== 0x0d;
1075 int dap_info_command(struct command_context
*cmd_ctx
, struct swjdp_common
*swjdp
, int apsel
)
1078 uint32_t dbgbase
,apid
;
1079 int romtable_present
= 0;
1083 apselold
= swjdp
->apsel
;
1084 dap_ap_select(swjdp
, apsel
);
1085 dap_ap_read_reg_u32(swjdp
, AP_REG_BASE
, &dbgbase
);
1086 dap_ap_read_reg_u32(swjdp
, AP_REG_IDR
, &apid
);
1087 swjdp_transaction_endcheck(swjdp
);
1088 /* Now we read ROM table ID registers, ref. ARM IHI 0029B sec */
1089 mem_ap
= ((apid
&0x10000) && ((apid
&0x0F) != 0));
1090 command_print(cmd_ctx
, "ap identification register 0x%8.8" PRIx32
"", apid
);
1096 command_print(cmd_ctx
, "\tType is jtag-ap");
1099 command_print(cmd_ctx
, "\tType is mem-ap AHB");
1102 command_print(cmd_ctx
, "\tType is mem-ap APB");
1105 command_print(cmd_ctx
, "\tUnknown AP-type");
1108 command_print(cmd_ctx
, "ap debugbase 0x%8.8" PRIx32
"", dbgbase
);
1112 command_print(cmd_ctx
, "No AP found at this apsel 0x%x", apsel
);
1115 romtable_present
= ((mem_ap
) && (dbgbase
!= 0xFFFFFFFF));
1116 if (romtable_present
)
1118 uint32_t cid0
,cid1
,cid2
,cid3
,memtype
,romentry
;
1119 uint16_t entry_offset
;
1121 /* bit 16 of apid indicates a memory access port */
1123 command_print(cmd_ctx
, "\tValid ROM table present");
1125 command_print(cmd_ctx
, "\tROM table in legacy format");
1127 /* Now we read ROM table ID registers, ref. ARM IHI 0029B sec */
1128 mem_ap_read_u32(swjdp
, (dbgbase
&0xFFFFF000) | 0xFF0, &cid0
);
1129 mem_ap_read_u32(swjdp
, (dbgbase
&0xFFFFF000) | 0xFF4, &cid1
);
1130 mem_ap_read_u32(swjdp
, (dbgbase
&0xFFFFF000) | 0xFF8, &cid2
);
1131 mem_ap_read_u32(swjdp
, (dbgbase
&0xFFFFF000) | 0xFFC, &cid3
);
1132 mem_ap_read_u32(swjdp
, (dbgbase
&0xFFFFF000) | 0xFCC, &memtype
);
1133 swjdp_transaction_endcheck(swjdp
);
1134 if (!is_dap_cid_ok(cid3
, cid2
, cid1
, cid0
))
1135 command_print(cmd_ctx
, "\tCID3 0x%2.2" PRIx32
1136 ", CID2 0x%2.2" PRIx32
1137 ", CID1 0x%2.2" PRIx32
1138 ", CID0 0x%2.2" PRIx32
,
1139 cid3
, cid2
, cid1
, cid0
);
1141 command_print(cmd_ctx
, "\tMEMTYPE system memory present on bus");
1143 command_print(cmd_ctx
, "\tMEMTYPE System memory not present. "
1144 "Dedicated debug bus.");
1146 /* Now we read ROM table entries from dbgbase&0xFFFFF000) | 0x000 until we get 0x00000000 */
1150 mem_ap_read_atomic_u32(swjdp
, (dbgbase
&0xFFFFF000) | entry_offset
, &romentry
);
1151 command_print(cmd_ctx
, "\tROMTABLE[0x%x] = 0x%" PRIx32
"",entry_offset
,romentry
);
1154 uint32_t c_cid0
, c_cid1
, c_cid2
, c_cid3
;
1155 uint32_t c_pid0
, c_pid1
, c_pid2
, c_pid3
, c_pid4
;
1156 uint32_t component_start
, component_base
;
1160 component_base
= (uint32_t)((dbgbase
& 0xFFFFF000)
1161 + (int)(romentry
& 0xFFFFF000));
1162 mem_ap_read_atomic_u32(swjdp
,
1163 (component_base
& 0xFFFFF000) | 0xFE0, &c_pid0
);
1164 mem_ap_read_atomic_u32(swjdp
,
1165 (component_base
& 0xFFFFF000) | 0xFE4, &c_pid1
);
1166 mem_ap_read_atomic_u32(swjdp
,
1167 (component_base
& 0xFFFFF000) | 0xFE8, &c_pid2
);
1168 mem_ap_read_atomic_u32(swjdp
,
1169 (component_base
& 0xFFFFF000) | 0xFEC, &c_pid3
);
1170 mem_ap_read_atomic_u32(swjdp
,
1171 (component_base
& 0xFFFFF000) | 0xFD0, &c_pid4
);
1172 mem_ap_read_atomic_u32(swjdp
,
1173 (component_base
& 0xFFFFF000) | 0xFF0, &c_cid0
);
1174 mem_ap_read_atomic_u32(swjdp
,
1175 (component_base
& 0xFFFFF000) | 0xFF4, &c_cid1
);
1176 mem_ap_read_atomic_u32(swjdp
,
1177 (component_base
& 0xFFFFF000) | 0xFF8, &c_cid2
);
1178 mem_ap_read_atomic_u32(swjdp
,
1179 (component_base
& 0xFFFFF000) | 0xFFC, &c_cid3
);
1180 component_start
= component_base
- 0x1000*(c_pid4
>> 4);
1182 command_print(cmd_ctx
, "\t\tComponent base address 0x%" PRIx32
1183 ", start address 0x%" PRIx32
,
1184 component_base
, component_start
);
1185 command_print(cmd_ctx
, "\t\tComponent class is 0x%x, %s",
1186 (int) (c_cid1
>> 4) & 0xf,
1187 /* See ARM IHI 0029B Table 3-3 */
1188 class_description
[(c_cid1
>> 4) & 0xf]);
1190 /* CoreSight component? */
1191 if (((c_cid1
>> 4) & 0x0f) == 9) {
1194 char *major
= "Reserved", *subtype
= "Reserved";
1196 mem_ap_read_atomic_u32(swjdp
,
1197 (component_base
& 0xfffff000) | 0xfcc,
1199 minor
= (devtype
>> 4) & 0x0f;
1200 switch (devtype
& 0x0f) {
1202 major
= "Miscellaneous";
1208 subtype
= "Validation component";
1213 major
= "Trace Sink";
1227 major
= "Trace Link";
1233 subtype
= "Funnel, router";
1239 subtype
= "FIFO, buffer";
1244 major
= "Trace Source";
1250 subtype
= "Processor";
1256 subtype
= "Engine/Coprocessor";
1264 major
= "Debug Control";
1270 subtype
= "Trigger Matrix";
1273 subtype
= "Debug Auth";
1278 major
= "Debug Logic";
1284 subtype
= "Processor";
1290 subtype
= "Engine/Coprocessor";
1295 command_print(cmd_ctx
, "\t\tType is 0x%2.2x, %s, %s",
1296 (unsigned) (devtype
& 0xff),
1298 /* REVISIT also show 0xfc8 DevId */
1301 if (!is_dap_cid_ok(cid3
, cid2
, cid1
, cid0
))
1302 command_print(cmd_ctx
, "\t\tCID3 0x%2.2" PRIx32
1303 ", CID2 0x%2.2" PRIx32
1304 ", CID1 0x%2.2" PRIx32
1305 ", CID0 0x%2.2" PRIx32
,
1306 c_cid3
, c_cid2
, c_cid1
, c_cid0
);
1307 command_print(cmd_ctx
, "\t\tPeripheral ID[4..0] = hex "
1308 "%2.2x %2.2x %2.2x %2.2x %2.2x",
1310 (int) c_pid3
, (int) c_pid2
,
1311 (int) c_pid1
, (int) c_pid0
);
1313 /* Part number interpretations are from Cortex
1314 * core specs, the CoreSight components TRM
1315 * (ARM DDI 0314H), and ETM specs; also from
1316 * chip observation (e.g. TI SDTI).
1318 part_num
= c_pid0
& 0xff;
1319 part_num
|= (c_pid1
& 0x0f) << 8;
1322 type
= "Cortex-M3 NVIC";
1323 full
= "(Interrupt Controller)";
1326 type
= "Cortex-M3 ITM";
1327 full
= "(Instrumentation Trace Module)";
1330 type
= "Cortex-M3 DWT";
1331 full
= "(Data Watchpoint and Trace)";
1334 type
= "Cortex-M3 FBP";
1335 full
= "(Flash Patch and Breakpoint)";
1338 type
= "CoreSight ETM11";
1339 full
= "(Embedded Trace)";
1341 // case 0x113: what?
1342 case 0x120: /* from OMAP3 memmap */
1344 full
= "(System Debug Trace Interface)";
1346 case 0x343: /* from OMAP3 memmap */
1351 type
= "Cortex-M3 ETM";
1352 full
= "(Embedded Trace)";
1355 type
= "Coresight CTI";
1356 full
= "(Cross Trigger)";
1359 type
= "Coresight ETB";
1360 full
= "(Trace Buffer)";
1363 type
= "Coresight CSTF";
1364 full
= "(Trace Funnel)";
1367 type
= "CoreSight ETM9";
1368 full
= "(Embedded Trace)";
1371 type
= "Coresight TPIU";
1372 full
= "(Trace Port Interface Unit)";
1375 type
= "Cortex-A8 ETM";
1376 full
= "(Embedded Trace)";
1379 type
= "Cortex-A8 CTI";
1380 full
= "(Cross Trigger)";
1383 type
= "Cortex-M3 TPIU";
1384 full
= "(Trace Port Interface Unit)";
1387 type
= "Cortex-A8 Debug";
1388 full
= "(Debug Unit)";
1391 type
= "-*- unrecognized -*-";
1395 command_print(cmd_ctx
, "\t\tPart is %s %s",
1401 command_print(cmd_ctx
, "\t\tComponent not present");
1403 command_print(cmd_ctx
, "\t\tEnd of ROM table");
1406 } while (romentry
> 0);
1410 command_print(cmd_ctx
, "\tNo ROM table present");
1412 dap_ap_select(swjdp
, apselold
);
1417 DAP_COMMAND_HANDLER(dap_baseaddr_command
)
1419 uint32_t apsel
, apselsave
, baseaddr
;
1422 apselsave
= swjdp
->apsel
;
1425 apsel
= swjdp
->apsel
;
1428 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], apsel
);
1431 return ERROR_COMMAND_SYNTAX_ERROR
;
1434 if (apselsave
!= apsel
)
1435 dap_ap_select(swjdp
, apsel
);
1437 dap_ap_read_reg_u32(swjdp
, AP_REG_BASE
, &baseaddr
);
1438 retval
= swjdp_transaction_endcheck(swjdp
);
1439 command_print(CMD_CTX
, "0x%8.8" PRIx32
, baseaddr
);
1441 if (apselsave
!= apsel
)
1442 dap_ap_select(swjdp
, apselsave
);
1447 DAP_COMMAND_HANDLER(dap_memaccess_command
)
1449 uint32_t memaccess_tck
;
1453 memaccess_tck
= swjdp
->memaccess_tck
;
1456 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], memaccess_tck
);
1459 return ERROR_COMMAND_SYNTAX_ERROR
;
1461 swjdp
->memaccess_tck
= memaccess_tck
;
1463 command_print(CMD_CTX
, "memory bus access delay set to %" PRIi32
" tck",
1464 swjdp
->memaccess_tck
);
1469 DAP_COMMAND_HANDLER(dap_apsel_command
)
1471 uint32_t apsel
, apid
;
1479 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], apsel
);
1482 return ERROR_COMMAND_SYNTAX_ERROR
;
1485 dap_ap_select(swjdp
, apsel
);
1486 dap_ap_read_reg_u32(swjdp
, AP_REG_IDR
, &apid
);
1487 retval
= swjdp_transaction_endcheck(swjdp
);
1488 command_print(CMD_CTX
, "ap %" PRIi32
" selected, identification register 0x%8.8" PRIx32
,
1494 DAP_COMMAND_HANDLER(dap_apid_command
)
1496 uint32_t apsel
, apselsave
, apid
;
1499 apselsave
= swjdp
->apsel
;
1502 apsel
= swjdp
->apsel
;
1505 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], apsel
);
1508 return ERROR_COMMAND_SYNTAX_ERROR
;
1511 if (apselsave
!= apsel
)
1512 dap_ap_select(swjdp
, apsel
);
1514 dap_ap_read_reg_u32(swjdp
, AP_REG_IDR
, &apid
);
1515 retval
= swjdp_transaction_endcheck(swjdp
);
1516 command_print(CMD_CTX
, "0x%8.8" PRIx32
, apid
);
1517 if (apselsave
!= apsel
)
1518 dap_ap_select(swjdp
, apselsave
);