|
OpenOCD
|
Utilities to support ARM "Serial Wire Debug" (SWD), a low pin-count debug link protocol used in cases where JTAG is not wanted. More...

Go to the source code of this file.
Enumerations | |
| enum | swd_recovery_mode { SWD_RECOVERY_QUEUE , SWD_RECOVERY_RUN } |
Functions | |
| static int | check_sync (struct adiv5_dap *dap) |
| static int | swd_check_dpidr_final (struct adiv5_dap *dap, uint32_t dpidr) |
| static int | swd_check_dpidr_in_loop (uint32_t dpidr) |
| static int | swd_check_reconnect (struct adiv5_dap *dap) |
| static int | swd_clear_sticky_errors (struct adiv5_dap *dap) |
| static int | swd_connect (struct adiv5_dap *dap) |
| static int | swd_connect_multidrop (struct adiv5_dap *dap) |
| static int | swd_connect_single (struct adiv5_dap *dap) |
| static void | swd_constructor (void) |
| static int | swd_error_recovery (struct adiv5_dap *dap, int err, enum swd_recovery_mode mode) |
| static int | swd_finish_read (struct adiv5_dap *dap) |
| static int | swd_init (struct command_context *ctx) |
| static int | swd_multidrop_select (struct adiv5_dap *dap) |
| static int | swd_multidrop_select_inner (struct adiv5_dap *dap, uint32_t *dpidr_ptr, uint32_t *dlpidr_ptr, uint32_t dp_abort) |
| static int | swd_pre_connect (struct adiv5_dap *dap) |
| static int | swd_queue_ap_abort (struct adiv5_dap *dap, uint8_t *ack) |
| static int | swd_queue_ap_bankselect (struct adiv5_ap *ap, unsigned int reg) |
| Select the AP register bank. More... | |
| static int | swd_queue_ap_read (struct adiv5_ap *ap, unsigned int reg, uint32_t *data) |
| static int | swd_queue_ap_write (struct adiv5_ap *ap, unsigned int reg, uint32_t data) |
| static int | swd_queue_dp_bankselect (struct adiv5_dap *dap, unsigned int reg) |
| Select the DP register bank. More... | |
| static int | swd_queue_dp_read (struct adiv5_dap *dap, unsigned int reg, uint32_t *data) |
| static int | swd_queue_dp_read_inner (struct adiv5_dap *dap, unsigned int reg, uint32_t *data) |
| static int | swd_queue_dp_write (struct adiv5_dap *dap, unsigned int reg, uint32_t data) |
| static int | swd_queue_dp_write_inner (struct adiv5_dap *dap, unsigned int reg, uint32_t data) |
| static void | swd_quit (struct adiv5_dap *dap) |
| Put the SWJ-DP back to JTAG mode. More... | |
| static int | swd_run (struct adiv5_dap *dap) |
| Executes all queued DAP operations. More... | |
| static int | swd_run_inner (struct adiv5_dap *dap) |
| static int | swd_select (struct command_context *ctx) |
| static int | swd_send_sequence (struct adiv5_dap *dap, enum swd_special_seq seq) |
| bool | transport_is_swd (void) |
| Returns true if the current debug session is using SWD as its transport. More... | |
Variables | |
| static bool | do_sync |
| static const struct command_registration | swd_commands [] |
| const struct dap_ops | swd_dap_ops |
| static const struct command_registration | swd_handlers [] |
| static bool | swd_multidrop_in_swd_state |
| static struct adiv5_dap * | swd_multidrop_selected_dap |
| static struct transport | swd_transport |
Utilities to support ARM "Serial Wire Debug" (SWD), a low pin-count debug link protocol used in cases where JTAG is not wanted.
This is coupled to recent versions of ARM's "CoreSight" debug framework. This specific code is a transport level interface, with "target/arm_adi_v5.[hc]" code understanding operation semantics, shared with the JTAG transport.
Single DAP and multidrop-SWD support.
for details, see "ARM IHI 0031A" ARM Debug Interface v5 Architecture Specification especially section 5.3 for SWD protocol and "ARM IHI 0074C" ARM Debug Interface Architecture Specification ADIv6.0
On many chips (most current Cortex-M3 parts) SWD is a run-time alternative to JTAG. Boards may support one or both. There are also SWD-only chips, (using SW-DP not SWJ-DP).
Even boards that also support JTAG can benefit from SWD support, because usually there's no way to access the SWO trace view mechanism in JTAG mode. That is, trace access may require SWD support.
Definition in file adi_v5_swd.c.
| enum swd_recovery_mode |
| Enumerator | |
|---|---|
| SWD_RECOVERY_QUEUE | |
| SWD_RECOVERY_RUN | |
Definition at line 54 of file adi_v5_swd.c.
|
inlinestatic |
Definition at line 100 of file adi_v5_swd.c.
References do_sync, ERROR_OK, and swd_run_inner().
Referenced by swd_queue_ap_abort(), swd_queue_ap_read(), swd_queue_ap_write(), swd_queue_dp_read_inner(), and swd_queue_dp_write_inner().
|
static |
Definition at line 214 of file adi_v5_swd.c.
References DP_DPIDR_VERSION_MASK, DP_DPIDR_VERSION_SHIFT, ERROR_FAIL, ERROR_OK, is_adiv6(), LOG_ERROR, and LOG_INFO.
Referenced by swd_connect_multidrop(), and swd_connect_single().
|
inlinestatic |
Definition at line 196 of file adi_v5_swd.c.
References BIT, ERROR_FAIL, ERROR_OK, and LOG_DEBUG.
Referenced by swd_connect_single(), and swd_multidrop_select_inner().
|
static |
Definition at line 629 of file adi_v5_swd.c.
References adiv5_dap::do_reconnect, ERROR_OK, and swd_connect().
Referenced by swd_queue_ap_read(), swd_queue_ap_write(), swd_queue_dp_read(), and swd_queue_dp_write().
|
static |
Definition at line 83 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), DP_ABORT, LOG_DEBUG_IO, ORUNERRCLR, STKCMPCLR, STKERRCLR, swd_cmd(), WDERRCLR, and swd_driver::write_reg.
Referenced by swd_connect_single().
|
static |
Definition at line 587 of file adi_v5_swd.c.
References adapter_assert_reset(), dap_dp_init(), dap_is_multidrop(), adiv5_dap::do_reconnect, ERROR_OK, jtag_get_reset_config(), jtag_reset_config, LOG_WARNING, RESET_CNCT_UNDER_SRST, RESET_SRST_NO_GATING, status, swd_connect_multidrop(), and swd_connect_single().
Referenced by swd_check_reconnect().
|
static |
Definition at line 359 of file adi_v5_swd.c.
References adiv5_dap_name(), alive_sleep(), dap_invalidate_cache(), DAPABORT, adiv5_dap::do_reconnect, ERROR_OK, ERROR_WAIT, LOG_ERROR, LOG_INFO, NULL, ORUNERRCLR, STKCMPCLR, STKERRCLR, swd_check_dpidr_final(), swd_multidrop_in_swd_state, swd_multidrop_select_inner(), swd_multidrop_selected_dap, swd_send_sequence(), SWD_TO_DORMANT, timeval_ms(), and WDERRCLR.
Referenced by swd_connect().
|
static |
Definition at line 421 of file adi_v5_swd.c.
References alive_sleep(), dap_invalidate_cache(), DAPABORT, adiv5_dap::do_reconnect, DORMANT_TO_SWD, DP_ABORT, DP_DPIDR, DP_SELECT, ERROR_FAIL, ERROR_OK, ERROR_WAIT, JTAG_TO_DORMANT, JTAG_TO_SWD, LOG_DEBUG, LOG_DEBUG_IO, LOG_ERROR, LOG_WARNING, ORUNERRCLR, adiv5_dap::select_dpbanksel_valid, STKCMPCLR, STKERRCLR, swd_check_dpidr_final(), swd_check_dpidr_in_loop(), swd_clear_sticky_errors(), swd_queue_dp_read_inner(), swd_queue_dp_write_inner(), swd_run_inner(), swd_send_sequence(), SWD_TO_DORMANT, adiv5_dap::switch_through_dormant, timeval_ms(), and WDERRCLR.
Referenced by swd_connect().
|
static |
Definition at line 945 of file adi_v5_swd.c.
|
static |
Definition at line 618 of file adi_v5_swd.c.
References adiv5_dap::do_reconnect, ERROR_OK, and LOG_DEBUG_IO.
Referenced by swd_queue_ap_bankselect(), swd_queue_ap_read(), swd_queue_ap_write(), swd_queue_dp_read(), swd_queue_dp_write(), and swd_run().
|
static |
Definition at line 71 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), DP_RDBUFF, ERROR_OK, adiv5_dap::last_read, NULL, swd_driver::read_reg, and swd_cmd().
Referenced by swd_queue_ap_write(), swd_queue_dp_write_inner(), and swd_run().
|
static |
Definition at line 932 of file adi_v5_swd.c.
References ERROR_OK.
|
static |
Definition at line 330 of file adi_v5_swd.c.
References adiv5_dap_name(), dap_is_multidrop(), adiv5_dap::do_reconnect, ERROR_OK, LOG_DEBUG, LOG_ERROR, NULL, ORUNERRCLR, swd_multidrop_select_inner(), and swd_multidrop_selected_dap.
Referenced by swd_queue_ap_abort(), swd_queue_ap_read(), swd_queue_ap_write(), swd_queue_dp_read(), swd_queue_dp_write(), and swd_run().
|
static |
Definition at line 234 of file adi_v5_swd.c.
References dap_is_multidrop(), DAPABORT, DORMANT_TO_SWD, DP_ABORT, DP_DLPIDR, DP_DLPIDR_PROTVSN, DP_DPIDR, DP_DPIDR_VERSION_MASK, DP_DPIDR_VERSION_SHIFT, DP_TARGETSEL, DP_TARGETSEL_INSTANCEID_MASK, ERROR_FAIL, ERROR_OK, JTAG_TO_DORMANT, LINE_RESET, LOG_DEBUG_IO, LOG_INFO, LOG_WARNING, adiv5_dap::multidrop_targetsel, adiv5_dap::select, adiv5_dap::select1_valid, adiv5_dap::select_dpbanksel_valid, adiv5_dap::select_valid, STKERRCLR, swd_check_dpidr_in_loop(), swd_multidrop_in_swd_state, swd_multidrop_selected_dap, swd_queue_dp_read_inner(), swd_queue_dp_write_inner(), swd_run_inner(), and swd_send_sequence().
Referenced by swd_connect_multidrop(), and swd_multidrop_select().
|
static |
Definition at line 580 of file adi_v5_swd.c.
References ERROR_OK, and swd_multidrop_in_swd_state.
|
static |
Definition at line 637 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), check_sync(), DAPABORT, DP_ABORT, ERROR_OK, ORUNERRCLR, STKCMPCLR, STKERRCLR, swd_cmd(), swd_multidrop_select(), WDERRCLR, and swd_driver::write_reg.
|
static |
Select the AP register bank.
Definition at line 689 of file adi_v5_swd.c.
References ADIV5_DP_SELECT_APBANK, adiv5_dap::ap, adiv5_ap::ap_num, adiv5_dap::asize, adiv5_ap::dap, DP_SELECT, DP_SELECT1, DP_SELECT_DPBANK, ERROR_OK, is_adiv6(), LOG_DEBUG_IO, adiv5_dap::select, adiv5_dap::select1_valid, SELECT_AP_MASK, adiv5_dap::select_valid, swd_error_recovery(), swd_queue_dp_write(), and SWD_RECOVERY_QUEUE.
Referenced by swd_queue_ap_read(), and swd_queue_ap_write().
|
static |
Definition at line 741 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), adiv5_dap::ap, check_sync(), adiv5_ap::dap, ERROR_OK, adiv5_dap::last_read, adiv5_ap::memaccess_tck, swd_driver::read_reg, swd_check_reconnect(), swd_cmd(), swd_error_recovery(), swd_multidrop_select(), swd_queue_ap_bankselect(), and SWD_RECOVERY_QUEUE.
|
static |
Definition at line 771 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), adiv5_dap::ap, check_sync(), adiv5_ap::dap, ERROR_OK, adiv5_ap::memaccess_tck, swd_check_reconnect(), swd_cmd(), swd_error_recovery(), swd_finish_read(), swd_multidrop_select(), swd_queue_ap_bankselect(), SWD_RECOVERY_QUEUE, and swd_driver::write_reg.
|
static |
Select the DP register bank.
Definition at line 106 of file adi_v5_swd.c.
References DP_SELECT, DP_SELECT_DPBANK, ERROR_OK, is_adiv6(), LOG_DEBUG_IO, adiv5_dap::select, SELECT_AP_MASK, adiv5_dap::select_dpbanksel_valid, adiv5_dap::select_valid, and swd_queue_dp_write_inner().
Referenced by swd_queue_dp_read_inner(), and swd_queue_dp_write_inner().
|
static |
Definition at line 658 of file adi_v5_swd.c.
References ERROR_OK, swd_check_reconnect(), swd_error_recovery(), swd_multidrop_select(), swd_queue_dp_read_inner(), and SWD_RECOVERY_QUEUE.
|
static |
Definition at line 131 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), check_sync(), ERROR_OK, swd_driver::read_reg, swd_cmd(), and swd_queue_dp_bankselect().
Referenced by swd_connect_single(), swd_multidrop_select_inner(), and swd_queue_dp_read().
|
static |
Definition at line 673 of file adi_v5_swd.c.
References ERROR_OK, swd_check_reconnect(), swd_error_recovery(), swd_multidrop_select(), swd_queue_dp_write_inner(), and SWD_RECOVERY_QUEUE.
Referenced by swd_queue_ap_bankselect().
|
static |
Definition at line 148 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), check_sync(), DP_ABORT, DP_SELECT, DP_SELECT1, ERROR_OK, adiv5_dap::select, adiv5_dap::select1_valid, adiv5_dap::select_dpbanksel_valid, adiv5_dap::select_valid, swd_cmd(), swd_finish_read(), swd_queue_dp_bankselect(), and swd_driver::write_reg.
Referenced by swd_connect_single(), swd_multidrop_select_inner(), swd_queue_dp_bankselect(), and swd_queue_dp_write().
|
static |
Put the SWJ-DP back to JTAG mode.
Definition at line 820 of file adi_v5_swd.c.
|
static |
Executes all queued DAP operations.
Definition at line 804 of file adi_v5_swd.c.
References ERROR_OK, swd_error_recovery(), swd_finish_read(), swd_multidrop_select(), SWD_RECOVERY_QUEUE, SWD_RECOVERY_RUN, and swd_run_inner().
|
static |
Definition at line 93 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), and swd_driver::run.
Referenced by check_sync(), swd_connect_single(), swd_multidrop_select_inner(), and swd_run().
|
static |
Definition at line 906 of file adi_v5_swd.c.
References ERROR_FAIL, ERROR_OK, swd_driver::init, LOG_DEBUG, NULL, swd_driver::read_reg, register_commands(), swd_handlers, adapter_driver::swd_ops, and swd_driver::write_reg.
|
static |
Definition at line 63 of file adi_v5_swd.c.
References adiv5_dap_swd_driver(), and swd_driver::switch_seq.
Referenced by swd_connect_multidrop(), swd_connect_single(), and swd_multidrop_select_inner().
| bool transport_is_swd | ( | void | ) |
Returns true if the current debug session is using SWD as its transport.
Definition at line 954 of file adi_v5_swd.c.
References get_current_transport(), and swd_transport.
Referenced by adapter_assert_reset(), adapter_deassert_reset(), adapter_resets(), am335xgpio_init(), bcm2835gpio_init(), cleanup_all_fds(), COMMAND_HANDLER(), dap_check_config(), dap_init_all(), imx_gpio_init(), imx_gpio_quit(), and sysfsgpio_init().
|
static |
Definition at line 48 of file adi_v5_swd.c.
Referenced by check_sync().
|
static |
Definition at line 820 of file adi_v5_swd.c.
| const struct dap_ops swd_dap_ops |
Definition at line 820 of file adi_v5_swd.c.
Referenced by dap_init_all().
|
static |
Definition at line 820 of file adi_v5_swd.c.
Referenced by swd_select().
|
static |
Definition at line 52 of file adi_v5_swd.c.
Referenced by swd_connect_multidrop(), swd_multidrop_select_inner(), and swd_pre_connect().
|
static |
Definition at line 50 of file adi_v5_swd.c.
Referenced by swd_connect_multidrop(), swd_multidrop_select(), and swd_multidrop_select_inner().
|
static |
Definition at line 932 of file adi_v5_swd.c.
Referenced by transport_is_swd().