Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversions, cleanup, and fixes to the scanchain systems #978

Merged
merged 12 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SRC = \
gdb_hostio.c \
gdb_packet.c \
hex_utils.c \
jtag_devs.c \
jtag_scan.c \
lmi.c \
lpc_common.c \
Expand Down
2 changes: 1 addition & 1 deletion src/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int generic_crc32(target *t, uint32_t *crc_res, uint32_t base, size_t len)
base += read_len;
len -= read_len;
}
DEBUG_WARN("%d ms\n", platform_time_ms() - start_time);
DEBUG_WARN("%" PRIu32 " ms\n", platform_time_ms() - start_time);
*crc_res = crc;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ifneq ($(HOSTED_BMP_ONLY), 1)
endif

VPATH += platforms/pc
SRC += timing.c cl_utils.c utils.c jtag_devs.c
SRC += timing.c cl_utils.c utils.c
SRC += bmp_remote.c remote_swdptap.c remote_jtagtap.c
ifneq ($(HOSTED_BMP_ONLY), 1)
SRC += bmp_libusb.c stlinkv2.c
Expand Down
8 changes: 4 additions & 4 deletions src/platforms/hosted/dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,9 @@ void dap_jtagtap_tdi_tdo_seq(uint8_t *DO, bool final_tms, const uint8_t *TMS,
*p++ = transfers;
for (int i = 0; i < transfers; i++) {
*p++ = 1 | ((DO) ? DAP_JTAG_TDO_CAPTURE : 0) |
((TMS[i / 8] & (1 << (i & 7))) ? DAP_JTAG_TMS : 0);
((TMS[i >> 3] & (1 << (i & 7))) ? DAP_JTAG_TMS : 0);
if (DI)
*p++ = (DI[i / 8] & (1 << (i & 7))) ? 1 : 0;
*p++ = (DI[i >> 3] & (1 << (i & 7))) ? 1 : 0;
else
*p++ = 1;
}
Expand All @@ -733,9 +733,9 @@ void dap_jtagtap_tdi_tdo_seq(uint8_t *DO, bool final_tms, const uint8_t *TMS,
if (DO) {
for (int i = 0; i < transfers; i++) {
if (buf[i + 1])
DO[i / 8] |= (1 << (i & 7));
DO[i >> 3] |= (1 << (i & 7));
else
DO[i / 8] &= ~(1 << (i & 7));
DO[i >> 3] &= ~(1 << (i & 7));
}
}
ticks -= transfers;
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/stlinkv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ int jtag_scan_stlinkv2(bmp_info_t *info, const uint8_t *irlens)
if((jtag_devs[i].jd_idcode & dev_descr[j].idmask) ==
dev_descr[j].idcode) {
if(dev_descr[j].handler)
dev_descr[j].handler(&jtag_devs[i]);
dev_descr[j].handler(i);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/pc/cl_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
} else {
num_targets = platform_adiv5_swdp_scan(opt->opt_targetid);
if (!num_targets) {
DEBUG_WARN("Scan SWD failed, trying JTAG!\n");
DEBUG_INFO("Scan SWD failed, trying JTAG!\n");
num_targets = platform_jtag_scan(NULL);
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/target/adiv5.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,19 @@
#define ADIV5_AP_BASE ADIV5_AP_REG(0xF8)
#define ADIV5_AP_IDR ADIV5_AP_REG(0xFC)

/* Known designers seen in SYSROM-PIDR and JTAG IDCode.
* Ignore Bit 0 from the designer bits to get JEDEC Ids.
* Should get it's one file as not only related to Adiv5!
*/
/* Known designers seen in SYSROM-PIDR. Ignore Bit 0 from
* the designer bits to get JEDEC Ids with bit 7 ignored.*/
#define AP_DESIGNER_FREESCALE 0x00e
#define AP_DESIGNER_TEXAS 0x017
#define AP_DESIGNER_ATMEL 0x01f
#define AP_DESIGNER_STM 0x020
#define AP_DESIGNER_CYPRESS 0x034
#define AP_DESIGNER_INFINEON 0x041
#define DESIGNER_XILINX 0x049
esden marked this conversation as resolved.
Show resolved Hide resolved
#define AP_DESIGNER_NORDIC 0x244
#define AP_DESIGNER_ARM 0x43b
/*LPC845 with designer 501. Strange!? */
#define AP_DESIGNER_SPECULAR 0x501
#define AP_DESIGNER_CS 0x555
#define DESIGNER_XAMBALA 0x61e
esden marked this conversation as resolved.
Show resolved Hide resolved
#define AP_DESIGNER_ENERGY_MICRO 0x673
#define AP_DESIGNER_GIGADEVICE 0x751
#define AP_DESIGNER_RASPBERRY 0x927
Expand Down Expand Up @@ -289,7 +285,7 @@ void adiv5_ap_ref(ADIv5_AP_t *ap);
void adiv5_ap_unref(ADIv5_AP_t *ap);
void platform_add_jtag_dev(const int dev_index, const jtag_dev_t *jtag_dev);

void adiv5_jtag_dp_handler(jtag_dev_t *jd);
void adiv5_jtag_dp_handler(uint8_t jd_index);
int platform_jtag_dp_init(ADIv5_DP_t *dp);
int swdptap_init(ADIv5_DP_t *dp);

Expand Down
6 changes: 3 additions & 3 deletions src/target/adiv5_jtagdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@

static uint32_t adiv5_jtagdp_error(ADIv5_DP_t *dp);

void adiv5_jtag_dp_handler(jtag_dev_t *jd)
void adiv5_jtag_dp_handler(uint8_t jd_index)
{
ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));
if (!dp) { /* calloc failed: heap exhaustion */
DEBUG_WARN("calloc: failed in %s\n", __func__);
return;
}

dp->dp_jd_index = jd->jd_dev;
dp->idcode = jd->jd_idcode;
dp->dp_jd_index = jd_index;
dp->idcode = jtag_devs[jd_index].jd_idcode;
if ((PC_HOSTED == 0 ) || (!platform_jtag_dp_init(dp))) {
dp->dp_read = fw_adiv5_jtagdp_read;
dp->error = adiv5_jtagdp_error;
Expand Down
2 changes: 1 addition & 1 deletion src/target/adiv5_swdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int adiv5_swdp_scan(uint32_t targetid)
}
if (e2.type || initial_dp->fault) {
DEBUG_WARN("No usable DP found\n");
return 0;
return -1;
}
}
if ((idcode & ADIV5_DP_VERSION_MASK) == ADIV5_DPv2) {
Expand Down
49 changes: 30 additions & 19 deletions src/target/jtag_devs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright (C) 2011 Black Sphere Technologies Ltd.
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
* Copyright (C) 2022 1bitsquared - Rachel Mant <git@dragonmux.network>
*
* 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
Expand All @@ -25,37 +26,47 @@

jtag_dev_descr_t dev_descr[] = {
{.idcode = 0x0BA00477, .idmask = 0x0FFF0FFF,
.descr = "ARM Limited: ADIv5 JTAG-DP port.",
.descr = "ADIv5 JTAG-DP port.",
.handler = adiv5_jtag_dp_handler},
{.idcode = 0x00000477, .idmask = 0x00000FFF,
.descr = "Unknown ARM."},
{.idcode = 0x06410041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32, Medium density."},
.descr = "STM32, Medium density."},
{.idcode = 0x06412041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32, Low density."},
.descr = "STM32, Low density."},
{.idcode = 0x06414041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32, High density."},
.descr = "STM32, High density."},
{.idcode = 0x06416041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32L."},
.descr = "STM32L."},
{.idcode = 0x06418041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32, Connectivity Line."},
.descr = "STM32, Connectivity Line."},
{.idcode = 0x06420041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32, Value Line."},
.descr = "STM32, Value Line."},
{.idcode = 0x06428041, .idmask = 0x0FFFFFFF,
.descr = "ST Microelectronics: STM32, Value Line, High density."},
.descr = "STM32, Value Line, High density."},
{.idcode = 0x06411041, .idmask = 0xFFFFFFFF,
.descr = "ST Microelectronics: STM32F2xx."},
.descr = "STM32F2xx."},
{.idcode = 0x06422041, .idmask = 0xFFFFFFFF,
.descr = "ST Microelectronics: STM32F3xx."},
{.idcode = 0x06413041 , .idmask = 0xFFFFFFFF,
.descr = "ST Microelectronics: STM32F4xx."},
{.idcode = 0x0BB11477 , .idmask = 0xFFFFFFFF,
.descr = "STM32F3xx."},
{.idcode = 0x06413041, .idmask = 0xFFFFFFFF,
.descr = "STM32F4xx."},
{.idcode = 0x00000041, .idmask = 0x00000FFF,
.descr = "STM32 BSD."},
{.idcode = 0x0BB11477, .idmask = 0xFFFFFFFF,
.descr = "NPX: LPC11C24."},
{.idcode = 0x4BA00477 , .idmask = 0xFFFFFFFF,
{.idcode = 0x4BA00477, .idmask = 0xFFFFFFFF,
.descr = "NXP: LPC17xx family."},
{.idcode = 0x00000093, .idmask = 0x00000FFF,
.descr = "Xilinx."},
{.idcode = 0x0000063D, .idmask = 0x00000FFF,
.descr = "Xambala: RVDBG013."},
{.idcode = 0x000007A3, .idmask = 0x00000FFF,
.descr = "Gigadevice BSD."},
/* Just for fun, unsupported */
{.idcode = 0x8940303F, .idmask = 0xFFFFFFFF, .descr = "ATMEL: ATMega16."},
{.idcode = 0x0792603F, .idmask = 0xFFFFFFFF, .descr = "ATMEL: AT91SAM9261."},
{.idcode = 0x20270013, .idmask = 0xFFFFFFFF, .descr = "Intel: i80386ex."},
{.idcode = 0x07B7617F, .idmask = 0xFFFFFFFF, .descr = "Broadcom: BCM2835."},
{.idcode = 0x4BA00477, .idmask = 0xFFFFFFFF, .descr = "Broadcom: BCM2836."},
{.idcode = 0x8940303F, .idmask = 0xFFFFFFFF, .descr = "ATMega16."},
{.idcode = 0x0792603F, .idmask = 0xFFFFFFFF, .descr = "AT91SAM9261."},
{.idcode = 0x20270013, .idmask = 0xFFFFFFFF, .descr = "i80386ex."},
{.idcode = 0x07B7617F, .idmask = 0xFFFFFFFF, .descr = "BCM2835."},
{.idcode = 0x4BA00477, .idmask = 0xFFFFFFFF, .descr = "BCM2836."},
{.idcode = 0, .idmask = 0, .descr = "Unknown"},
};
2 changes: 1 addition & 1 deletion src/target/jtag_devs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef const struct jtag_dev_descr_s {
const uint32_t idcode;
const uint32_t idmask;
const char * const descr;
void (*const handler)(jtag_dev_t *jd);
void (*const handler)(uint8_t jd_index);
} jtag_dev_descr_t;
extern jtag_dev_descr_t dev_descr[];

Loading