From 57cb707b993ee7317e753adb8e31aaccb7615994 Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Wed, 19 Jul 2023 14:52:15 +0100 Subject: [PATCH] hosted/jlink_swd: remove now redundant swd error handling This function duplicated firmware_swdp_error in target/adiv5_swd, jlink support now provides all the methods required to perform the routine --- src/platforms/hosted/jlink_swd.c | 57 -------------------------------- 1 file changed, 57 deletions(-) diff --git a/src/platforms/hosted/jlink_swd.c b/src/platforms/hosted/jlink_swd.c index 514fcf8125c..6c44c154e56 100644 --- a/src/platforms/hosted/jlink_swd.c +++ b/src/platforms/hosted/jlink_swd.c @@ -68,11 +68,6 @@ static const uint8_t jlink_adiv5_read_request[5] = { /* clang-format on */ }; -/* 60 cycles of SWDIO held high + 4 cycles of it low (idle) */ -static const uint8_t jlink_line_reset_data[8] = {0xffU, 0xffU, 0xffU, 0xffU, 0xffU, 0xffU, 0xffU, 0xf0U}; -/* Define the direction as output for the entire lot */ -static const uint8_t jlink_line_reset_dir[8] = {0xffU, 0xffU, 0xffU, 0xffU, 0xffU, 0xffU, 0xffU, 0xffU}; - static uint32_t jlink_swd_seq_in(size_t clock_cycles); static bool jlink_swd_seq_in_parity(uint32_t *result, size_t clock_cycles); static void jlink_swd_seq_out(uint32_t tms_states, size_t clock_cycles); @@ -80,7 +75,6 @@ static void jlink_swd_seq_out_parity(uint32_t tms_states, size_t clock_cycles); static bool jlink_adiv5_raw_write_no_check(uint16_t addr, uint32_t data); static uint32_t jlink_adiv5_raw_read_no_check(uint16_t addr); -static uint32_t jlink_adiv5_clear_error(adiv5_debug_port_s *dp, bool protocol_recovery); static uint32_t jlink_adiv5_raw_access(adiv5_debug_port_s *dp, uint8_t rnw, uint16_t addr, uint32_t request_value); bool jlink_swd_init(adiv5_debug_port_s *dp) @@ -103,7 +97,6 @@ bool jlink_swd_init(adiv5_debug_port_s *dp) dp->write_no_check = jlink_adiv5_raw_write_no_check; dp->read_no_check = jlink_adiv5_raw_read_no_check; dp->dp_read = firmware_swdp_read; - dp->error = jlink_adiv5_clear_error; dp->low_access = jlink_adiv5_raw_access; return true; } @@ -226,56 +219,6 @@ static uint32_t jlink_adiv5_raw_read_no_check(const uint16_t addr) return ack == SWDP_ACK_OK ? data : 0U; } -static bool jlink_swd_line_reset(void) -{ - /* - * We have to send at least 50 cycles (actually at least 51 because of non-conformance - * in STM32 devices) of SWDIO held high to perform the line reset, then 4 cycles of it low - * to complete the reset and put the device back in idle - */ - const bool result = jlink_transfer(64U, jlink_line_reset_dir, jlink_line_reset_data, NULL); - if (!result) - DEBUG_ERROR("%s failed\n", __func__); - return result; -} - -static uint32_t jlink_adiv5_clear_error(adiv5_debug_port_s *const dp, const bool protocol_recovery) -{ - DEBUG_PROBE("jlink_adiv5_clear_error (protocol recovery? %s)\n", protocol_recovery ? "true" : "false"); - /* Only do the comms reset dance on DPv2+ w/ fault or to perform protocol recovery. */ - if ((dp->version >= 2 && dp->fault) || protocol_recovery) { - /* - * Note that on DPv2+ devices, during a protocol error condition - * the target becomes deselected during line reset. Once reset, - * we must then re-select the target to bring the device back - * into the expected state. - */ - jlink_swd_line_reset(); - if (dp->version >= 2) - jlink_adiv5_raw_write_no_check(ADIV5_DP_TARGETSEL, dp->targetsel); - jlink_adiv5_raw_read_no_check(ADIV5_DP_DPIDR); - /* Exception here is unexpected, so do not catch */ - } - const uint32_t err = jlink_adiv5_raw_read_no_check(ADIV5_DP_CTRLSTAT) & - (ADIV5_DP_CTRLSTAT_STICKYORUN | ADIV5_DP_CTRLSTAT_STICKYCMP | ADIV5_DP_CTRLSTAT_STICKYERR | - ADIV5_DP_CTRLSTAT_WDATAERR); - uint32_t clr = 0; - - if (err & ADIV5_DP_CTRLSTAT_STICKYORUN) - clr |= ADIV5_DP_ABORT_ORUNERRCLR; - if (err & ADIV5_DP_CTRLSTAT_STICKYCMP) - clr |= ADIV5_DP_ABORT_STKCMPCLR; - if (err & ADIV5_DP_CTRLSTAT_STICKYERR) - clr |= ADIV5_DP_ABORT_STKERRCLR; - if (err & ADIV5_DP_CTRLSTAT_WDATAERR) - clr |= ADIV5_DP_ABORT_WDERRCLR; - - if (clr) - jlink_adiv5_raw_write_no_check(ADIV5_DP_ABORT, clr); - dp->fault = 0; - return err; -} - static uint32_t jlink_adiv5_raw_read(adiv5_debug_port_s *const dp) { uint8_t result[5] = {0};