swd: Remove swd_proc and swdptap.h.
This commit is contained in:
parent
b6fbf86743
commit
04d1c9805b
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SWDPTAP_H
|
||||
#define __SWDPTAP_H
|
||||
#include "adiv5.h"
|
||||
|
||||
typedef struct swd_proc_s {
|
||||
uint32_t (*swdptap_seq_in)(int ticks);
|
||||
bool (*swdptap_seq_in_parity)(uint32_t *data, int ticks);
|
||||
void (*swdptap_seq_out)(uint32_t MS, int ticks);
|
||||
void (*swdptap_seq_out_parity)(uint32_t MS, int ticks);
|
||||
# if PC_HOSTED == 1
|
||||
uint32_t (*swdp_read)(ADIv5_DP_t *dp, uint16_t addr);
|
||||
uint32_t (*swdp_error)(ADIv5_DP_t *dp);
|
||||
uint32_t (*swdp_low_access)(ADIv5_DP_t *dp, uint8_t RnW,
|
||||
uint16_t addr, uint32_t value);
|
||||
void (*swdp_abort)(ADIv5_DP_t *dp, uint32_t abort);
|
||||
#endif
|
||||
} swd_proc_t;
|
||||
extern swd_proc_t swd_proc;
|
||||
|
||||
# if PC_HOSTED == 1
|
||||
int platform_swdptap_init(void);
|
||||
# else
|
||||
int swdptap_init(void);
|
||||
# endif
|
||||
#endif
|
|
@ -21,8 +21,8 @@
|
|||
/* This file implements the SW-DP interface. */
|
||||
|
||||
#include "general.h"
|
||||
#include "swdptap.h"
|
||||
#include "timing.h"
|
||||
#include "adiv5.h"
|
||||
|
||||
enum {
|
||||
SWDIO_STATUS_FLOAT = 0,
|
||||
|
@ -204,14 +204,12 @@ static void swdptap_seq_out_parity(uint32_t MS, int ticks)
|
|||
for(cnt = swd_delay_cnt; --cnt > 0;);
|
||||
}
|
||||
|
||||
swd_proc_t swd_proc;
|
||||
|
||||
int swdptap_init(void)
|
||||
int swdptap_init(ADIv5_DP_t *dp)
|
||||
{
|
||||
swd_proc.swdptap_seq_in = swdptap_seq_in;
|
||||
swd_proc.swdptap_seq_in_parity = swdptap_seq_in_parity;
|
||||
swd_proc.swdptap_seq_out = swdptap_seq_out;
|
||||
swd_proc.swdptap_seq_out_parity = swdptap_seq_out_parity;
|
||||
dp->seq_in = swdptap_seq_in;
|
||||
dp->seq_in_parity = swdptap_seq_in_parity;
|
||||
dp->seq_out = swdptap_seq_out;
|
||||
dp->seq_out_parity = swdptap_seq_out_parity;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
#if !defined(__BMP_REMOTE_H_)
|
||||
#define __BMP_REMOTE_H_
|
||||
#include "swdptap.h"
|
||||
#include "jtagtap.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
@ -30,7 +29,7 @@ int platform_buffer_write(const uint8_t *data, int size);
|
|||
int platform_buffer_read(uint8_t *data, int size);
|
||||
|
||||
int remote_init(void);
|
||||
int remote_swdptap_init(swd_proc_t *swd_proc);
|
||||
int remote_swdptap_init(ADIv5_DP_t *dp);
|
||||
int remote_jtagtap_init(jtag_proc_t *jtag_proc);
|
||||
bool remote_target_get_power(void);
|
||||
const char *remote_target_voltage(void);
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <wchar.h>
|
||||
|
||||
#include "bmp_hosted.h"
|
||||
#include "swdptap.h"
|
||||
#include "dap.h"
|
||||
#include "cmsis_dap.h"
|
||||
|
||||
|
@ -368,7 +367,7 @@ int dap_jtag_dp_init(ADIv5_DP_t *dp)
|
|||
return true;
|
||||
}
|
||||
|
||||
int dap_swdptap_init(swd_proc_t *swd_proc)
|
||||
int dap_swdptap_init(ADIv5_DP_t *dp)
|
||||
{
|
||||
if (!(dap_caps & DAP_CAP_SWD))
|
||||
return 1;
|
||||
|
@ -379,14 +378,14 @@ int dap_swdptap_init(swd_proc_t *swd_proc)
|
|||
dap_led(0, 1);
|
||||
dap_reset_link(false);
|
||||
if (has_swd_sequence) {
|
||||
swd_proc->swdptap_seq_in = dap_swdptap_seq_in;
|
||||
swd_proc->swdptap_seq_in_parity = dap_swdptap_seq_in_parity;
|
||||
swd_proc->swdptap_seq_out = dap_swdptap_seq_out;
|
||||
swd_proc->swdptap_seq_out_parity = dap_swdptap_seq_out_parity;
|
||||
swd_proc->swdp_read = dap_dp_read_reg;
|
||||
swd_proc->swdp_error = dap_dp_error;
|
||||
swd_proc->swdp_low_access = dap_dp_low_access;
|
||||
swd_proc->swdp_abort = dap_dp_abort;
|
||||
dp->seq_in = dap_swdptap_seq_in;
|
||||
dp->seq_in_parity = dap_swdptap_seq_in_parity;
|
||||
dp->seq_out = dap_swdptap_seq_out;
|
||||
dp->seq_out_parity = dap_swdptap_seq_out_parity;
|
||||
dp->dp_read = dap_dp_read_reg;
|
||||
dp->error = dap_dp_error;
|
||||
dp->low_access = dap_dp_low_access;
|
||||
dp->abort = dap_dp_abort;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ int dap_enter_debug_swd(ADIv5_DP_t *dp);
|
|||
void dap_exit_function(void);
|
||||
void dap_adiv5_dp_defaults(ADIv5_DP_t *dp);
|
||||
int cmsis_dap_jtagtap_init(jtag_proc_t *jtag_proc);
|
||||
int dap_swdptap_init(swd_proc_t *swd_proc);
|
||||
int dap_swdptap_init(ADIv5_DP_t *dp);
|
||||
int dap_jtag_dp_init(ADIv5_DP_t *dp);
|
||||
uint32_t dap_swj_clock(uint32_t clock);
|
||||
void dap_swd_configure(uint8_t cfg);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#define __FTDI_BMP_H
|
||||
|
||||
#include "cl_utils.h"
|
||||
#include "swdptap.h"
|
||||
#include "jtagtap.h"
|
||||
|
||||
#include "bmp_hosted.h"
|
||||
|
@ -104,7 +103,7 @@ typedef struct cable_desc_s {
|
|||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
int ftdi_bmp_init(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info) {return -1;};
|
||||
int libftdi_swdptap_init(swd_proc_t *swd_proc) {return -1;};
|
||||
int libftdi_swdptap_init(ADIv5_DP_t *dp) {return -1;};
|
||||
int libftdi_jtagtap_init(jtag_proc_t *jtag_proc) {return 0;};
|
||||
void libftdi_buffer_flush(void) {};
|
||||
int libftdi_buffer_write(const uint8_t *data, int size) {return size;};
|
||||
|
@ -124,7 +123,7 @@ extern struct ftdi_context *ftdic;
|
|||
extern data_desc_t active_state;
|
||||
|
||||
int ftdi_bmp_init(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info);
|
||||
int libftdi_swdptap_init(swd_proc_t *swd_proc);
|
||||
int libftdi_swdptap_init(ADIv5_DP_t *dp);
|
||||
int libftdi_jtagtap_init(jtag_proc_t *jtag_proc);
|
||||
void libftdi_buffer_flush(void);
|
||||
int libftdi_buffer_write(const uint8_t *data, int size);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* Copyright (C) 2019 - 2020 Uwe Bonnes
|
||||
* Copyright (C) 2019 - 2021 Uwe Bonnes
|
||||
* (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -103,7 +103,7 @@ static int line_reset(bmp_info_t *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int swdptap_init(bmp_info_t *info)
|
||||
static int jlink_swdptap_init(bmp_info_t *info)
|
||||
{
|
||||
uint8_t cmd[2] = {CMD_GET_SELECT_IF, JLINK_IF_GET_AVAILABLE};
|
||||
uint8_t res[4];
|
||||
|
@ -119,7 +119,7 @@ static int swdptap_init(bmp_info_t *info)
|
|||
|
||||
int jlink_swdp_scan(bmp_info_t *info)
|
||||
{
|
||||
swdptap_init(info);
|
||||
jlink_swdptap_init(info);
|
||||
target_list_free();
|
||||
uint8_t cmd[44];
|
||||
cmd[0] = CMD_HW_JTAG3;
|
||||
|
|
|
@ -167,7 +167,7 @@ bool libftdi_swd_possible(bool *do_mpsse, bool *direct_bb_swd)
|
|||
return true;
|
||||
}
|
||||
|
||||
int libftdi_swdptap_init(swd_proc_t *swd_proc)
|
||||
int libftdi_swdptap_init(ADIv5_DP_t *dp)
|
||||
{
|
||||
if (!libftdi_swd_possible(&do_mpsse, &direct_bb_swd)) {
|
||||
DEBUG_WARN("SWD not possible or missing item in cable description.\n");
|
||||
|
@ -207,14 +207,14 @@ int libftdi_swdptap_init(swd_proc_t *swd_proc)
|
|||
libftdi_buffer_flush();
|
||||
olddir = SWDIO_STATUS_FLOAT;
|
||||
|
||||
swd_proc->swdptap_seq_in = swdptap_seq_in;
|
||||
swd_proc->swdptap_seq_in_parity = swdptap_seq_in_parity;
|
||||
swd_proc->swdptap_seq_out = swdptap_seq_out;
|
||||
swd_proc->swdptap_seq_out_parity = swdptap_seq_out_parity;
|
||||
swd_proc->swdp_read = firmware_swdp_read;
|
||||
swd_proc->swdp_error = firmware_swdp_error;
|
||||
swd_proc->swdp_low_access = firmware_swdp_low_access;
|
||||
swd_proc->swdp_abort = firmware_swdp_abort;
|
||||
dp->seq_in = swdptap_seq_in;
|
||||
dp->seq_in_parity = swdptap_seq_in_parity;
|
||||
dp->seq_out = swdptap_seq_out;
|
||||
dp->seq_out_parity = swdptap_seq_out_parity;
|
||||
dp->dp_read = firmware_swdp_read;
|
||||
dp->error = firmware_swdp_error;
|
||||
dp->low_access = firmware_swdp_low_access;
|
||||
dp->abort = firmware_swdp_abort;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*/
|
||||
|
||||
#include "general.h"
|
||||
#include "swdptap.h"
|
||||
#include "jtagtap.h"
|
||||
#include "target.h"
|
||||
#include "target_internal.h"
|
||||
|
@ -41,7 +40,6 @@
|
|||
|
||||
bmp_info_t info;
|
||||
|
||||
swd_proc_t swd_proc;
|
||||
jtag_proc_t jtag_proc;
|
||||
|
||||
void gdb_ident(char *p, int count)
|
||||
|
@ -128,6 +126,7 @@ int platform_adiv5_swdp_scan(uint32_t targetid)
|
|||
switch (info.bmp_type) {
|
||||
case BMP_TYPE_BMP:
|
||||
case BMP_TYPE_LIBFTDI:
|
||||
case BMP_TYPE_CMSIS_DAP:
|
||||
return adiv5_swdp_scan(targetid);
|
||||
break;
|
||||
case BMP_TYPE_STLINKV2:
|
||||
|
@ -143,27 +142,6 @@ int platform_adiv5_swdp_scan(uint32_t targetid)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case BMP_TYPE_CMSIS_DAP:
|
||||
if (dap_swdptap_init(&swd_proc))
|
||||
return 0;
|
||||
if (swd_proc.swdptap_seq_in) {
|
||||
dap_swd_configure(4); /* No abort for now*/
|
||||
return adiv5_swdp_scan(targetid);
|
||||
} else {
|
||||
/* We need to ignore errors with TARGET_SEL.
|
||||
* Therefore we need DAP_SWD_Sequence obly available on >= V1.2
|
||||
*/
|
||||
target_list_free();
|
||||
ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));
|
||||
if (dap_enter_debug_swd(dp)) {
|
||||
free(dp);
|
||||
} else {
|
||||
adiv5_dp_init(dp);
|
||||
if (target_list)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BMP_TYPE_JLINK:
|
||||
return jlink_swdp_scan(&info);
|
||||
default:
|
||||
|
@ -172,18 +150,18 @@ int platform_adiv5_swdp_scan(uint32_t targetid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int platform_swdptap_init(void)
|
||||
int swdptap_init(ADIv5_DP_t *dp)
|
||||
{
|
||||
switch (info.bmp_type) {
|
||||
case BMP_TYPE_BMP:
|
||||
return remote_swdptap_init(&swd_proc);
|
||||
return remote_swdptap_init(dp);
|
||||
case BMP_TYPE_CMSIS_DAP:
|
||||
// return dap_swdptap_init(&swd_proc);
|
||||
return dap_swdptap_init(dp);
|
||||
case BMP_TYPE_STLINKV2:
|
||||
case BMP_TYPE_JLINK:
|
||||
return 0;
|
||||
case BMP_TYPE_LIBFTDI:
|
||||
return libftdi_swdptap_init(&swd_proc);
|
||||
return libftdi_swdptap_init(dp);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ static uint32_t swdptap_seq_in(int ticks);
|
|||
static void swdptap_seq_out(uint32_t MS, int ticks);
|
||||
static void swdptap_seq_out_parity(uint32_t MS, int ticks);
|
||||
|
||||
int remote_swdptap_init(swd_proc_t *swd_proc)
|
||||
int remote_swdptap_init(ADIv5_DP_t *dp)
|
||||
{
|
||||
DEBUG_WIRE("remote_swdptap_init\n");
|
||||
uint8_t construct[REMOTE_MAX_MSG_SIZE];
|
||||
|
@ -50,14 +50,14 @@ int remote_swdptap_init(swd_proc_t *swd_proc)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
swd_proc->swdptap_seq_in = swdptap_seq_in;
|
||||
swd_proc->swdptap_seq_in_parity = swdptap_seq_in_parity;
|
||||
swd_proc->swdptap_seq_out = swdptap_seq_out;
|
||||
swd_proc->swdptap_seq_out_parity = swdptap_seq_out_parity;
|
||||
swd_proc->swdp_read = firmware_swdp_read;
|
||||
swd_proc->swdp_error = firmware_swdp_error;
|
||||
swd_proc->swdp_low_access = firmware_swdp_low_access;
|
||||
swd_proc->swdp_abort = firmware_swdp_abort;
|
||||
dp->seq_in = swdptap_seq_in;
|
||||
dp->seq_in_parity = swdptap_seq_in_parity;
|
||||
dp->seq_out = swdptap_seq_out;
|
||||
dp->seq_out_parity = swdptap_seq_out_parity;
|
||||
dp->dp_read = firmware_swdp_read;
|
||||
dp->error = firmware_swdp_error;
|
||||
dp->low_access = firmware_swdp_low_access;
|
||||
dp->abort = firmware_swdp_abort;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
12
src/remote.c
12
src/remote.c
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2019 Black Sphere Technologies Ltd.
|
||||
* Written by Dave Marples <dave@marples.net>
|
||||
* Modified 2020 - 2021 by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,7 +22,6 @@
|
|||
#include "general.h"
|
||||
#include "remote.h"
|
||||
#include "gdb_packet.h"
|
||||
#include "swdptap.h"
|
||||
#include "jtagtap.h"
|
||||
#include "gdb_if.h"
|
||||
#include "platform.h"
|
||||
|
@ -145,7 +145,7 @@ void remotePacketProcessSWD(uint8_t i, char *packet)
|
|||
if (i==2) {
|
||||
remote_dp.dp_read = firmware_swdp_read;
|
||||
remote_dp.low_access = firmware_swdp_low_access;
|
||||
swdptap_init();
|
||||
swdptap_init(&remote_dp);
|
||||
_respond(REMOTE_RESP_OK, 0);
|
||||
} else {
|
||||
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN);
|
||||
|
@ -154,27 +154,27 @@ void remotePacketProcessSWD(uint8_t i, char *packet)
|
|||
|
||||
case REMOTE_IN_PAR: /* SI = In parity ============================= */
|
||||
ticks=remotehston(2,&packet[2]);
|
||||
badParity = swd_proc.swdptap_seq_in_parity(¶m, ticks);
|
||||
badParity = remote_dp.seq_in_parity(¶m, ticks);
|
||||
_respond(badParity?REMOTE_RESP_PARERR:REMOTE_RESP_OK,param);
|
||||
break;
|
||||
|
||||
case REMOTE_IN: /* Si = In ======================================= */
|
||||
ticks=remotehston(2,&packet[2]);
|
||||
param = swd_proc.swdptap_seq_in(ticks);
|
||||
param = remote_dp.seq_in(ticks);
|
||||
_respond(REMOTE_RESP_OK,param);
|
||||
break;
|
||||
|
||||
case REMOTE_OUT: /* So= Out ====================================== */
|
||||
ticks=remotehston(2,&packet[2]);
|
||||
param=remotehston(-1, &packet[4]);
|
||||
swd_proc.swdptap_seq_out(param, ticks);
|
||||
remote_dp.seq_out(param, ticks);
|
||||
_respond(REMOTE_RESP_OK, 0);
|
||||
break;
|
||||
|
||||
case REMOTE_OUT_PAR: /* SO = Out parity ========================== */
|
||||
ticks=remotehston(2,&packet[2]);
|
||||
param=remotehston(-1, &packet[4]);
|
||||
swd_proc.swdptap_seq_out_parity(param, ticks);
|
||||
remote_dp.seq_out_parity(param, ticks);
|
||||
_respond(REMOTE_RESP_OK, 0);
|
||||
break;
|
||||
|
||||
|
|
|
@ -139,6 +139,10 @@
|
|||
#define ADIV5_LOW_WRITE 0
|
||||
#define ADIV5_LOW_READ 1
|
||||
|
||||
#define SWDP_ACK_OK 0x01
|
||||
#define SWDP_ACK_WAIT 0x02
|
||||
#define SWDP_ACK_FAULT 0x04
|
||||
|
||||
enum align {
|
||||
ALIGN_BYTE = 0,
|
||||
ALIGN_HALFWORD = 1,
|
||||
|
@ -206,6 +210,8 @@ struct ADIv5_AP_s {
|
|||
uint16_t ap_partno;
|
||||
};
|
||||
|
||||
unsigned int make_packet_request(uint8_t RnW, uint16_t addr);
|
||||
|
||||
#if PC_HOSTED == 0
|
||||
static inline uint32_t adiv5_dp_read(ADIv5_DP_t *dp, uint16_t addr)
|
||||
{
|
||||
|
@ -280,6 +286,7 @@ void platform_add_jtag_dev(const int dev_index, const jtag_dev_t *jtag_dev);
|
|||
|
||||
void adiv5_jtag_dp_handler(uint8_t jd_index, uint32_t j_idcode);
|
||||
int platform_jtag_dp_init(ADIv5_DP_t *dp);
|
||||
int swdptap_init(ADIv5_DP_t *dp);
|
||||
|
||||
void adiv5_mem_write(ADIv5_AP_t *ap, uint32_t dest, const void *src, size_t len);
|
||||
uint64_t adiv5_ap_read_pidr(ADIv5_AP_t *ap, uint32_t addr);
|
||||
|
|
|
@ -26,15 +26,10 @@
|
|||
#include "general.h"
|
||||
#include "exception.h"
|
||||
#include "adiv5.h"
|
||||
#include "swdptap.h"
|
||||
#include "target.h"
|
||||
#include "target_internal.h"
|
||||
|
||||
#define SWDP_ACK_OK 0x01
|
||||
#define SWDP_ACK_WAIT 0x02
|
||||
#define SWDP_ACK_FAULT 0x04
|
||||
|
||||
static unsigned int make_packet_request(uint8_t RnW, uint16_t addr)
|
||||
unsigned int make_packet_request(uint8_t RnW, uint16_t addr)
|
||||
{
|
||||
bool APnDP = addr & ADIV5_APnDP;
|
||||
addr &= 0xff;
|
||||
|
@ -62,8 +57,7 @@ bool firmware_dp_low_write(ADIv5_DP_t *dp, uint16_t addr, const uint32_t data)
|
|||
unsigned int request = make_packet_request(ADIV5_LOW_WRITE, addr & 0xf);
|
||||
dp->seq_out(request, 8);
|
||||
int res = dp->seq_in(3);
|
||||
dp->seq_out(data, 32);
|
||||
dp->seq_out(__builtin_parity(data), 1);
|
||||
dp->seq_out_parity(data, 32);
|
||||
return (res != 1);
|
||||
}
|
||||
|
||||
|
@ -72,9 +66,7 @@ static bool firmware_dp_low_read(ADIv5_DP_t *dp, uint16_t addr, uint32_t *res)
|
|||
unsigned int request = make_packet_request(ADIV5_LOW_READ, addr & 0xf);
|
||||
dp->seq_out(request, 8);
|
||||
dp->seq_in(3);
|
||||
*res = dp->seq_in(32);
|
||||
int paritybit = dp->seq_in(1);
|
||||
return (__builtin_parity(*res) != paritybit);
|
||||
return dp->seq_in_parity(res, 32);
|
||||
}
|
||||
|
||||
/* Try first the dormant to SWD procedure.
|
||||
|
@ -86,36 +78,21 @@ int adiv5_swdp_scan(uint32_t targetid)
|
|||
target_list_free();
|
||||
ADIv5_DP_t idp, *initial_dp = &idp;
|
||||
memset(initial_dp, 0, sizeof(ADIv5_DP_t));
|
||||
#if PC_HOSTED == 1
|
||||
if (platform_swdptap_init()) {
|
||||
exit(-1);
|
||||
}
|
||||
#else
|
||||
if (swdptap_init()) {
|
||||
if (swdptap_init(initial_dp))
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HOSTED == 0
|
||||
initial_dp->seq_out= swd_proc.swdptap_seq_out;
|
||||
initial_dp->seq_in= swd_proc.swdptap_seq_in;
|
||||
initial_dp->dp_low_write = firmware_dp_low_write;
|
||||
initial_dp->dp_low_read = firmware_dp_low_read;
|
||||
initial_dp->dp_read = firmware_swdp_read;
|
||||
initial_dp->error = firmware_swdp_error;
|
||||
initial_dp->low_access = firmware_swdp_low_access;
|
||||
initial_dp->abort = firmware_swdp_abort;
|
||||
#else
|
||||
initial_dp->seq_out= swd_proc.swdptap_seq_out;
|
||||
initial_dp->seq_in= swd_proc.swdptap_seq_in;
|
||||
initial_dp->dp_low_write = firmware_dp_low_write;
|
||||
initial_dp->dp_low_write = firmware_dp_low_read;
|
||||
initial_dp->dp_read = firmware_swdp_read;
|
||||
initial_dp->dp_read = swd_proc->swdp_read;
|
||||
initial_dp->error = swd_proc->swdp_error;
|
||||
initial_dp->low_access = swd_proc->swdp_low_access;
|
||||
initial_dp->abort = swd_proc->swdp_abort;
|
||||
#endif
|
||||
/* Set defaults when no procedure given*/
|
||||
if (!initial_dp->dp_low_write)
|
||||
initial_dp->dp_low_write = firmware_dp_low_write;
|
||||
if (!initial_dp->dp_low_read)
|
||||
initial_dp->dp_low_read = firmware_dp_low_read;
|
||||
if (!initial_dp->error)
|
||||
initial_dp->error = firmware_swdp_error;
|
||||
if (!initial_dp->dp_read)
|
||||
initial_dp->dp_read = firmware_swdp_read;
|
||||
if (!initial_dp->error)
|
||||
initial_dp->error = firmware_swdp_error;
|
||||
if (!initial_dp->low_access)
|
||||
initial_dp->low_access = firmware_swdp_low_access;
|
||||
/* DORMANT-> SWD sequence*/
|
||||
initial_dp->seq_out(0xFFFFFFFF, 32);
|
||||
initial_dp->seq_out(0xFFFFFFFF, 32);
|
||||
|
@ -163,6 +140,12 @@ int adiv5_swdp_scan(uint32_t targetid)
|
|||
target_id = adiv5_dp_read(initial_dp, ADIV5_DP_CTRLSTAT);
|
||||
adiv5_dp_write(initial_dp, ADIV5_DP_SELECT, 0);
|
||||
DEBUG_INFO("TARGETID %08" PRIx32 "\n", target_id);
|
||||
switch (target_id) {
|
||||
case 0x01002927: /* RP2040 */
|
||||
/* Release evt. handing RESCUE DP reset*/
|
||||
adiv5_dp_write(initial_dp, ADIV5_DP_CTRLSTAT, 0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
is_v2 = false;
|
||||
}
|
||||
|
@ -177,9 +160,8 @@ int adiv5_swdp_scan(uint32_t targetid)
|
|||
dp_targetid = (i << 28) | (target_id & 0x0fffffff);
|
||||
initial_dp->dp_low_write(initial_dp, ADIV5_DP_TARGETSEL,
|
||||
dp_targetid);
|
||||
bool res = initial_dp->dp_low_read(initial_dp, ADIV5_DP_IDCODE,
|
||||
&idcode);
|
||||
if (res)
|
||||
if (initial_dp->dp_low_read(initial_dp, ADIV5_DP_IDCODE,
|
||||
&idcode))
|
||||
continue;
|
||||
if (dp_targetid == 0xf1002927) /* Fixme: Handle RP2040 rescue port */
|
||||
continue;
|
||||
|
@ -225,7 +207,7 @@ uint32_t firmware_swdp_read(ADIv5_DP_t *dp, uint16_t addr)
|
|||
uint32_t dummy;
|
||||
dp->dp_low_read(dp, ADIV5_DP_IDCODE, &dummy);
|
||||
}
|
||||
err = firmware_swdp_read(dp, ADIV5_DP_CTRLSTAT) &
|
||||
err = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT) &
|
||||
(ADIV5_DP_CTRLSTAT_STICKYORUN | ADIV5_DP_CTRLSTAT_STICKYCMP |
|
||||
ADIV5_DP_CTRLSTAT_STICKYERR | ADIV5_DP_CTRLSTAT_WDATAERR);
|
||||
|
||||
|
@ -256,13 +238,13 @@ uint32_t firmware_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
|
|||
|
||||
platform_timeout_set(&timeout, 2000);
|
||||
do {
|
||||
swd_proc.swdptap_seq_out(request, 8);
|
||||
ack = swd_proc.swdptap_seq_in(3);
|
||||
dp->seq_out(request, 8);
|
||||
ack = dp->seq_in(3);
|
||||
if (ack == SWDP_ACK_FAULT) {
|
||||
/* On fault, abort() and repeat the command once.*/
|
||||
firmware_swdp_error(dp);
|
||||
swd_proc.swdptap_seq_out(request, 8);
|
||||
ack = swd_proc.swdptap_seq_in(3);
|
||||
dp->error(dp);
|
||||
dp->seq_out(request, 8);
|
||||
ack = dp->seq_in(3);
|
||||
}
|
||||
} while (ack == SWDP_ACK_WAIT && !platform_timeout_is_expired(&timeout));
|
||||
|
||||
|
@ -278,10 +260,10 @@ uint32_t firmware_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
|
|||
raise_exception(EXCEPTION_ERROR, "SWDP invalid ACK");
|
||||
|
||||
if(RnW) {
|
||||
if(swd_proc.swdptap_seq_in_parity(&response, 32)) /* Give up on parity error */
|
||||
if(dp->seq_in_parity(&response, 32)) /* Give up on parity error */
|
||||
raise_exception(EXCEPTION_ERROR, "SWDP Parity error");
|
||||
} else {
|
||||
swd_proc.swdptap_seq_out_parity(value, 32);
|
||||
dp->seq_out_parity(value, 32);
|
||||
/* ARM Debug Interface Architecture Specification ADIv5.0 to ADIv5.2
|
||||
* tells to clock the data through SW-DP to either :
|
||||
* - immediate start a new transaction
|
||||
|
@ -291,7 +273,7 @@ uint32_t firmware_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
|
|||
* Implement last option to favour correctness over
|
||||
* slight speed decrease
|
||||
*/
|
||||
swd_proc.swdptap_seq_out(0, 8);
|
||||
dp->seq_out(0, 8);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "general.h"
|
||||
#include "swdptap.h"
|
||||
|
||||
uint32_t swdptap_seq_in(int ticks)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue