Classify debug messages
Firmware BMP with ENABLE_DEBUG=1 will print WARN and INFO as before. PC-Hosted BMPwill alway print to stderr. Warn is printed unconditional, INFO, GDB, TARGET, DONGLE and WIRE will print if their appropriate bit in cl_debuglevel is set via the -v verbose command line argument. INFO will go to stdout with -t or -l.
This commit is contained in:
parent
c5c21bb958
commit
dc3fd2eb06
|
@ -26,7 +26,7 @@ struct exception *innermost_exception;
|
|||
void raise_exception(uint32_t type, const char *msg)
|
||||
{
|
||||
struct exception *e;
|
||||
DEBUG("Exception: %s\n", msg);
|
||||
DEBUG_WARN("Exception: %s\n", msg);
|
||||
for (e = innermost_exception; e; e = e->outer) {
|
||||
if (e->mask & type) {
|
||||
e->type = type;
|
||||
|
|
|
@ -120,7 +120,8 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
|||
gdb_putpacketz("E02");
|
||||
break;
|
||||
}
|
||||
DEBUG("m packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len);
|
||||
DEBUG_GDB("m packet: addr = %" PRIx32 ", len = %" PRIx32 "\n",
|
||||
addr, len);
|
||||
uint8_t mem[len];
|
||||
if (target_mem_read(cur_target, mem, addr, len))
|
||||
gdb_putpacketz("E01");
|
||||
|
@ -145,7 +146,8 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
|||
gdb_putpacketz("E02");
|
||||
break;
|
||||
}
|
||||
DEBUG("M packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len);
|
||||
DEBUG_GDB("M packet: addr = %" PRIx32 ", len = %" PRIx32 "\n",
|
||||
addr, len);
|
||||
uint8_t mem[len];
|
||||
unhexify(mem, pbuf + hex, len);
|
||||
if (target_mem_write(cur_target, addr, mem, len))
|
||||
|
@ -242,7 +244,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
|||
if (in_syscall) {
|
||||
return hostio_reply(tc, pbuf, size);
|
||||
} else {
|
||||
DEBUG("*** F packet when not in syscall! '%s'\n", pbuf);
|
||||
DEBUG_GDB("*** F packet when not in syscall! '%s'\n", pbuf);
|
||||
gdb_putpacketz("");
|
||||
}
|
||||
break;
|
||||
|
@ -295,7 +297,8 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
|||
gdb_putpacketz("E02");
|
||||
break;
|
||||
}
|
||||
DEBUG("X packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len);
|
||||
DEBUG_GDB("X packet: addr = %" PRIx32 ", len = %" PRIx32 "\n",
|
||||
addr, len);
|
||||
if (target_mem_write(cur_target, addr, pbuf+bin, len))
|
||||
gdb_putpacketz("E01");
|
||||
else
|
||||
|
@ -319,7 +322,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
|||
break;
|
||||
|
||||
default: /* Packet not implemented */
|
||||
DEBUG("*** Unsupported packet: %s\n", pbuf);
|
||||
DEBUG_GDB("*** Unsupported packet: %s\n", pbuf);
|
||||
gdb_putpacketz("");
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +413,7 @@ handle_q_packet(char *packet, int len)
|
|||
gdb_putpacket_f("C%lx", generic_crc32(cur_target, addr, alen));
|
||||
|
||||
} else {
|
||||
DEBUG("*** Unsupported packet: %s\n", packet);
|
||||
DEBUG_GDB("*** Unsupported packet: %s\n", packet);
|
||||
gdb_putpacket("", 0);
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +481,7 @@ handle_v_packet(char *packet, int plen)
|
|||
|
||||
} else if (sscanf(packet, "vFlashErase:%08lx,%08lx", &addr, &len) == 2) {
|
||||
/* Erase Flash Memory */
|
||||
DEBUG("Flash Erase %08lX %08lX\n", addr, len);
|
||||
DEBUG_GDB("Flash Erase %08lX %08lX\n", addr, len);
|
||||
if(!cur_target) { gdb_putpacketz("EFF"); return; }
|
||||
|
||||
if(!flash_mode) {
|
||||
|
@ -495,7 +498,7 @@ handle_v_packet(char *packet, int plen)
|
|||
} else if (sscanf(packet, "vFlashWrite:%08lx:%n", &addr, &bin) == 1) {
|
||||
/* Write Flash Memory */
|
||||
len = plen - bin;
|
||||
DEBUG("Flash Write %08lX %08lX\n", addr, len);
|
||||
DEBUG_GDB("Flash Write %08lX %08lX\n", addr, len);
|
||||
if(cur_target && target_flash_write(cur_target, addr, (void*)packet + bin, len) == 0)
|
||||
gdb_putpacketz("OK");
|
||||
else
|
||||
|
@ -507,7 +510,7 @@ handle_v_packet(char *packet, int plen)
|
|||
flash_mode = 0;
|
||||
|
||||
} else {
|
||||
DEBUG("*** Unsupported packet: %s\n", packet);
|
||||
DEBUG_GDB("*** Unsupported packet: %s\n", packet);
|
||||
gdb_putpacket("", 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,16 +118,16 @@ int gdb_getpacket(char *packet, int size)
|
|||
gdb_if_putchar('+', 1); /* send ack */
|
||||
packet[i] = 0;
|
||||
|
||||
#ifdef DEBUG_GDBPACKET
|
||||
DEBUG("%s : ", __func__);
|
||||
#if PC_HOSTED == 1
|
||||
DEBUG_GDB_WIRE("%s : ", __func__);
|
||||
for(int j = 0; j < i; j++) {
|
||||
c = packet[j];
|
||||
if ((c >= 32) && (c < 127))
|
||||
DEBUG("%c", c);
|
||||
DEBUG_GDB_WIRE("%c", c);
|
||||
else
|
||||
DEBUG("\\x%02X", c);
|
||||
DEBUG_GDB_WIRE("\\x%02X", c);
|
||||
}
|
||||
DEBUG("\n");
|
||||
DEBUG_GDB_WIRE("\n");
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
|
@ -141,18 +141,16 @@ void gdb_putpacket(const char *packet, int size)
|
|||
int tries = 0;
|
||||
|
||||
do {
|
||||
#ifdef DEBUG_GDBPACKET
|
||||
DEBUG("%s : ", __func__);
|
||||
#endif
|
||||
DEBUG_GDB_WIRE("%s : ", __func__);
|
||||
csum = 0;
|
||||
gdb_if_putchar('$', 0);
|
||||
for(i = 0; i < size; i++) {
|
||||
c = packet[i];
|
||||
#ifdef DEBUG_GDBPACKET
|
||||
#if PC_HOSTED == 1
|
||||
if ((c >= 32) && (c < 127))
|
||||
DEBUG("%c", c);
|
||||
DEBUG_GDB_WIRE("%c", c);
|
||||
else
|
||||
DEBUG("\\x%02X", c);
|
||||
DEBUG_GDB_WIRE("\\x%02X", c);
|
||||
#endif
|
||||
if((c == '$') || (c == '#') || (c == '}')) {
|
||||
gdb_if_putchar('}', 0);
|
||||
|
@ -167,9 +165,7 @@ void gdb_putpacket(const char *packet, int size)
|
|||
snprintf(xmit_csum, sizeof(xmit_csum), "%02X", csum);
|
||||
gdb_if_putchar(xmit_csum[0], 0);
|
||||
gdb_if_putchar(xmit_csum[1], 1);
|
||||
#ifdef DEBUG_GDBPACKET
|
||||
DEBUG("\n");
|
||||
#endif
|
||||
DEBUG_GDB_WIRE("\n");
|
||||
} while((gdb_if_getchar_to(2000) != '+') && (tries++ < 3));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,116 @@
|
|||
#include "platform.h"
|
||||
#include "platform_support.h"
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG printf
|
||||
enum BMP_DEBUG {
|
||||
BMP_DEBUG_NONE = 0,
|
||||
BMP_DEBUG_INFO = 1,
|
||||
BMP_DEBUG_GDB = 2,
|
||||
BMP_DEBUG_TARGET = 4,
|
||||
BMP_DEBUG_PROBE = 8,
|
||||
BMP_DEBUG_WIRE = 0x10,
|
||||
BMP_DEBUG_MAX = 0x20,
|
||||
BMP_DEBUG_STDOUT = 0x8000,
|
||||
};
|
||||
|
||||
#if PC_HOSTED == 0
|
||||
/* For BMP debug output on a firmware BMP platform, using
|
||||
* BMP PC-Hosted is the preferred way. Printing DEBUG_WARN
|
||||
* and DEBUG_INFO is kept for comptibiluty.
|
||||
*/
|
||||
# if defined(ENABLE_DEBUG)
|
||||
# define DEBUG_WARN printf
|
||||
# define DEBUG_INFO printf
|
||||
# else
|
||||
# define DEBUG_WARN(...)
|
||||
# define DEBUG_INFO(...)
|
||||
# endif
|
||||
# define DEBUG_GDB(...)
|
||||
# define DEBUG_TARGET(...)
|
||||
# define DEBUG_PROBE(...)
|
||||
# define DEBUG_WIRE(...)
|
||||
# define DEBUG_GDB_WIRE(...)
|
||||
#else
|
||||
# include <stdarg.h>
|
||||
extern int cl_debuglevel;
|
||||
|
||||
static inline void DEBUG_WARN(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void DEBUG_INFO(const char *format, ...)
|
||||
{
|
||||
if (~cl_debuglevel & BMP_DEBUG_INFO)
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
if (cl_debuglevel & BMP_DEBUG_STDOUT)
|
||||
vfprintf(stdout, format, ap);
|
||||
else
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void DEBUG_GDB(const char *format, ...)
|
||||
{
|
||||
if (~cl_debuglevel & BMP_DEBUG_GDB)
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void DEBUG_GDB_WIRE(const char *format, ...)
|
||||
{
|
||||
if ((cl_debuglevel & (BMP_DEBUG_GDB | BMP_DEBUG_WIRE)) !=
|
||||
(BMP_DEBUG_GDB | BMP_DEBUG_WIRE))
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void DEBUG_TARGET(const char *format, ...)
|
||||
{
|
||||
if (~cl_debuglevel & BMP_DEBUG_TARGET)
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void DEBUG_PROBE(const char *format, ...)
|
||||
{
|
||||
if (~cl_debuglevel & BMP_DEBUG_PROBE)
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void DEBUG_WIRE(const char *format, ...)
|
||||
{
|
||||
if (~cl_debuglevel & BMP_DEBUG_WIRE)
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ALIGN(x, n) (((x) + (n) - 1) & ~((n) - 1))
|
||||
|
|
|
@ -61,7 +61,7 @@ void morse(const char *msg, char repeat)
|
|||
{
|
||||
#if PC_HOSTED == 1
|
||||
if (msg)
|
||||
DEBUG("%s\n", msg);
|
||||
DEBUG_WARN("%s\n", msg);
|
||||
(void) repeat;
|
||||
#else
|
||||
morse_msg = morse_ptr = msg;
|
||||
|
|
|
@ -135,8 +135,6 @@
|
|||
#define TRACE_IRQ NVIC_TIM3_IRQ
|
||||
#define TRACE_ISR tim3_isr
|
||||
|
||||
#define DEBUG(...)
|
||||
|
||||
#define gpio_set_val(port, pin, val) do { \
|
||||
if(val) \
|
||||
gpio_set((port), (pin)); \
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* Additions by Dave Marples <dave@marples.net>
|
||||
* Additions by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
* Modifications (C) 2020 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
|
||||
|
@ -45,12 +45,12 @@ int remote_init(bool verbose)
|
|||
c = platform_buffer_read((uint8_t *)construct, REMOTE_MAX_MSG_SIZE);
|
||||
|
||||
if ((!c) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr,"Remote Start failed, error %s\n",
|
||||
DEBUG_WARN("Remote Start failed, error %s\n",
|
||||
c ? (char *)&(construct[1]) : "unknown");
|
||||
return -1;
|
||||
}
|
||||
if (verbose)
|
||||
printf("Remote is %s\n", &construct[1]);
|
||||
DEBUG_WARN("Remote is %s\n", &construct[1]);
|
||||
char *p = strstr(&construct[1], "(Firmware v");
|
||||
if (!p)
|
||||
return -1;
|
||||
|
@ -77,8 +77,8 @@ bool remote_target_get_power(void)
|
|||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr," platform_target_get_power failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
DEBUG_WARN(" platform_target_get_power failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ void remote_target_set_power(bool power)
|
|||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "platform_target_set_power failed, error %s\n",
|
||||
DEBUG_WARN("platform_target_set_power failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -115,8 +115,8 @@ void remote_srst_set_val(bool assert)
|
|||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "platform_srst_set_val failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
DEBUG_WARN("platform_srst_set_val failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ bool remote_srst_get_val(void)
|
|||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "platform_srst_set_val failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
DEBUG_WARN("platform_srst_set_val failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
return (construct[1] == '1');
|
||||
|
@ -152,7 +152,7 @@ const char *remote_target_voltage(void)
|
|||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "platform_target_voltage failed, error %s\n",
|
||||
DEBUG_WARN("platform_target_voltage failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(- 1);
|
||||
}
|
||||
|
@ -168,10 +168,11 @@ static uint32_t remote_adiv5_dp_read(ADIv5_DP_t *dp, uint16_t addr)
|
|||
platform_buffer_write(construct, s);
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
printf("%s error %d\n", __func__, s);
|
||||
DEBUG_WARN("%s error %d\n", __func__, s);
|
||||
}
|
||||
uint32_t dest[1];
|
||||
unhexify(dest, (const char*)&construct[1], 4);
|
||||
DEBUG_PROBE("dp_read addr %04x: %08" PRIx32 "\n", dest[0]);
|
||||
return dest[0];
|
||||
}
|
||||
|
||||
|
@ -180,12 +181,12 @@ static uint32_t remote_adiv5_low_access(
|
|||
{
|
||||
(void)dp;
|
||||
uint8_t construct[REMOTE_MAX_MSG_SIZE];
|
||||
int s = snprintf((char *)construct, REMOTE_MAX_MSG_SIZE, REMOTE_LOW_ACCESS_STR,
|
||||
RnW, addr, value);
|
||||
int s = snprintf((char *)construct, REMOTE_MAX_MSG_SIZE,
|
||||
REMOTE_LOW_ACCESS_STR, RnW, addr, value);
|
||||
platform_buffer_write(construct, s);
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
printf("%s error %d\n", __func__, s);
|
||||
DEBUG_WARN("%s error %d\n", __func__, s);
|
||||
}
|
||||
uint32_t dest[1];
|
||||
unhexify(dest, (const char*)&construct[1], 4);
|
||||
|
@ -200,7 +201,7 @@ static uint32_t remote_adiv5_ap_read(ADIv5_AP_t *ap, uint16_t addr)
|
|||
platform_buffer_write(construct, s);
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
printf("%s error %d\n", __func__, s);
|
||||
DEBUG_WARN("%s error %d\n", __func__, s);
|
||||
}
|
||||
uint32_t dest[1];
|
||||
unhexify(dest, (const char*)&construct[1], 4);
|
||||
|
@ -215,7 +216,7 @@ static void remote_adiv5_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
|
|||
platform_buffer_write(construct, s);
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
printf("%s error %d\n", __func__, s);
|
||||
DEBUG_WARN("%s error %d\n", __func__, s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -227,8 +228,7 @@ static void remote_mem_read(
|
|||
(void)ap;
|
||||
if (len == 0)
|
||||
return;
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("memread @ %" PRIx32 " len %ld, start: \n",
|
||||
DEBUG_WIRE("memread @ %" PRIx32 " len %ld, start: \n",
|
||||
src, len);
|
||||
uint8_t construct[REMOTE_MAX_MSG_SIZE];
|
||||
int s;
|
||||
|
@ -252,11 +252,11 @@ static void remote_mem_read(
|
|||
} else {
|
||||
if(construct[0] == REMOTE_RESP_ERR) {
|
||||
ap->dp->fault = 1;
|
||||
printf("%s returned REMOTE_RESP_ERR at addr: 0x%08x\n",
|
||||
DEBUG_WARN("%s returned REMOTE_RESP_ERR at addr: 0x%08x\n",
|
||||
__func__, src);
|
||||
break;
|
||||
} else {
|
||||
printf("%s error %d\n", __func__, s);
|
||||
DEBUG_WARN("%s error %d\n", __func__, s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -290,11 +290,11 @@ static void remote_ap_mem_read(
|
|||
} else {
|
||||
if(construct[0] == REMOTE_RESP_ERR) {
|
||||
ap->dp->fault = 1;
|
||||
printf("%s returned REMOTE_RESP_ERR at apsel %d, "
|
||||
DEBUG_WARN("%s returned REMOTE_RESP_ERR at apsel %d, "
|
||||
"addr: 0x%08" PRIx32 "\n", __func__, ap->apsel, src);
|
||||
break;
|
||||
} else {
|
||||
printf("%s error %d around 0x%08" PRIx32 "\n",
|
||||
DEBUG_WARN("%s error %d around 0x%08" PRIx32 "\n",
|
||||
__func__, s, src);
|
||||
break;
|
||||
}
|
||||
|
@ -334,10 +334,10 @@ static void remote_ap_mem_write_sized(
|
|||
continue;
|
||||
if ((s > 0) && (construct[0] == REMOTE_RESP_ERR)) {
|
||||
ap->dp->fault = 1;
|
||||
printf("%s returned REMOTE_RESP_ERR at apsel %d, "
|
||||
DEBUG_WARN("%s returned REMOTE_RESP_ERR at apsel %d, "
|
||||
"addr: 0x%08x\n", __func__, ap->apsel, dest);
|
||||
} else {
|
||||
printf("%s error %d around address 0x%08" PRIx32 "\n",
|
||||
DEBUG_WARN("%s error %d around address 0x%08" PRIx32 "\n",
|
||||
__func__, s, dest);
|
||||
break;
|
||||
}
|
||||
|
@ -347,7 +347,8 @@ static void remote_ap_mem_write_sized(
|
|||
void remote_adiv5_dp_defaults(ADIv5_DP_t *dp)
|
||||
{
|
||||
if (remote_init(false)) {
|
||||
printf("Please update BMP firmware for substantial speed increase!\n");
|
||||
DEBUG_WARN(
|
||||
"Please update BMP firmware for substantial speed increase!\n");
|
||||
return;
|
||||
}
|
||||
dp->low_access = remote_adiv5_low_access;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2019-20 Uwe Bonnes
|
||||
* Copyright (C) 2019-20 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
|
||||
|
@ -62,7 +62,7 @@ int dap_init(bmp_info_t *info)
|
|||
* FIXME: Find a solution to decipher from the device.
|
||||
*/
|
||||
if ((info->vid == 0x1fc9) && (info->pid == 0x0132)) {
|
||||
printf("Blacklist\n");
|
||||
DEBUG_WARN("Blacklist\n");
|
||||
report_size = 64 + 1;
|
||||
}
|
||||
handle = hid_open(info->vid, info->pid, serial);
|
||||
|
@ -71,17 +71,17 @@ int dap_init(bmp_info_t *info)
|
|||
dap_disconnect();
|
||||
size = dap_info(DAP_INFO_CAPABILITIES, hid_buffer, sizeof(hid_buffer));
|
||||
dap_caps = hid_buffer[0];
|
||||
printf(" Cap (0x%2x): %s%s%s", hid_buffer[0],
|
||||
DEBUG_INFO(" Cap (0x%2x): %s%s%s", hid_buffer[0],
|
||||
(hid_buffer[0] & 1)? "SWD" : "",
|
||||
((hid_buffer[0] & 3) == 3) ? "/" : "",
|
||||
(hid_buffer[0] & 2)? "JTAG" : "");
|
||||
if (hid_buffer[0] & 4)
|
||||
printf(", SWO_UART");
|
||||
DEBUG_INFO(", SWO_UART");
|
||||
if (hid_buffer[0] & 8)
|
||||
printf(", SWO_MANCHESTER");
|
||||
DEBUG_INFO(", SWO_MANCHESTER");
|
||||
if (hid_buffer[0] & 0x10)
|
||||
printf(", Atomic Cmds");
|
||||
printf("\n");
|
||||
DEBUG_INFO(", Atomic Cmds");
|
||||
DEBUG_INFO("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -155,35 +155,31 @@ int dbg_dap_cmd(uint8_t *data, int size, int rsize)
|
|||
hid_buffer[0] = 0x00; // Report ID??
|
||||
memcpy(&hid_buffer[1], data, rsize);
|
||||
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE) {
|
||||
printf("cmd : ");
|
||||
for(int i = 0; (i < 16) && (i < rsize + 1); i++)
|
||||
printf("%02x.", hid_buffer[i]);
|
||||
printf("\n");
|
||||
}
|
||||
DEBUG_WIRE("cmd : ");
|
||||
for(int i = 0; (i < 16) && (i < rsize + 1); i++)
|
||||
DEBUG_WIRE("%02x.", hid_buffer[i]);
|
||||
DEBUG_WIRE("\n");
|
||||
res = hid_write(handle, hid_buffer, rsize + 1);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Error: %ls\n", hid_error(handle));
|
||||
DEBUG_WARN( "Error: %ls\n", hid_error(handle));
|
||||
exit(-1);
|
||||
}
|
||||
if (size) {
|
||||
res = hid_read(handle, hid_buffer, report_size + 1);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "debugger read(): %ls\n", hid_error(handle));
|
||||
DEBUG_WARN( "debugger read(): %ls\n", hid_error(handle));
|
||||
exit(-1);
|
||||
}
|
||||
if (size && hid_buffer[0] != cmd) {
|
||||
printf("cmd %02x invalid response received %02x\n",
|
||||
DEBUG_WARN("cmd %02x invalid response received %02x\n",
|
||||
cmd, hid_buffer[0]);
|
||||
}
|
||||
res--;
|
||||
memcpy(data, &hid_buffer[1], (size < res) ? size : res);
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE) {
|
||||
printf("cmd res:");
|
||||
for(int i = 0; (i < 16) && (i < size + 4); i++)
|
||||
printf("%02x.", hid_buffer[i]);
|
||||
printf("\n");
|
||||
}
|
||||
DEBUG_WIRE("cmd res:");
|
||||
for(int i = 0; (i < 16) && (i < size + 4); i++)
|
||||
DEBUG_WIRE("%02x.", hid_buffer[i]);
|
||||
DEBUG_WIRE("\n");
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -196,10 +192,8 @@ static void dap_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
|
|||
if (len == 0)
|
||||
return;
|
||||
enum align align = MIN(ALIGNOF(src), ALIGNOF(len));
|
||||
#if 0
|
||||
printf("memread @ %" PRIx32 " len %ld, align %d , start: \n",
|
||||
DEBUG_WIRE("memread @ %" PRIx32 " len %ld, align %d , start: \n",
|
||||
src, len, align);
|
||||
#endif
|
||||
if (((unsigned)(1 << align)) == len)
|
||||
return dap_read_single(ap, dest, src, align);
|
||||
/* One word transfer for every byte/halfword/word
|
||||
|
@ -218,7 +212,7 @@ static void dap_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
|
|||
unsigned int res = dap_read_block(ap, dest, src, transfersize,
|
||||
align);
|
||||
if (res) {
|
||||
// printf("mem_read failed %02x\n", res);
|
||||
DEBUG_WIRE("mem_read failed %02x\n", res);
|
||||
ap->dp->fault = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -228,7 +222,7 @@ static void dap_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
|
|||
src += transfersize;
|
||||
}
|
||||
}
|
||||
// printf("memread res last data %08" PRIx32 "\n", ((uint32_t*)dest)[-1]);
|
||||
DEBUG_WIRE("memread res last data %08" PRIx32 "\n", ((uint32_t*)dest)[-1]);
|
||||
}
|
||||
|
||||
static void dap_mem_write_sized(
|
||||
|
@ -237,10 +231,8 @@ static void dap_mem_write_sized(
|
|||
{
|
||||
if (len == 0)
|
||||
return;
|
||||
#if 0
|
||||
printf("memwrite @ %" PRIx32 " len %ld, align %d , %08x start: \n",
|
||||
dest, len, align, *(uint32_t *)src);
|
||||
#endif
|
||||
DEBUG_WIRE("memwrite @ %" PRIx32 " len %ld, align %d , %08x start: \n",
|
||||
dest, len, align, *(uint32_t *)src);
|
||||
if (((unsigned)(1 << align)) == len)
|
||||
return dap_write_single(ap, dest, src, align);
|
||||
unsigned int max_size = (dbg_get_report_size() - 5) >> (2 - align);
|
||||
|
@ -256,7 +248,7 @@ static void dap_mem_write_sized(
|
|||
unsigned int res = dap_write_block(ap, dest, src, transfersize,
|
||||
align);
|
||||
if (res) {
|
||||
printf("mem_write failed %02x\n", res);
|
||||
DEBUG_WARN("mem_write failed %02x\n", res);
|
||||
ap->dp->fault = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -266,7 +258,7 @@ static void dap_mem_write_sized(
|
|||
src += transfersize;
|
||||
}
|
||||
}
|
||||
// printf("memwrite done\n");
|
||||
DEBUG_WIRE("memwrite done\n");
|
||||
}
|
||||
|
||||
int dap_enter_debug_swd(ADIv5_DP_t *dp)
|
||||
|
@ -311,39 +303,34 @@ static void cmsis_dap_jtagtap_tms_seq(uint32_t MS, int ticks)
|
|||
uint8_t TMS[4] = {MS & 0xff, (MS >> 8) & 0xff, (MS >> 16) & 0xff,
|
||||
(MS >> 24) & 0xff};
|
||||
dap_jtagtap_tdi_tdo_seq(NULL, false, TMS, NULL, ticks);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("tms_seq DI %08x %d\n", MS, ticks);
|
||||
DEBUG_PROBE("tms_seq DI %08x %d\n", MS, ticks);
|
||||
}
|
||||
|
||||
static void cmsis_dap_jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms,
|
||||
const uint8_t *DI, int ticks)
|
||||
{
|
||||
dap_jtagtap_tdi_tdo_seq(DO, (final_tms), NULL, DI, ticks);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("jtagtap_tdi_tdo_seq %d, %02x-> %02x\n", ticks, DI[0], DO[0]);
|
||||
DEBUG_PROBE("jtagtap_tdi_tdo_seq %d, %02x-> %02x\n", ticks, DI[0], DO[0]);
|
||||
}
|
||||
|
||||
static void cmsis_dap_jtagtap_tdi_seq(const uint8_t final_tms,
|
||||
const uint8_t *DI, int ticks)
|
||||
{
|
||||
dap_jtagtap_tdi_tdo_seq(NULL, (final_tms), NULL, DI, ticks);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("jtagtap_tdi_seq %d, %02x\n", ticks, DI[0]);
|
||||
DEBUG_PROBE("jtagtap_tdi_seq %d, %02x\n", ticks, DI[0]);
|
||||
}
|
||||
|
||||
static uint8_t cmsis_dap_jtagtap_next(uint8_t dTMS, uint8_t dTDI)
|
||||
{
|
||||
uint8_t tdo[1];
|
||||
dap_jtagtap_tdi_tdo_seq(tdo, false, &dTMS, &dTDI, 1);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("next tms %02x tdi %02x tdo %02x\n", dTMS, dTDI, tdo[0]);
|
||||
DEBUG_PROBE("next tms %02x tdi %02x tdo %02x\n", dTMS, dTDI, tdo[0]);
|
||||
return (tdo[0] & 1);
|
||||
}
|
||||
|
||||
int cmsis_dap_jtagtap_init(jtag_proc_t *jtag_proc)
|
||||
{
|
||||
if (cl_debuglevel)
|
||||
printf("jtap_init\n");
|
||||
DEBUG_PROBE("jtap_init\n");
|
||||
if (!(dap_caps & DAP_CAP_JTAG))
|
||||
return -1;
|
||||
mode = DAP_CAP_JTAG;
|
||||
|
|
|
@ -31,11 +31,8 @@
|
|||
*/
|
||||
|
||||
/*- Includes ----------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <general.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "dap.h"
|
||||
#include "jtag_scan.h"
|
||||
|
||||
|
@ -312,7 +309,7 @@ static void dap_line_reset(void)
|
|||
};
|
||||
dbg_dap_cmd(buf, sizeof(buf), 10);
|
||||
if (buf[0])
|
||||
printf("line reset failed\n");
|
||||
DEBUG_WARN("line reset failed\n");
|
||||
}
|
||||
|
||||
static uint32_t wait_word(uint8_t *buf, int size, int len, uint8_t *dp_fault)
|
||||
|
@ -324,11 +321,11 @@ static uint32_t wait_word(uint8_t *buf, int size, int len, uint8_t *dp_fault)
|
|||
} while (buf[1] == DAP_TRANSFER_WAIT);
|
||||
|
||||
if (buf[1] > DAP_TRANSFER_WAIT) {
|
||||
// printf("dap_read_reg fault\n");
|
||||
// DEBUG_WARN("dap_read_reg fault\n");
|
||||
*dp_fault = 1;
|
||||
}
|
||||
if (buf[1] == DAP_TRANSFER_ERROR) {
|
||||
printf("dap_read_reg, protocoll error\n");
|
||||
DEBUG_WARN("dap_read_reg, protocoll error\n");
|
||||
dap_line_reset();
|
||||
}
|
||||
uint32_t res =
|
||||
|
@ -349,7 +346,7 @@ uint32_t dap_read_reg(ADIv5_DP_t *dp, uint8_t reg)
|
|||
buf[2] = 0x01; // Request size
|
||||
buf[3] = reg | DAP_TRANSFER_RnW;
|
||||
uint32_t res = wait_word(buf, 8, 4, &dp->fault);
|
||||
// printf("\tdap_read_reg %02x %08x\n", reg, res);
|
||||
DEBUG_WIRE("\tdap_read_reg %02x %08x\n", reg, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -357,7 +354,7 @@ uint32_t dap_read_reg(ADIv5_DP_t *dp, uint8_t reg)
|
|||
void dap_write_reg(ADIv5_DP_t *dp, uint8_t reg, uint32_t data)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
// printf("\tdap_write_reg %02x %08x\n", reg, data);
|
||||
DEBUG_PROBE("\tdap_write_reg %02x %08x\n", reg, data);
|
||||
|
||||
buf[0] = ID_DAP_TRANSFER;
|
||||
uint8_t dap_index = 0;
|
||||
|
@ -377,11 +374,12 @@ void dap_write_reg(ADIv5_DP_t *dp, uint8_t reg, uint32_t data)
|
|||
} while (buf[1] == DAP_TRANSFER_WAIT);
|
||||
|
||||
if (buf[1] > DAP_TRANSFER_WAIT) {
|
||||
// printf("dap_write_reg %02x data %08x:fault\n", reg, data);
|
||||
DEBUG_PROBE("dap_write_reg %02x data %08x:fault\n", reg, data);
|
||||
dp->fault = 1;
|
||||
}
|
||||
if (buf[1] == DAP_TRANSFER_ERROR) {
|
||||
// printf("dap_write_reg %02x data %08x: protocoll error\n", reg, data);
|
||||
DEBUG_PROBE("dap_write_reg %02x data %08x: protocoll error\n",
|
||||
reg, data);
|
||||
dap_line_reset();
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +400,7 @@ unsigned int dap_read_block(ADIv5_AP_t *ap, void *dest, uint32_t src,
|
|||
dbg_dap_cmd(buf, 1023, 5 + 1);
|
||||
unsigned int transferred = buf[0] + (buf[1] << 8);
|
||||
if (buf[2] > DAP_TRANSFER_FAULT) {
|
||||
printf("line_reset\n");
|
||||
DEBUG_PROBE("line_reset\n");
|
||||
dap_line_reset();
|
||||
}
|
||||
if (sz != transferred) {
|
||||
|
@ -561,7 +559,7 @@ void dap_ap_mem_access_setup(ADIv5_AP_t *ap, uint32_t addr, enum align align)
|
|||
|
||||
uint32_t dap_ap_read(ADIv5_AP_t *ap, uint16_t addr)
|
||||
{
|
||||
// printf("dap_ap_read_start\n");
|
||||
DEBUG_PROBE("dap_ap_read_start\n");
|
||||
uint8_t buf[63], *p = buf;
|
||||
buf[0] = ID_DAP_TRANSFER;
|
||||
uint8_t dap_index = 0;
|
||||
|
@ -583,7 +581,7 @@ uint32_t dap_ap_read(ADIv5_AP_t *ap, uint16_t addr)
|
|||
|
||||
void dap_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
|
||||
{
|
||||
// printf("dap_ap_write addr %04x value %08x\n", addr, value);
|
||||
DEBUG_PROBE("dap_ap_write addr %04x value %08x\n", addr, value);
|
||||
uint8_t buf[63], *p = buf;
|
||||
uint8_t dap_index = 0;
|
||||
if (ap->dp->dev)
|
||||
|
@ -602,7 +600,6 @@ void dap_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
|
|||
*p++ = (value >> 16) & 0xff;
|
||||
*p++ = (value >> 24) & 0xff;
|
||||
dbg_dap_cmd(buf, sizeof(buf), p - buf);
|
||||
// printf("dap_ap_write done\n");
|
||||
}
|
||||
|
||||
void dap_read_single(ADIv5_AP_t *ap, void *dest, uint32_t src, enum align align)
|
||||
|
@ -673,7 +670,7 @@ void dap_jtagtap_tdi_tdo_seq(uint8_t *DO, bool final_tms, const uint8_t *TMS,
|
|||
p += n_di_bytes;
|
||||
dbg_dap_cmd(buf, sizeof(buf), p - buf);
|
||||
if (buf[0] != DAP_OK)
|
||||
printf("Failed %02x\n", buf[0]);
|
||||
DEBUG_WARN("dap_jtagtap_tdi_tdo_seq failed %02x\n", buf[0]);
|
||||
if (DO) {
|
||||
memcpy(DO, &buf[1], (transfers + 7) >> 3);
|
||||
DO += (transfers + 7) >> 3;
|
||||
|
@ -692,7 +689,7 @@ void dap_jtagtap_tdi_tdo_seq(uint8_t *DO, bool final_tms, const uint8_t *TMS,
|
|||
}
|
||||
dbg_dap_cmd(buf, sizeof(buf), p - buf);
|
||||
if (buf[0] == DAP_ERROR)
|
||||
printf("Failed %02x\n", buf[0]);
|
||||
DEBUG_WARN("dap_jtagtap_tdi_tdo_seq failed %02x\n", buf[0]);
|
||||
if (DO) {
|
||||
if (buf[1] & 1)
|
||||
DO[last_byte] |= (1 << last_bit);
|
||||
|
@ -719,7 +716,7 @@ void dap_jtagtap_tdi_tdo_seq(uint8_t *DO, bool final_tms, const uint8_t *TMS,
|
|||
}
|
||||
dbg_dap_cmd(buf, sizeof(buf), p - buf);
|
||||
if (buf[0] == DAP_ERROR)
|
||||
printf("Failed %02x\n", buf[0]);
|
||||
DEBUG_WARN("dap_jtagtap_tdi_tdo_seq failed %02x\n", buf[0]);
|
||||
if (DO) {
|
||||
for (int i = 0; i < transfers; i++) {
|
||||
if (buf[i + 1])
|
||||
|
@ -740,7 +737,7 @@ int dap_jtag_configure(void)
|
|||
for (; i < jtag_dev_count; i++) {
|
||||
struct jtag_dev_s *jtag_dev = &jtag_devs[i];
|
||||
*p++ = jtag_dev->ir_len;
|
||||
printf("irlen %d\n", jtag_dev->ir_len);
|
||||
DEBUG_PROBE("irlen %d\n", jtag_dev->ir_len);
|
||||
}
|
||||
if ((!i || i >= JTAG_MAX_DEVS))
|
||||
return -1;
|
||||
|
@ -748,6 +745,6 @@ int dap_jtag_configure(void)
|
|||
buf[1] = i;
|
||||
dbg_dap_cmd(buf, sizeof(buf), p - buf);
|
||||
if (buf[0] != DAP_OK)
|
||||
printf("dap_jtag_configure Failed %02x\n", buf[0]);
|
||||
DEBUG_WARN("dap_jtag_configure Failed %02x\n", buf[0]);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -190,54 +190,50 @@ int ftdi_bmp_init(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info)
|
|||
if (strcmp(cable_desc[index].name, cl_opts->opt_cable) == 0)
|
||||
break;
|
||||
|
||||
if (index == sizeof(cable_desc)/sizeof(cable_desc[0])){
|
||||
fprintf(stderr, "No cable matching %s found\n", cl_opts->opt_cable);
|
||||
if (index == sizeof(cable_desc)/sizeof(cable_desc[0])) {
|
||||
DEBUG_WARN( "No cable matching %s found\n", cl_opts->opt_cable);
|
||||
return -1;
|
||||
}
|
||||
|
||||
active_cable = &cable_desc[index];
|
||||
|
||||
printf("\nBlack Magic Probe (" FIRMWARE_VERSION ")\n");
|
||||
printf("Copyright (C) 2015 Black Sphere Technologies Ltd.\n");
|
||||
printf("License GPLv3+: GNU GPL version 3 or later "
|
||||
"<http://gnu.org/licenses/gpl.html>\n\n");
|
||||
|
||||
DEBUG_WARN("Black Magic Probe for FTDI/MPSSE\n");
|
||||
if(ftdic) {
|
||||
ftdi_usb_close(ftdic);
|
||||
ftdi_free(ftdic);
|
||||
ftdic = NULL;
|
||||
}
|
||||
if((ftdic = ftdi_new()) == NULL) {
|
||||
fprintf(stderr, "ftdi_new: %s\n",
|
||||
DEBUG_WARN( "ftdi_new: %s\n",
|
||||
ftdi_get_error_string(ftdic));
|
||||
abort();
|
||||
}
|
||||
info->ftdic = ftdic;
|
||||
if((err = ftdi_set_interface(ftdic, active_cable->interface)) != 0) {
|
||||
fprintf(stderr, "ftdi_set_interface: %d: %s\n",
|
||||
DEBUG_WARN( "ftdi_set_interface: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
goto error_1;
|
||||
}
|
||||
if((err = ftdi_usb_open_desc(
|
||||
ftdic, active_cable->vendor, active_cable->product,
|
||||
active_cable->description, cl_opts->opt_serial)) != 0) {
|
||||
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
|
||||
DEBUG_WARN( "unable to open ftdi device: %d (%s)\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
goto error_1;
|
||||
}
|
||||
|
||||
if((err = ftdi_set_latency_timer(ftdic, 1)) != 0) {
|
||||
fprintf(stderr, "ftdi_set_latency_timer: %d: %s\n",
|
||||
DEBUG_WARN( "ftdi_set_latency_timer: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
goto error_2;
|
||||
}
|
||||
if((err = ftdi_set_baudrate(ftdic, 1000000)) != 0) {
|
||||
fprintf(stderr, "ftdi_set_baudrate: %d: %s\n",
|
||||
DEBUG_WARN( "ftdi_set_baudrate: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
goto error_2;
|
||||
}
|
||||
if((err = ftdi_write_data_set_chunksize(ftdic, BUF_SIZE)) != 0) {
|
||||
fprintf(stderr, "ftdi_write_data_set_chunksize: %d: %s\n",
|
||||
DEBUG_WARN( "ftdi_write_data_set_chunksize: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
goto error_2;
|
||||
}
|
||||
|
@ -260,7 +256,7 @@ bool libftdi_srst_get_val(void) { return false; }
|
|||
void libftdi_buffer_flush(void)
|
||||
{
|
||||
assert(ftdi_write_data(ftdic, outbuf, bufptr) == bufptr);
|
||||
// printf("FT2232 libftdi_buffer flush: %d bytes\n", bufptr);
|
||||
DEBUG_WIRE("FT2232 libftdi_buffer flush: %d bytes\n", bufptr);
|
||||
bufptr = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ static void jlink_print_caps(bmp_info_t *info)
|
|||
uint8_t res[4];
|
||||
send_recv(info->usb_link, cmd, 1, res, sizeof(res));
|
||||
uint32_t caps = res[0] | (res[1] << 8) | (res[2] << 16) | (res[3] << 24);
|
||||
printf("Caps %" PRIx32 "\n", caps);
|
||||
DEBUG_INFO("Caps %" PRIx32 "\n", caps);
|
||||
if (caps & JLINK_CAP_GET_HW_VERSION) {
|
||||
uint8_t cmd[1] = {CMD_GET_HW_VERSION};
|
||||
send_recv(info->usb_link, cmd, 1, NULL, 0);
|
||||
send_recv(info->usb_link, NULL, 0, res, sizeof(res));
|
||||
printf("HW: Type %d, Major %d, Minor %d, Rev %d\n",
|
||||
DEBUG_INFO("HW: Type %d, Major %d, Minor %d, Rev %d\n",
|
||||
res[3], res[2], res[1], res[0]);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ static void jlink_print_speed(bmp_info_t *info)
|
|||
uint32_t speed = res[0] | (res[1] << 8) | (res[2] << 16) | (res[3] << 24);
|
||||
double freq_mhz = speed / 1000000.0;
|
||||
uint16_t divisor = res[4] | (res[5] << 8);
|
||||
printf("Emulator speed %3.1f MHz, Mindiv %d\n", freq_mhz, divisor);
|
||||
DEBUG_INFO("Emulator speed %3.1f MHz, Mindiv %d\n", freq_mhz, divisor);
|
||||
}
|
||||
|
||||
static void jlink_print_version(bmp_info_t *info)
|
||||
|
@ -72,7 +72,7 @@ static void jlink_print_version(bmp_info_t *info)
|
|||
send_recv(info->usb_link, cmd, 1, len_str, sizeof(len_str));
|
||||
uint8_t version[0x70];
|
||||
send_recv(info->usb_link, NULL, 0, version, sizeof(version));
|
||||
printf("%s\n", version );
|
||||
DEBUG_INFO("%s\n", version );
|
||||
}
|
||||
|
||||
static void jlink_print_interfaces(bmp_info_t *info)
|
||||
|
@ -83,16 +83,15 @@ static void jlink_print_interfaces(bmp_info_t *info)
|
|||
cmd[1] = JLINK_IF_GET_AVAILABLE;
|
||||
uint8_t res1[4];
|
||||
send_recv(info->usb_link, cmd, 2, res1, sizeof(res1));
|
||||
printf("%s active", (res[0] == SELECT_IF_SWD) ? "SWD":
|
||||
DEBUG_INFO("%s active", (res[0] == SELECT_IF_SWD) ? "SWD":
|
||||
(res[0] == SELECT_IF_JTAG) ? "JTAG" : "NONE");
|
||||
uint8_t other_interface = res1[0] - (res[0] + 1);
|
||||
if (other_interface)
|
||||
printf(", %s available",
|
||||
DEBUG_INFO(", %s available\n",
|
||||
(other_interface == JLINK_IF_SWD) ? "SWD": "JTAG");
|
||||
else
|
||||
printf(", %s not available",
|
||||
DEBUG_WARN(", %s not available\n",
|
||||
((res[0] + 1) == JLINK_IF_SWD) ? "JTAG": "SWD");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void jlink_info(bmp_info_t *info)
|
||||
|
@ -109,7 +108,7 @@ static int initialize_handle(bmp_info_t *info, libusb_device *dev)
|
|||
struct libusb_config_descriptor *config;
|
||||
int ret = libusb_get_active_config_descriptor(dev, &config);
|
||||
if (ret != LIBUSB_SUCCESS) {
|
||||
fprintf(stderr, "Failed to get configuration descriptor: %s.",
|
||||
DEBUG_WARN( "Failed to get configuration descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
return -1;
|
||||
}
|
||||
|
@ -128,13 +127,13 @@ static int initialize_handle(bmp_info_t *info, libusb_device *dev)
|
|||
found_interface = true;
|
||||
if (libusb_claim_interface (
|
||||
info->usb_link->ul_libusb_device_handle, i)) {
|
||||
fprintf(stderr, " Can not claim handle\n");
|
||||
DEBUG_WARN( " Can not claim handle\n");
|
||||
found_interface = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!found_interface) {
|
||||
fprintf(stderr, "No suitable interface found.");
|
||||
DEBUG_WARN( "No suitable interface found.");
|
||||
libusb_free_config_descriptor(config);
|
||||
return -1;
|
||||
}
|
||||
|
@ -162,7 +161,7 @@ int jlink_init(bmp_info_t *info)
|
|||
int ret = -1;
|
||||
libusb_device **devs;
|
||||
if (libusb_get_device_list(info->libusb_ctx, &devs) < 0) {
|
||||
fprintf(stderr, "libusb_get_device_list() failed");
|
||||
DEBUG_WARN( "libusb_get_device_list() failed");
|
||||
return ret;
|
||||
}
|
||||
int i = 0;
|
||||
|
@ -170,7 +169,7 @@ int jlink_init(bmp_info_t *info)
|
|||
libusb_device *dev = devs[i];
|
||||
struct libusb_device_descriptor desc;
|
||||
if (libusb_get_device_descriptor(dev, &desc) < 0) {
|
||||
fprintf(stderr, "libusb_get_device_descriptor() failed");
|
||||
DEBUG_WARN( "libusb_get_device_descriptor() failed");
|
||||
goto error;;
|
||||
}
|
||||
if (desc.idVendor != USB_PID_SEGGER)
|
||||
|
@ -198,7 +197,7 @@ int jlink_init(bmp_info_t *info)
|
|||
jl->rep_trans = libusb_alloc_transfer(0);
|
||||
if (!jl->req_trans || !jl->rep_trans ||
|
||||
!jl->ep_tx || !jl->ep_rx) {
|
||||
fprintf(stderr,"Device setup failed\n");
|
||||
DEBUG_WARN("Device setup failed\n");
|
||||
goto error;
|
||||
}
|
||||
libusb_free_device_list(devs, 1);
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
*
|
||||
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* Copyright (C) 2019 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
* Copyright (C) 2019 - 2020 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
|
||||
|
@ -96,7 +97,7 @@ static int line_reset(bmp_info_t *info)
|
|||
send_recv(info->usb_link, NULL, 0, res, 1);
|
||||
|
||||
if (res[0] != 0) {
|
||||
fprintf(stderr, "Line reset failed\n");
|
||||
DEBUG_WARN( "Line reset failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -174,7 +175,7 @@ int jlink_swdp_scan(bmp_info_t *info)
|
|||
send_recv(info->usb_link, NULL, 0, res, 1);
|
||||
|
||||
if (res[0] != 0) {
|
||||
fprintf(stderr, "Line reset failed\n");
|
||||
DEBUG_WARN( "Line reset failed\n");
|
||||
return 0;
|
||||
}
|
||||
dp->idcode = jlink_adiv5_swdp_low_access(dp, 1, ADIV5_DP_IDCODE, 0);
|
||||
|
@ -265,15 +266,15 @@ static uint32_t jlink_adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
|
|||
raise_exception(EXCEPTION_TIMEOUT, "SWDP ACK timeout");
|
||||
|
||||
if(ack == SWDP_ACK_FAULT) {
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
fprintf(stderr, "Fault\n");
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET)
|
||||
DEBUG_WARN( "Fault\n");
|
||||
dp->fault = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ack != SWDP_ACK_OK) {
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
fprintf(stderr, "Protocol\n");
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET)
|
||||
DEBUG_WARN( "Protocol\n");
|
||||
line_reset(&info);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ static void jtagtap_reset(void)
|
|||
|
||||
static void jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("jtagtap_tms_seq 0x%08" PRIx32 ", ticks %d\n", MS, ticks);
|
||||
DEBUG_PROBE("jtagtap_tms_seq 0x%08" PRIx32 ", ticks %d\n", MS, ticks);
|
||||
int len = (ticks + 7) / 8;
|
||||
uint8_t cmd[12];
|
||||
cmd[0] = CMD_HW_JTAG3;
|
||||
|
@ -68,13 +67,13 @@ static void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms,
|
|||
if (!ticks)
|
||||
return;
|
||||
int len = (ticks + 7) / 8;
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
printf("jtagtap_tdi_tdo %s, ticks %d, DI: ",
|
||||
if (cl_debuglevel & BMP_DEBUG_PROBE) {
|
||||
DEBUG_PROBE("jtagtap_tdi_tdo %s, ticks %d, DI: ",
|
||||
(final_tms) ? "Final TMS" : "", ticks);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf("%02x", DI[i]);
|
||||
DEBUG_PROBE("%02x", DI[i]);
|
||||
}
|
||||
printf("\n");
|
||||
DEBUG_PROBE("\n");
|
||||
}
|
||||
uint8_t *cmd = alloca(4 + 2 * len);
|
||||
cmd[0] = CMD_HW_JTAG3;
|
||||
|
@ -103,25 +102,24 @@ static void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms,
|
|||
static void jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI,
|
||||
int ticks)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
printf("jtagtap_tdi_seq %s:", (final_tms)? "final_tms" : "");
|
||||
if (cl_debuglevel & BMP_DEBUG_PROBE) {
|
||||
DEBUG_PROBE("jtagtap_tdi_seq %s:", (final_tms)? "final_tms" : "");
|
||||
const uint8_t *p = DI;
|
||||
unsigned int i = (ticks & 7) & ~7 ;
|
||||
if (i > 16)
|
||||
i = 16;
|
||||
while (i--)
|
||||
printf(" %02x", *p++);
|
||||
DEBUG_PROBE(" %02x", *p++);
|
||||
if (ticks > (16 * 8))
|
||||
printf(" ...");
|
||||
printf("\n");
|
||||
DEBUG_PROBE(" ...");
|
||||
DEBUG_PROBE("\n");
|
||||
}
|
||||
return jtagtap_tdi_tdo_seq(NULL, final_tms, DI, ticks);
|
||||
}
|
||||
|
||||
static uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDI)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("jtagtap_next TMS 0x%02x, TDI %02x\n", dTMS, dTDI);
|
||||
DEBUG_PROBE("jtagtap_next TMS 0x%02x, TDI %02x\n", dTMS, dTDI);
|
||||
uint8_t cmd[6];
|
||||
cmd[0] = CMD_HW_JTAG3;
|
||||
cmd[1] = 0;
|
||||
|
@ -140,13 +138,12 @@ static uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDI)
|
|||
|
||||
int jlink_jtagtap_init(bmp_info_t *info, jtag_proc_t *jtag_proc)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("jtap_init\n");
|
||||
DEBUG_PROBE("jtap_init\n");
|
||||
uint8_t cmd_switch[2] = {CMD_GET_SELECT_IF, JLINK_IF_GET_AVAILABLE};
|
||||
uint8_t res[4];
|
||||
send_recv(info->usb_link, cmd_switch, 2, res, sizeof(res));
|
||||
if (!(res[0] & JLINK_IF_JTAG)) {
|
||||
fprintf(stderr, "JTAG not available\n");
|
||||
DEBUG_WARN("JTAG not available\n");
|
||||
return -1;
|
||||
}
|
||||
cmd_switch[1] = SELECT_IF_JTAG;
|
||||
|
@ -176,7 +173,7 @@ int jlink_jtagtap_init(bmp_info_t *info, jtag_proc_t *jtag_proc)
|
|||
send_recv(info->usb_link, NULL, 0, res, 1);
|
||||
|
||||
if (res[0] != 0) {
|
||||
fprintf(stderr, "Switch to JTAGt failed\n");
|
||||
DEBUG_WARN("Switch to JTAG failed\n");
|
||||
return 0;
|
||||
}
|
||||
jtag_proc->jtagtap_reset = jtagtap_reset;
|
||||
|
|
|
@ -49,21 +49,21 @@ int libftdi_jtagtap_init(jtag_proc_t *jtag_proc)
|
|||
assert(ftdic != NULL);
|
||||
int err = ftdi_usb_purge_buffers(ftdic);
|
||||
if (err != 0) {
|
||||
printf("ftdi_usb_purge_buffer: %d: %s\n",
|
||||
DEBUG_WARN("ftdi_usb_purge_buffer: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
abort();
|
||||
}
|
||||
/* Reset MPSSE controller. */
|
||||
err = ftdi_set_bitmode(ftdic, 0, BITMODE_RESET);
|
||||
if (err != 0) {
|
||||
printf("ftdi_set_bitmode: %d: %s\n",
|
||||
DEBUG_WARN("ftdi_set_bitmode: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
return -1;
|
||||
}
|
||||
/* Enable MPSSE controller. Pin directions are set later.*/
|
||||
err = ftdi_set_bitmode(ftdic, 0, BITMODE_MPSSE);
|
||||
if (err != 0) {
|
||||
printf("ftdi_set_bitmode: %d: %s\n",
|
||||
DEBUG_WARN("ftdi_set_bitmode: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
return -1;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ static void jtagtap_tdi_tdo_seq(
|
|||
if(!ticks) return;
|
||||
if (!DI && !DO) return;
|
||||
|
||||
// printf("ticks: %d\n", ticks);
|
||||
// DEBUG_PROBE("ticks: %d\n", ticks);
|
||||
if(final_tms) ticks--;
|
||||
rticks = ticks & 7;
|
||||
ticks >>= 3;
|
||||
|
@ -153,7 +153,7 @@ static void jtagtap_tdi_tdo_seq(
|
|||
if(final_tms) rsize--;
|
||||
|
||||
while(rsize--) {
|
||||
/*if(rsize) printf("%02X ", tmp[index]);*/
|
||||
if(rsize) DEBUG_WIRE("%02X ", tmp[index]);
|
||||
*DO++ = tmp[index++];
|
||||
}
|
||||
if (rticks == 0)
|
||||
|
@ -166,7 +166,7 @@ static void jtagtap_tdi_tdo_seq(
|
|||
if(rticks) {
|
||||
*DO >>= (8-rticks);
|
||||
}
|
||||
/*printf("%02X\n", *DO);*/
|
||||
DEBUG_WIRE("%02X\n", *DO);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,26 +43,26 @@ static void swdptap_seq_out_parity(uint32_t MS, int ticks);
|
|||
int libftdi_swdptap_init(swd_proc_t *swd_proc)
|
||||
{
|
||||
if (!active_cable->bitbang_tms_in_pin) {
|
||||
printf("SWD not possible or missing item in cable description.\n");
|
||||
DEBUG_WARN("SWD not possible or missing item in cable description.\n");
|
||||
return -1;
|
||||
}
|
||||
int err = ftdi_usb_purge_buffers(ftdic);
|
||||
if (err != 0) {
|
||||
printf("ftdi_usb_purge_buffer: %d: %s\n",
|
||||
DEBUG_WARN("ftdi_usb_purge_buffer: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
return -1;
|
||||
}
|
||||
/* Reset MPSSE controller. */
|
||||
err = ftdi_set_bitmode(ftdic, 0, BITMODE_RESET);
|
||||
if (err != 0) {
|
||||
printf("ftdi_set_bitmode: %d: %s\n",
|
||||
DEBUG_WARN("ftdi_set_bitmode: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
return -1;
|
||||
}
|
||||
/* Enable MPSSE controller. Pin directions are set later.*/
|
||||
err = ftdi_set_bitmode(ftdic, 0, BITMODE_MPSSE);
|
||||
if (err != 0) {
|
||||
printf("ftdi_set_bitmode: %d: %s\n",
|
||||
DEBUG_WARN("ftdi_set_bitmode: %d: %s\n",
|
||||
err, ftdi_get_error_string(ftdic));
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2020
|
||||
* Written by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
* Copyright (C) 2020 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
|
||||
|
@ -91,7 +90,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
libusb_device **devs;
|
||||
int n_devs = libusb_get_device_list(info->libusb_ctx, &devs);
|
||||
if (n_devs < 0) {
|
||||
fprintf(stderr, "WARN:libusb_get_device_list() failed");
|
||||
DEBUG_WARN( "WARN:libusb_get_device_list() failed");
|
||||
return -1;
|
||||
}
|
||||
bool report = false;
|
||||
|
@ -107,7 +106,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
libusb_device *dev = devs[i];
|
||||
int res = libusb_get_device_descriptor(dev, &desc);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "WARN: libusb_get_device_descriptor() failed: %s",
|
||||
DEBUG_WARN( "WARN: libusb_get_device_descriptor() failed: %s",
|
||||
libusb_strerror(res));
|
||||
libusb_free_device_list(devs, 1);
|
||||
continue;
|
||||
|
@ -115,7 +114,8 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
libusb_device_handle *handle;
|
||||
res = libusb_open(dev, &handle);
|
||||
if (res != LIBUSB_SUCCESS) {
|
||||
fprintf(stderr,"WARN: Open failed\n");
|
||||
DEBUG_INFO("INFO: Open USB %04x:%04x failed\n",
|
||||
desc.idVendor, desc.idProduct);
|
||||
continue;
|
||||
}
|
||||
res = libusb_get_string_descriptor_ascii(
|
||||
|
@ -138,7 +138,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
handle, desc.iProduct, (uint8_t*)product,
|
||||
sizeof(product));
|
||||
if (res <= 0) {
|
||||
fprintf(stderr, "WARN:"
|
||||
DEBUG_WARN( "WARN:"
|
||||
"libusb_get_string_descriptor_ascii "
|
||||
"for ident_string failed: %s\n",
|
||||
libusb_strerror(res));
|
||||
|
@ -170,7 +170,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
type = BMP_TYPE_STLINKV2;
|
||||
} else {
|
||||
if (desc.idProduct == PRODUCT_ID_STLINKV1)
|
||||
fprintf(stderr, "INFO: STLINKV1 not supported\n");
|
||||
DEBUG_WARN( "INFO: STLINKV1 not supported\n");
|
||||
continue;
|
||||
}
|
||||
} else if ((strstr(manufacturer, "CMSIS")) || (strstr(product, "CMSIS"))) {
|
||||
|
@ -182,7 +182,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
}
|
||||
found_debuggers ++;
|
||||
if (report) {
|
||||
printf("%2d: %s, %s, %s\n", found_debuggers,
|
||||
DEBUG_WARN("%2d: %s, %s, %s\n", found_debuggers,
|
||||
serial,
|
||||
manufacturer,product);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
|||
}
|
||||
if (found_debuggers > 1) {
|
||||
if (!report) {
|
||||
printf("%d debuggers found! Select with -P <num>, -s <string> "
|
||||
DEBUG_WARN("%d debuggers found! Select with -P <num>, -s <string> "
|
||||
"and/or -S <string>\n",
|
||||
found_debuggers);
|
||||
report = true;
|
||||
|
@ -221,7 +221,7 @@ void platform_init(int argc, char **argv)
|
|||
signal(SIGINT, sigterm_handler);
|
||||
int res = libusb_init(&info.libusb_ctx);
|
||||
if (res) {
|
||||
fprintf(stderr, "Fatal: Failed to get USB context: %s\n",
|
||||
DEBUG_WARN( "Fatal: Failed to get USB context: %s\n",
|
||||
libusb_strerror(res));
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ void platform_init(int argc, char **argv)
|
|||
} else if (find_debuggers(&cl_opts, &info)) {
|
||||
exit(-1);
|
||||
}
|
||||
printf("Using %04x:%04x %s %s %s\n", info.vid, info.pid, info.serial,
|
||||
DEBUG_WARN("Using %04x:%04x %s %s %s\n", info.vid, info.pid, info.serial,
|
||||
info.manufacturer,
|
||||
info.product);
|
||||
switch (info.bmp_type) {
|
||||
|
@ -473,44 +473,44 @@ void platform_buffer_flush(void)
|
|||
static void ap_decode_access(uint16_t addr, uint8_t RnW)
|
||||
{
|
||||
if (RnW)
|
||||
printf("Read ");
|
||||
fprintf(stderr, "Read ");
|
||||
else
|
||||
printf("Write ");
|
||||
fprintf(stderr, "Write ");
|
||||
switch(addr) {
|
||||
case 0x00:
|
||||
if (RnW)
|
||||
printf("DP_DPIDR :");
|
||||
fprintf(stderr, "DP_DPIDR :");
|
||||
else
|
||||
printf("DP_ABORT :");
|
||||
fprintf(stderr, "DP_ABORT :");
|
||||
break;
|
||||
case 0x004: printf("CTRL/STAT:");
|
||||
case 0x004: fprintf(stderr, "CTRL/STAT:");
|
||||
break;
|
||||
case 0x008:
|
||||
if (RnW)
|
||||
printf("RESEND :");
|
||||
fprintf(stderr, "RESEND :");
|
||||
else
|
||||
printf("DP_SELECT:");
|
||||
fprintf(stderr, "DP_SELECT:");
|
||||
break;
|
||||
case 0x00c: printf("DP_RDBUFF:");
|
||||
case 0x00c: fprintf(stderr, "DP_RDBUFF:");
|
||||
break;
|
||||
case 0x100: printf("AP_CSW :");
|
||||
case 0x100: fprintf(stderr, "AP_CSW :");
|
||||
break;
|
||||
case 0x104: printf("AP_TAR :");
|
||||
case 0x104: fprintf(stderr, "AP_TAR :");
|
||||
break;
|
||||
case 0x10c: printf("AP_DRW :");
|
||||
case 0x10c: fprintf(stderr, "AP_DRW :");
|
||||
break;
|
||||
case 0x1f8: printf("AP_BASE :");
|
||||
case 0x1f8: fprintf(stderr, "AP_BASE :");
|
||||
break;
|
||||
case 0x1fc: printf("AP_IDR :");
|
||||
case 0x1fc: fprintf(stderr, "AP_IDR :");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void adiv5_dp_write(ADIv5_DP_t *dp, uint16_t addr, uint32_t value)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
ap_decode_access(addr, ADIV5_LOW_WRITE);
|
||||
printf(" 0x%08" PRIx32 "\n", value);
|
||||
fprintf(stderr, " 0x%08" PRIx32 "\n", value);
|
||||
}
|
||||
dp->low_access(dp, ADIV5_LOW_WRITE, addr, value);
|
||||
}
|
||||
|
@ -518,9 +518,9 @@ void adiv5_dp_write(ADIv5_DP_t *dp, uint16_t addr, uint32_t value)
|
|||
uint32_t adiv5_dp_read(ADIv5_DP_t *dp, uint16_t addr)
|
||||
{
|
||||
uint32_t ret = dp->dp_read(dp, addr);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
ap_decode_access(addr, ADIV5_LOW_READ);
|
||||
printf(" 0x%08" PRIx32 "\n", ret);
|
||||
fprintf(stderr, " 0x%08" PRIx32 "\n", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -528,9 +528,7 @@ uint32_t adiv5_dp_read(ADIv5_DP_t *dp, uint16_t addr)
|
|||
uint32_t adiv5_dp_error(ADIv5_DP_t *dp)
|
||||
{
|
||||
uint32_t ret = dp->error(dp);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
printf("DP Error 0x%08" PRIx32 "\n", ret);
|
||||
}
|
||||
DEBUG_TARGET( "DP Error 0x%08" PRIx32 "\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -538,9 +536,9 @@ uint32_t adiv5_dp_low_access(struct ADIv5_DP_s *dp, uint8_t RnW,
|
|||
uint16_t addr, uint32_t value)
|
||||
{
|
||||
uint32_t ret = dp->low_access(dp, RnW, addr, value);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
ap_decode_access(addr, RnW);
|
||||
printf(" 0x%08" PRIx32 "\n", (RnW)? ret : value);
|
||||
fprintf(stderr, " 0x%08" PRIx32 "\n", (RnW)? ret : value);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -548,18 +546,18 @@ uint32_t adiv5_dp_low_access(struct ADIv5_DP_s *dp, uint8_t RnW,
|
|||
uint32_t adiv5_ap_read(ADIv5_AP_t *ap, uint16_t addr)
|
||||
{
|
||||
uint32_t ret = ap->dp->ap_read(ap, addr);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
ap_decode_access(addr, ADIV5_LOW_READ);
|
||||
printf(" 0x%08" PRIx32 "\n", ret);
|
||||
fprintf(stderr, " 0x%08" PRIx32 "\n", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void adiv5_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
ap_decode_access(addr, ADIV5_LOW_WRITE);
|
||||
printf(" 0x%08" PRIx32 "\n", value);
|
||||
fprintf(stderr, " 0x%08" PRIx32 "\n", value);
|
||||
}
|
||||
return ap->dp->ap_write(ap, addr, value);
|
||||
}
|
||||
|
@ -567,42 +565,42 @@ void adiv5_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
|
|||
void adiv5_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
|
||||
{
|
||||
ap->dp->mem_read(ap, dest, src, len);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
printf("ap_memread @ %" PRIx32 " len %" PRIx32 ":", src, (uint32_t)len);
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
fprintf(stderr, "ap_memread @ %" PRIx32 " len %" PRIx32 ":",
|
||||
src, (uint32_t)len);
|
||||
uint8_t *p = (uint8_t *) dest;
|
||||
unsigned int i = len;
|
||||
if (i > 16)
|
||||
i = 16;
|
||||
while (i--)
|
||||
printf(" %02x", *p++);
|
||||
fprintf(stderr, " %02x", *p++);
|
||||
if (len > 16)
|
||||
printf(" ...");
|
||||
printf("\n");
|
||||
fprintf(stderr, " ...");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
void adiv5_mem_write_sized( ADIv5_AP_t *ap, uint32_t dest, const void *src,
|
||||
size_t len, enum align align)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM) {
|
||||
printf("ap_mem_write_sized @ %" PRIx32 " len %" PRIx32 ", align %d:",
|
||||
dest, (uint32_t)len, 1 << align);
|
||||
if (cl_debuglevel & BMP_DEBUG_TARGET) {
|
||||
fprintf(stderr, "ap_mem_write_sized @ %" PRIx32 " len %" PRIx32
|
||||
", align %d:", dest, (uint32_t)len, 1 << align);
|
||||
uint8_t *p = (uint8_t *) src;
|
||||
unsigned int i = len;
|
||||
if (i > 16)
|
||||
i = 16;
|
||||
while (i--)
|
||||
printf(" %02x", *p++);
|
||||
fprintf(stderr, " %02x", *p++);
|
||||
if (len > 16)
|
||||
printf(" ...");
|
||||
printf("\n");
|
||||
fprintf(stderr, " ...");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
return ap->dp->mem_write_sized(ap, dest, src, len, align);
|
||||
}
|
||||
|
||||
void adiv5_dp_abort(struct ADIv5_DP_s *dp, uint32_t abort)
|
||||
{
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("Abort: %08" PRIx32 "\n", abort);
|
||||
DEBUG_TARGET("Abort: %08" PRIx32 "\n", abort);
|
||||
return dp->abort(dp, abort);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* Copyright (C) 2008 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* Modified by Dave Marples <dave@marples.net>
|
||||
* Modified (c) 2020 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
|
||||
|
@ -55,7 +56,7 @@ int remote_jtagtap_init(jtag_proc_t *jtag_proc)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "jtagtap_init failed, error %s\n",
|
||||
DEBUG_WARN("jtagtap_init failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -82,7 +83,7 @@ static void jtagtap_reset(void)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "jtagtap_reset failed, error %s\n",
|
||||
DEBUG_WARN("jtagtap_reset failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -99,7 +100,7 @@ static void jtagtap_tms_seq(uint32_t MS, int ticks)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "jtagtap_tms_seq failed, error %s\n",
|
||||
DEBUG_WARN("jtagtap_tms_seq failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ static void jtagtap_tdi_tdo_seq(
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "jtagtap_tms_seq failed, error %s\n",
|
||||
DEBUG_WARN("jtagtap_tms_seq failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -156,7 +157,7 @@ static uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDI)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "jtagtap_next failed, error %s\n",
|
||||
DEBUG_WARN("jtagtap_next failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2018 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* Modified by Dave Marples <dave@marples.net>
|
||||
* Modification (C) 2020 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
|
||||
|
@ -37,6 +37,7 @@ static void swdptap_seq_out_parity(uint32_t MS, int ticks);
|
|||
|
||||
int remote_swdptap_init(swd_proc_t *swd_proc)
|
||||
{
|
||||
DEBUG_WIRE("remote_swdptap_init\n");
|
||||
uint8_t construct[REMOTE_MAX_MSG_SIZE];
|
||||
int s;
|
||||
s = sprintf((char *)construct,"%s", REMOTE_SWDP_INIT_STR);
|
||||
|
@ -44,7 +45,7 @@ int remote_swdptap_init(swd_proc_t *swd_proc)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((!s) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "swdptap_init failed, error %s\n",
|
||||
DEBUG_WARN("swdptap_init failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "unknown");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -67,12 +68,14 @@ static bool swdptap_seq_in_parity(uint32_t *res, int ticks)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((s<2) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "swdptap_seq_in_parity failed, error %s\n",
|
||||
DEBUG_WARN("swdptap_seq_in_parity failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "short response");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
*res=remotehston(-1, (char *)&construct[1]);
|
||||
DEBUG_PROBE("swdptap_seq_in_parity %2d ticks: %08" PRIx32 " %s\n",
|
||||
ticks, *res, (construct[0] != REMOTE_RESP_OK) ? "ERR" : "OK");
|
||||
return (construct[0] != REMOTE_RESP_OK);
|
||||
}
|
||||
|
||||
|
@ -86,12 +89,14 @@ static uint32_t swdptap_seq_in(int ticks)
|
|||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((s<2) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "swdptap_seq_in failed, error %s\n",
|
||||
DEBUG_WARN("swdptap_seq_in failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "short response");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
return remotehston(-1,(char *)&construct[1]);
|
||||
uint32_t res = remotehston(-1,(char *)&construct[1]);
|
||||
DEBUG_PROBE("swdptap_seq_in %2d ticks: %08" PRIx32 "\n",
|
||||
ticks, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void swdptap_seq_out(uint32_t MS, int ticks)
|
||||
|
@ -99,12 +104,14 @@ static void swdptap_seq_out(uint32_t MS, int ticks)
|
|||
uint8_t construct[REMOTE_MAX_MSG_SIZE];
|
||||
int s;
|
||||
|
||||
DEBUG_PROBE("swdptap_seq_out %2d ticks: %08" PRIx32 "\n",
|
||||
ticks, MS);
|
||||
s = sprintf((char *)construct,REMOTE_SWDP_OUT_STR, ticks, MS);
|
||||
platform_buffer_write(construct, s);
|
||||
|
||||
s=platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((s < 1) || (construct[0] == REMOTE_RESP_ERR)) {
|
||||
fprintf(stderr, "swdptap_seq_out failed, error %s\n",
|
||||
DEBUG_WARN("swdptap_seq_out failed, error %s\n",
|
||||
s ? (char *)&(construct[1]) : "short response");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -115,12 +122,14 @@ static void swdptap_seq_out_parity(uint32_t MS, int ticks)
|
|||
uint8_t construct[REMOTE_MAX_MSG_SIZE];
|
||||
int s;
|
||||
|
||||
DEBUG_PROBE("swdptap_seq_out_parity %2d ticks: %08" PRIx32 "\n",
|
||||
ticks, MS);
|
||||
s = sprintf((char *)construct, REMOTE_SWDP_OUT_PAR_STR, ticks, MS);
|
||||
platform_buffer_write(construct, s);
|
||||
|
||||
s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE);
|
||||
if ((s < 1) || (construct[1] == REMOTE_RESP_ERR)){
|
||||
fprintf(stderr, "swdptap_seq_out_parity failed, error %s\n",
|
||||
DEBUG_WARN("swdptap_seq_out_parity failed, error %s\n",
|
||||
s ? (char *)&(construct[2]) : "short response");
|
||||
exit(-1);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2019 Uwe Bonnes
|
||||
* Copyright (C) 2019-2020 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
|
||||
|
@ -232,43 +232,46 @@ static int stlink_usb_error_check(uint8_t *data, bool verbose)
|
|||
return STLINK_ERROR_OK;
|
||||
case STLINK_DEBUG_ERR_FAULT:
|
||||
if (verbose)
|
||||
printf("SWD fault response (0x%x)\n", STLINK_DEBUG_ERR_FAULT);
|
||||
DEBUG_WARN("SWD fault response (0x%x)\n",
|
||||
STLINK_DEBUG_ERR_FAULT);
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_JTAG_UNKNOWN_JTAG_CHAIN:
|
||||
if (verbose)
|
||||
printf("Unknown JTAG chain\n");
|
||||
DEBUG_WARN("Unknown JTAG chain\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_NO_DEVICE_CONNECTED:
|
||||
if (verbose)
|
||||
printf("No device connected\n");
|
||||
DEBUG_WARN("No device connected\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_JTAG_COMMAND_ERROR:
|
||||
if (verbose)
|
||||
printf("Command error\n");
|
||||
DEBUG_WARN("Command error\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_JTAG_GET_IDCODE_ERROR:
|
||||
if (verbose)
|
||||
printf("Failure reading IDCODE\n");
|
||||
DEBUG_WARN("Failure reading IDCODE\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_JTAG_DBG_POWER_ERROR:
|
||||
if (verbose)
|
||||
printf("Failure powering DBG\n");
|
||||
DEBUG_WARN("Failure powering DBG\n");
|
||||
return STLINK_ERROR_WAIT;
|
||||
case STLINK_SWD_AP_WAIT:
|
||||
if (verbose)
|
||||
printf("wait status SWD_AP_WAIT (0x%x)\n", STLINK_SWD_AP_WAIT);
|
||||
DEBUG_WARN("wait status SWD_AP_WAIT (0x%x)\n",
|
||||
STLINK_SWD_AP_WAIT);
|
||||
return STLINK_ERROR_WAIT;
|
||||
case STLINK_SWD_DP_WAIT:
|
||||
if (verbose)
|
||||
printf("wait status SWD_DP_WAIT (0x%x)\n", STLINK_SWD_DP_WAIT);
|
||||
DEBUG_WARN("wait status SWD_DP_WAIT (0x%x)\n",
|
||||
STLINK_SWD_DP_WAIT);
|
||||
return STLINK_ERROR_WAIT;
|
||||
case STLINK_JTAG_WRITE_ERROR:
|
||||
if (verbose)
|
||||
printf("Write error\n");
|
||||
DEBUG_WARN("Write error\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_JTAG_WRITE_VERIF_ERROR:
|
||||
if (verbose)
|
||||
printf("Write verify error, ignoring\n");
|
||||
DEBUG_WARN("Write verify error, ignoring\n");
|
||||
return STLINK_ERROR_OK;
|
||||
case STLINK_SWD_AP_FAULT:
|
||||
/* git://git.ac6.fr/openocd commit 657e3e885b9ee10
|
||||
|
@ -278,40 +281,40 @@ static int stlink_usb_error_check(uint8_t *data, bool verbose)
|
|||
*/
|
||||
Stlink.ap_error = true;
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_AP_FAULT\n");
|
||||
DEBUG_WARN("STLINK_SWD_AP_FAULT\n");
|
||||
return STLINK_ERROR_DP_FAULT;
|
||||
case STLINK_SWD_AP_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_AP_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_AP_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_AP_PARITY_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_AP_PARITY_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_AP_PARITY_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_DP_FAULT:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_DP_FAULT\n");
|
||||
DEBUG_WARN("STLINK_SWD_DP_FAULT\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_DP_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_DP_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_DP_ERROR\n");
|
||||
raise_exception(EXCEPTION_ERROR, "STLINK_SWD_DP_ERROR");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_DP_PARITY_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_DP_PARITY_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_DP_PARITY_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_AP_WDATA_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_AP_WDATA_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_AP_WDATA_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_AP_STICKY_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_AP_STICKY_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_AP_STICKY_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_SWD_AP_STICKYORUN_ERROR:
|
||||
if (verbose)
|
||||
printf("STLINK_SWD_AP_STICKYORUN_ERROR\n");
|
||||
DEBUG_WARN("STLINK_SWD_AP_STICKYORUN_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_BAD_AP_ERROR:
|
||||
/* ADIV5 probe 256 APs, most of them are non exisitant.*/
|
||||
|
@ -319,15 +322,15 @@ static int stlink_usb_error_check(uint8_t *data, bool verbose)
|
|||
case STLINK_TOO_MANY_AP_ERROR:
|
||||
/* TI TM4C duplicates AP. Error happens at AP9.*/
|
||||
if (verbose)
|
||||
printf("STLINK_TOO_MANY_AP_ERROR\n");
|
||||
DEBUG_WARN("STLINK_TOO_MANY_AP_ERROR\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
case STLINK_JTAG_UNKNOWN_CMD :
|
||||
if (verbose)
|
||||
printf("STLINK_JTAG_UNKNOWN_CMD\n");
|
||||
DEBUG_WARN("STLINK_JTAG_UNKNOWN_CMD\n");
|
||||
return STLINK_ERROR_FAIL;
|
||||
default:
|
||||
if (verbose)
|
||||
printf("unknown/unexpected STLINK status code 0x%x\n", data[0]);
|
||||
DEBUG_WARN("unknown/unexpected STLINK status code 0x%x\n", data[0]);
|
||||
return STLINK_ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +348,7 @@ static int stlink_send_recv_retry(uint8_t *txbuf, size_t txsize,
|
|||
return res;
|
||||
uint32_t now = platform_time_ms();
|
||||
if (((now - start) > 1000) || (res != STLINK_ERROR_WAIT)) {
|
||||
printf("write_retry failed. ");
|
||||
DEBUG_WARN("write_retry failed. ");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +367,7 @@ static int read_retry(uint8_t *txbuf, size_t txsize,
|
|||
return res;
|
||||
uint32_t now = platform_time_ms();
|
||||
if (((now -start) > 1000) || (res != STLINK_ERROR_WAIT)) {
|
||||
printf("read_retry failed. ");
|
||||
DEBUG_WARN("read_retry failed. ");
|
||||
stlink_usb_get_rw_status(true);
|
||||
return res;
|
||||
}
|
||||
|
@ -400,7 +403,7 @@ static void stlink_version(bmp_info_t *info)
|
|||
uint8_t data[12];
|
||||
int size = send_recv(info->usb_link, cmd, 16, data, 12);
|
||||
if (size == -1) {
|
||||
printf("[!] stlink_send_recv STLINK_APIV3_GET_VERSION_EX\n");
|
||||
DEBUG_WARN("[!] stlink_send_recv STLINK_APIV3_GET_VERSION_EX\n");
|
||||
}
|
||||
Stlink.ver_stlink = data[0];
|
||||
Stlink.ver_swim = data[1];
|
||||
|
@ -415,7 +418,7 @@ static void stlink_version(bmp_info_t *info)
|
|||
uint8_t data[6];
|
||||
int size = send_recv(info->usb_link, cmd, 16, data, 6);
|
||||
if (size == -1) {
|
||||
printf("[!] stlink_send_recv STLINK_GET_VERSION_EX\n");
|
||||
DEBUG_WARN("[!] stlink_send_recv STLINK_GET_VERSION_EX\n");
|
||||
}
|
||||
Stlink.vid = data[3] << 8 | data[2];
|
||||
Stlink.pid = data[5] << 8 | data[4];
|
||||
|
@ -430,15 +433,15 @@ static void stlink_version(bmp_info_t *info)
|
|||
Stlink.ver_swim = (version >> 0) & 0x3f;
|
||||
}
|
||||
}
|
||||
printf("V%dJ%d",Stlink.ver_stlink, Stlink.ver_jtag);
|
||||
DEBUG_INFO("V%dJ%d",Stlink.ver_stlink, Stlink.ver_jtag);
|
||||
if (Stlink.ver_hw == 30) {
|
||||
printf("M%dB%dS%d", Stlink.ver_mass, Stlink.ver_bridge, Stlink.ver_swim);
|
||||
DEBUG_INFO("M%dB%dS%d", Stlink.ver_mass, Stlink.ver_bridge, Stlink.ver_swim);
|
||||
} else if (Stlink.ver_hw == 20) {
|
||||
printf("S%d", Stlink.ver_swim);
|
||||
DEBUG_INFO("S%d", Stlink.ver_swim);
|
||||
} else if (Stlink.ver_hw == 21) {
|
||||
printf("M%d", Stlink.ver_mass);
|
||||
DEBUG_INFO("M%d", Stlink.ver_mass);
|
||||
}
|
||||
printf("\n");
|
||||
DEBUG_INFO("\n");
|
||||
}
|
||||
|
||||
static bool stlink_leave_state(bmp_info_t *info)
|
||||
|
@ -448,23 +451,23 @@ static bool stlink_leave_state(bmp_info_t *info)
|
|||
send_recv(info->usb_link,cmd, 16, data, 2);
|
||||
if (data[0] == STLINK_DEV_DFU_MODE) {
|
||||
uint8_t dfu_cmd[16] = {STLINK_DFU_COMMAND, STLINK_DFU_EXIT};
|
||||
printf("Leaving DFU Mode\n");
|
||||
DEBUG_INFO("Leaving DFU Mode\n");
|
||||
send_recv(info->usb_link, dfu_cmd, 16, NULL, 0);
|
||||
return true;
|
||||
} else if (data[0] == STLINK_DEV_SWIM_MODE) {
|
||||
uint8_t swim_cmd[16] = {STLINK_SWIM_COMMAND, STLINK_SWIM_EXIT};
|
||||
printf("Leaving SWIM Mode\n");
|
||||
DEBUG_INFO("Leaving SWIM Mode\n");
|
||||
send_recv(info->usb_link, swim_cmd, 16, NULL, 0);
|
||||
} else if (data[0] == STLINK_DEV_DEBUG_MODE) {
|
||||
uint8_t dbg_cmd[16] = {STLINK_DEBUG_COMMAND, STLINK_DEBUG_EXIT};
|
||||
printf("Leaving DEBUG Mode\n");
|
||||
DEBUG_INFO("Leaving DEBUG Mode\n");
|
||||
send_recv(info->usb_link, dbg_cmd, 16, NULL, 0);
|
||||
} else if (data[0] == STLINK_DEV_BOOTLOADER_MODE) {
|
||||
printf("Leaving BOOTLOADER Mode\n");
|
||||
DEBUG_INFO("Leaving BOOTLOADER Mode\n");
|
||||
} else if (data[0] == STLINK_DEV_MASS_MODE) {
|
||||
printf("Leaving MASS Mode\n");
|
||||
DEBUG_INFO("Leaving MASS Mode\n");
|
||||
} else {
|
||||
printf("Unknown Mode %02x\n", data[0]);
|
||||
DEBUG_INFO("Unknown Mode %02x\n", data[0]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -503,7 +506,7 @@ int stlink_init(bmp_info_t *info)
|
|||
ssize_t cnt;
|
||||
cnt = libusb_get_device_list(info->libusb_ctx, &devs);
|
||||
if (cnt < 0) {
|
||||
fprintf(stderr, "FATAL: Stlink libusb_get_device_list failed\n");
|
||||
DEBUG_WARN("FATAL: Stlink libusb_get_device_list failed\n");
|
||||
return -1;
|
||||
}
|
||||
int i = 0;
|
||||
|
@ -512,7 +515,7 @@ int stlink_init(bmp_info_t *info)
|
|||
struct libusb_device_descriptor desc;
|
||||
int r = libusb_get_device_descriptor(dev, &desc);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "libusb_get_device_descriptor failed %s",
|
||||
DEBUG_WARN("libusb_get_device_descriptor failed %s",
|
||||
libusb_strerror(r));
|
||||
return -1;
|
||||
}
|
||||
|
@ -555,21 +558,21 @@ int stlink_init(bmp_info_t *info)
|
|||
int config;
|
||||
int r = libusb_get_configuration(sl->ul_libusb_device_handle, &config);
|
||||
if (r) {
|
||||
fprintf(stderr, "FATAL: Stlink libusb_get_configuration failed %d: %s",
|
||||
DEBUG_WARN("FATAL: Stlink libusb_get_configuration failed %d: %s",
|
||||
r, libusb_strerror(r));
|
||||
return -1;
|
||||
}
|
||||
if (config != 1) {
|
||||
r = libusb_set_configuration(sl->ul_libusb_device_handle, 0);
|
||||
if (r) {
|
||||
fprintf(stderr, "FATAL: Stlinklibusb_set_configuration "
|
||||
DEBUG_WARN("FATAL: Stlinklibusb_set_configuration "
|
||||
"failed %d: %s", r, libusb_strerror(r));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
r = libusb_claim_interface(sl->ul_libusb_device_handle, 0);
|
||||
if (r) {
|
||||
fprintf(stderr, "FATAL: Stlink libusb_claim_interface failed %s\n",
|
||||
DEBUG_WARN("FATAL: Stlink libusb_claim_interface failed %s\n",
|
||||
libusb_strerror(r));
|
||||
return -1;
|
||||
}
|
||||
|
@ -580,24 +583,24 @@ int stlink_init(bmp_info_t *info)
|
|||
(Stlink.ver_stlink == 3 && Stlink.ver_jtag < 3)) {
|
||||
/* Maybe the adapter is in some strange state. Try to reset */
|
||||
int result = libusb_reset_device(sl->ul_libusb_device_handle);
|
||||
fprintf(stderr, "INFO: Trying Stlink reset\n");
|
||||
DEBUG_WARN("INFO: Trying Stlink reset\n");
|
||||
if (result == LIBUSB_ERROR_BUSY) { /* Try again */
|
||||
platform_delay(50);
|
||||
result = libusb_reset_device(sl->ul_libusb_device_handle);
|
||||
}
|
||||
if (result != LIBUSB_SUCCESS) {
|
||||
fprintf(stderr, "FATAL: Stlink libusb_reset_device failed\n");
|
||||
DEBUG_WARN("FATAL: Stlink libusb_reset_device failed\n");
|
||||
return -1;
|
||||
}
|
||||
stlink_version(info);
|
||||
}
|
||||
if ((Stlink.ver_stlink < 3 && Stlink.ver_jtag < 32) ||
|
||||
(Stlink.ver_stlink == 3 && Stlink.ver_jtag < 3)) {
|
||||
printf("Please update Firmware\n");
|
||||
DEBUG_WARN("Please update Firmware\n");
|
||||
return -1;
|
||||
}
|
||||
if (stlink_leave_state(info)) {
|
||||
printf("Stlink board was in DFU mode. Restart\n");
|
||||
DEBUG_WARN("Stlink board was in DFU mode. Restart\n");
|
||||
return -1;
|
||||
}
|
||||
stlink_resetsys(info);
|
||||
|
@ -646,7 +649,7 @@ static bool stlink3_set_freq_divisor(bmp_info_t *info, uint16_t divisor)
|
|||
divisor = size;
|
||||
uint8_t *p = data + 12 + divisor * sizeof(uint32_t);
|
||||
uint32_t freq = p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
|
||||
printf("Selected %" PRId32 " khz\n", freq);
|
||||
DEBUG_INFO("Selected %" PRId32 " khz\n", freq);
|
||||
cmd[1] = STLINK_APIV3_SET_COM_FREQ;
|
||||
cmd[2] = Stlink.transport_mode;
|
||||
cmd[3] = 0;
|
||||
|
@ -676,7 +679,7 @@ static int stlink_enter_debug_jtag(bmp_info_t *info)
|
|||
STLINK_DEBUG_APIV2_ENTER,
|
||||
STLINK_DEBUG_ENTER_JTAG_NO_RESET};
|
||||
uint8_t data[2];
|
||||
printf("Enter JTAG\n");
|
||||
DEBUG_INFO("Enter JTAG\n");
|
||||
send_recv(info->usb_link, cmd, 16, data, 2);
|
||||
return stlink_usb_error_check(data, true);
|
||||
}
|
||||
|
@ -688,7 +691,7 @@ static uint32_t stlink_read_coreid(void)
|
|||
uint8_t data[4];
|
||||
send_recv(info.usb_link, cmd, 16, data, 4);
|
||||
uint32_t id = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
|
||||
printf("Read Core ID: 0x%08" PRIx32 "\n", id);
|
||||
DEBUG_INFO("Read Core ID: 0x%08" PRIx32 "\n", id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -741,7 +744,7 @@ uint32_t stlink_dp_error(ADIv5_DP_t *dp)
|
|||
adiv5_dp_write(dp, ADIV5_DP_ABORT, clr);
|
||||
dp->fault = 0;
|
||||
if (err)
|
||||
printf("stlink_dp_error %d\n", err);
|
||||
DEBUG_WARN("stlink_dp_error %d\n", err);
|
||||
err |= Stlink.ap_error;
|
||||
Stlink.ap_error = false;
|
||||
return err;
|
||||
|
@ -768,7 +771,7 @@ static int stlink_read_dp_register(uint16_t port, uint16_t addr, uint32_t *reg)
|
|||
uint32_t ret = data[4] | data[5] << 8 | data[6] << 16 | data[7] << 24;
|
||||
*reg = ret;
|
||||
} else {
|
||||
printf("%s error %d\n", __func__, res);
|
||||
DEBUG_WARN("%s error %d\n", __func__, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -777,8 +780,7 @@ static int stlink_write_dp_register(uint16_t port, uint16_t addr, uint32_t val)
|
|||
{
|
||||
if (port == STLINK_DEBUG_PORT_ACCESS && addr == 8) {
|
||||
Stlink.dap_select = val;
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("Caching SELECT 0x%02" PRIx32 "\n", val);
|
||||
DEBUG_PROBE("Caching SELECT 0x%02" PRIx32 "\n", val);
|
||||
return STLINK_ERROR_OK;
|
||||
} else {
|
||||
uint8_t cmd[16] = {
|
||||
|
@ -828,12 +830,11 @@ static bool stlink_ap_setup(int ap)
|
|||
};
|
||||
uint8_t data[2];
|
||||
send_recv(info.usb_link, cmd, 16, data, 2);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("Open AP %d\n", ap);
|
||||
DEBUG_PROBE("Open AP %d\n", ap);
|
||||
int res = stlink_usb_error_check(data, true);
|
||||
if (res) {
|
||||
if (Stlink.ver_hw == 30) {
|
||||
printf("STLINKV3 only connects to STM8/32!\n");
|
||||
DEBUG_WARN("STLINKV3 only connects to STM8/32!\n");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -849,8 +850,7 @@ static void stlink_ap_cleanup(int ap)
|
|||
};
|
||||
uint8_t data[2];
|
||||
send_recv(info.usb_link, cmd, 16, data, 2);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("Close AP %d\n", ap);
|
||||
DEBUG_PROBE("Close AP %d\n", ap);
|
||||
stlink_usb_error_check(data, true);
|
||||
}
|
||||
static int stlink_usb_get_rw_status(bool verbose)
|
||||
|
@ -873,7 +873,7 @@ static void stlink_readmem(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
|
|||
if (src & 1 || len & 1) {
|
||||
type = STLINK_DEBUG_READMEM_8BIT;
|
||||
if (len > Stlink.block_size) {
|
||||
printf(" Too large!\n");
|
||||
DEBUG_WARN(" Too large!\n");
|
||||
return;
|
||||
}
|
||||
if (len == 1)
|
||||
|
@ -897,10 +897,11 @@ static void stlink_readmem(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
|
|||
* Approach taken:
|
||||
* Fill the memory with some fixed pattern so hopefully
|
||||
* the caller notices the error*/
|
||||
printf("stlink_readmem failed\n");
|
||||
DEBUG_WARN("stlink_readmem failed\n");
|
||||
memset(dest, 0xff, len);
|
||||
}
|
||||
DEBUG_STLINK("\n");
|
||||
DEBUG_PROBE("stlink_readmem from %" PRIx32 " to %" PRIx32 ", len %" PRIx32
|
||||
"\n", src, dest, (uint32_t) len);
|
||||
}
|
||||
|
||||
static void stlink_writemem8(usb_link_t *link, ADIv5_AP_t *ap, uint32_t addr,
|
||||
|
@ -961,8 +962,7 @@ static void stlink_regs_read(ADIv5_AP_t *ap, void *data)
|
|||
uint8_t cmd[16] = {STLINK_DEBUG_COMMAND, STLINK_DEBUG_APIV2_READALLREGS,
|
||||
ap->apsel};
|
||||
uint8_t res[88];
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("AP %d: Read all core registers\n", ap->apsel);
|
||||
DEBUG_PROBE("AP %d: Read all core registers\n", ap->apsel);
|
||||
send_recv(info.usb_link, cmd, 16, res, 88);
|
||||
stlink_usb_error_check(res, true);
|
||||
memcpy(data, res + 4, 84);
|
||||
|
@ -976,9 +976,8 @@ static uint32_t stlink_reg_read(ADIv5_AP_t *ap, int num)
|
|||
send_recv(info.usb_link, cmd, 16, res, 8);
|
||||
stlink_usb_error_check(res, true);
|
||||
uint32_t ret = res[0] | res[1] << 8 | res[2] << 16 | res[3] << 24;
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("AP %d: Read reg %02" PRId32 " val 0x%08" PRIx32 "\n",
|
||||
ap->apsel, num, ret);
|
||||
DEBUG_PROBE("AP %d: Read reg %02" PRId32 " val 0x%08" PRIx32 "\n",
|
||||
ap->apsel, num, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -990,9 +989,8 @@ static void stlink_reg_write(ADIv5_AP_t *ap, int num, uint32_t val)
|
|||
(val >> 24) & 0xff, ap->apsel};
|
||||
uint8_t res[2];
|
||||
send_recv(info.usb_link, cmd, 16, res, 2);
|
||||
if (cl_debuglevel & BMP_DEBUG_PLATFORM)
|
||||
printf("AP %d: Write reg %02" PRId32 " val 0x%08" PRIx32 "\n",
|
||||
ap->apsel, num, val);
|
||||
DEBUG_PROBE("AP %d: Write reg %02" PRId32 " val 0x%08" PRIx32 "\n",
|
||||
ap->apsel, num, val);
|
||||
stlink_usb_error_check(res, true);
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1093,7 @@ int stlink_enter_debug_swd(bmp_info_t *info, ADIv5_DP_t *dp)
|
|||
STLINK_DEBUG_APIV2_ENTER,
|
||||
STLINK_DEBUG_ENTER_SWD_NO_RESET};
|
||||
uint8_t data[2];
|
||||
printf("Enter SWD\n");
|
||||
DEBUG_INFO("Enter SWD\n");
|
||||
send_recv(info->usb_link, cmd, 16, data, 2);
|
||||
if (stlink_usb_error_check(data, true))
|
||||
return -1;
|
||||
|
|
|
@ -36,7 +36,4 @@ void stlink_adiv5_dp_defaults(ADIv5_DP_t *dp);
|
|||
int stlink_jtag_dp_init(ADIv5_DP_t *dp);
|
||||
int jtag_scan_stlinkv2(bmp_info_t *info, const uint8_t *irlens);
|
||||
void stlink_exit_function(bmp_info_t *info);
|
||||
extern int debug_level;
|
||||
# define DEBUG_STLINK if (debug_level > 0) printf
|
||||
# define DEBUG_USB if (debug_level > 1) printf
|
||||
#endif
|
||||
|
|
|
@ -135,8 +135,6 @@
|
|||
#define TRACE_IRQ NVIC_TIM3_IRQ
|
||||
#define TRACE_ISR tim3_isr
|
||||
|
||||
#define DEBUG(...)
|
||||
|
||||
#define gpio_set_val(port, pin, val) do { \
|
||||
if(val) \
|
||||
gpio_set((port), (pin)); \
|
||||
|
|
|
@ -98,8 +98,6 @@ extern const usbd_driver lm4f_usb_driver;
|
|||
#define vasprintf vasiprintf
|
||||
#define snprintf sniprintf
|
||||
|
||||
#define DEBUG(...)
|
||||
|
||||
#define SET_RUN_STATE(state) {running_status = (state);}
|
||||
#define SET_IDLE_STATE(state) {}
|
||||
#define SET_ERROR_STATE(state) SET_IDLE_STATE(state)
|
||||
|
|
|
@ -30,10 +30,14 @@
|
|||
|
||||
#define PLATFORM_HAS_TRACESWO
|
||||
#define PLATFORM_HAS_POWER_SWITCH
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
#define PLATFORM_HAS_DEBUG
|
||||
#define USBUART_DEBUG
|
||||
# define PLATFORM_HAS_DEBUG
|
||||
# define USBUART_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
#endif
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe"
|
||||
#define BOARD_IDENT_DFU "Black Magic Probe (Upgrade)"
|
||||
#define BOARD_IDENT_UPD "Black Magic Probe (DFU Upgrade)"
|
||||
|
@ -165,15 +169,6 @@
|
|||
#define TRACE_IRQ NVIC_TIM3_IRQ
|
||||
#define TRACE_ISR tim3_isr
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
|
||||
#define DEBUG printf
|
||||
#else
|
||||
#define DEBUG(...)
|
||||
#endif
|
||||
|
||||
#define SET_RUN_STATE(state) {running_status = (state);}
|
||||
#define SET_IDLE_STATE(state) {gpio_set_val(LED_PORT, LED_IDLE_RUN, state);}
|
||||
#define SET_ERROR_STATE(state) {gpio_set_val(LED_PORT, LED_ERROR, state);}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2019
|
||||
* Written by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
* Copyright (C) 2019 - 2020 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
|
||||
|
@ -63,7 +63,7 @@ static int bmp_mmap(char *file, struct mmap_data *map)
|
|||
map->hFile = CreateFile(file, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
|
||||
NULL, OPEN_ALWAYS, 0, NULL);
|
||||
if (map->hFile == INVALID_HANDLE_VALUE) {
|
||||
DEBUG("Open file %s failed: %s\n", file, strerror(errno));
|
||||
DEBUG_WARN("Open file %s failed: %s\n", file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
map->size = GetFileSize(map->hFile, NULL);
|
||||
|
@ -76,13 +76,13 @@ static int bmp_mmap(char *file, struct mmap_data *map)
|
|||
NULL); /* name of mapping object */
|
||||
|
||||
if (map->hMapFile == NULL || map->hMapFile == INVALID_HANDLE_VALUE) {
|
||||
DEBUG("Map file %s failed: %s\n", file, strerror(errno));
|
||||
DEBUG_WARN("Map file %s failed: %s\n", file, strerror(errno));
|
||||
CloseHandle(map->hFile);
|
||||
return -1;
|
||||
}
|
||||
map->data = MapViewOfFile(map->hMapFile, FILE_MAP_READ, 0, 0, 0);
|
||||
if (!map->data) {
|
||||
printf("Could not create file mapping object (%s).\n",
|
||||
DEBUG_WARN("Could not create file mapping object (%s).\n",
|
||||
strerror(errno));
|
||||
CloseHandle(map->hMapFile);
|
||||
return -1;
|
||||
|
@ -90,7 +90,7 @@ static int bmp_mmap(char *file, struct mmap_data *map)
|
|||
#else
|
||||
map->fd = open(file, O_RDONLY | O_BINARY);
|
||||
if (map->fd < 0) {
|
||||
DEBUG("Open file %s failed: %s\n", file, strerror(errno));
|
||||
DEBUG_WARN("Open file %s failed: %s\n", file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
struct stat stat;
|
||||
|
@ -115,34 +115,37 @@ static void bmp_munmap(struct mmap_data *map)
|
|||
|
||||
static void cl_help(char **argv, BMP_CL_OPTIONS_t *opt)
|
||||
{
|
||||
printf("%s\n\n", opt->opt_idstring);
|
||||
printf("Usage: %s [options]\n", argv[0]);
|
||||
printf("\t-h\t\t: This help.\n");
|
||||
printf("\t-v[1|2]\t\t: Increasing verbosity\n");
|
||||
printf("\t-d \"path\"\t: Use serial device at \"path\"\n");
|
||||
printf("\t-P <num>\t: Use debugger found at position <num>\n");
|
||||
printf("\t-n <num>\t: Use target device found at position <num>\n");
|
||||
printf("\t-s \"string\"\t: Use dongle with (partial) "
|
||||
DEBUG_WARN("%s for: \n", opt->opt_idstring);
|
||||
DEBUG_WARN("\tBMP Firmware, ST-Link V2/3, CMSIS_DAP, JLINK and "
|
||||
"LIBFTDI/MPSSE\n\n");
|
||||
DEBUG_WARN("Usage: %s [options]\n", argv[0]);
|
||||
DEBUG_WARN("\t-h\t\t: This help.\n");
|
||||
DEBUG_WARN("\t-v[bitmask]\t: Increasing verbosity. Bitmask:\n");
|
||||
DEBUG_WARN("\t\t\t 1 = INFO, 2 = GDB, 4 = TARGET, 8 = PROBE, 16 = WIRE\n");
|
||||
DEBUG_WARN("Probe selection arguments:\n");
|
||||
DEBUG_WARN("\t-d \"path\"\t: Use serial device at \"path\"\n");
|
||||
DEBUG_WARN("\t-P <num>\t: Use debugger found at position <num>\n");
|
||||
DEBUG_WARN("\t-n <num>\t: Use target device found at position <num>\n");
|
||||
DEBUG_WARN("\t-s \"string\"\t: Use dongle with (partial) "
|
||||
"serial number \"string\"\n");
|
||||
printf("\t-c \"string\"\t: Use ftdi dongle with type \"string\"\n");
|
||||
printf("\tRun mode related options:\n");
|
||||
printf("\tDefault mode is to start the debug server at :2000\n");
|
||||
printf("\t-j\t\t: Use JTAG. SWD is default.\n");
|
||||
printf("\t-C\t\t: Connect under reset\n");
|
||||
printf("\t-t\t\t: Scan SWD and display information about connected"
|
||||
"devices\n");
|
||||
printf("\t-E\t\t: Erase flash until flash end or for given size\n");
|
||||
printf("\t-V\t\t: Verify flash against binary file\n");
|
||||
printf("\t-r\t\t: Read flash and write to binary file\n");
|
||||
printf("\t-p\t\t: Supplies power to the target (where applicable)\n");
|
||||
printf("\t-R\t\t: Reset device\n");
|
||||
printf("\tFlash operation modifiers options:\n");
|
||||
printf("\t-a <num>\t: Start flash operation at flash address <num>\n"
|
||||
DEBUG_WARN("\t-c \"string\"\t: Use ftdi dongle with type \"string\"\n");
|
||||
DEBUG_WARN("Run mode related options:\n");
|
||||
DEBUG_WARN("\tDefault mode is to start the debug server at :2000\n");
|
||||
DEBUG_WARN("\t-j\t\t: Use JTAG. SWD is default.\n");
|
||||
DEBUG_WARN("\t-C\t\t: Connect under reset\n");
|
||||
DEBUG_WARN("\t-t\t\t: Scan SWD or JTAG and display information about \n"
|
||||
"\t\t\t connected devices\n");
|
||||
DEBUG_WARN("\t-E\t\t: Erase flash until flash end or for given size\n");
|
||||
DEBUG_WARN("\t-V\t\t: Verify flash against binary file\n");
|
||||
DEBUG_WARN("\t-r\t\t: Read flash and write to binary file\n");
|
||||
DEBUG_WARN("\t-p\t\t: Supplies power to the target (where applicable)\n");
|
||||
DEBUG_WARN("\t-R\t\t: Reset device\n");
|
||||
DEBUG_WARN("Flash operation modifiers options:\n");
|
||||
DEBUG_WARN("\tDefault action with given file is to write to flash\n");
|
||||
DEBUG_WARN("\t-a <addr>\t: Start flash operation at flash address <addr>\n"
|
||||
"\t\t\t Default start is 0x08000000\n");
|
||||
printf("\t-S <num>\t: Read <num> bytes. Default is until read fails.\n");
|
||||
printf("\t <file>\t\t: Use (binary) file <file> for flash operation\n"
|
||||
"\t\t\t Given <file> writes to flash if neither -r or -V is "
|
||||
"given\n");
|
||||
DEBUG_WARN("\t-S <num>\t: Read <num> bytes. Default is until read fails.\n");
|
||||
DEBUG_WARN("\t <file>\t\t: Use (binary) file <file> for flash operation\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -152,7 +155,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||
opt->opt_target_dev = 1;
|
||||
opt->opt_flash_start = 0x08000000;
|
||||
opt->opt_flash_size = 16 * 1024 *1024;
|
||||
while((c = getopt(argc, argv, "Ehv::d:s:I:c:Cn:tVta:S:jpP:rR")) != -1) {
|
||||
while((c = getopt(argc, argv, "Ehv:d:s:I:c:Cn:tVta:S:jpP:rR")) != -1) {
|
||||
switch(c) {
|
||||
case 'c':
|
||||
if (optarg)
|
||||
|
@ -163,9 +166,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||
break;
|
||||
case 'v':
|
||||
if (optarg)
|
||||
cl_debuglevel = strtol(optarg, NULL, 0);
|
||||
else
|
||||
cl_debuglevel = 1;
|
||||
cl_debuglevel = strtol(optarg, NULL, 0) & (BMP_DEBUG_MAX - 1);
|
||||
break;
|
||||
case 'j':
|
||||
opt->opt_usejtag = true;
|
||||
|
@ -190,6 +191,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||
break;
|
||||
case 't':
|
||||
opt->opt_mode = BMP_MODE_TEST;
|
||||
cl_debuglevel |= BMP_DEBUG_INFO | BMP_DEBUG_STDOUT;
|
||||
break;
|
||||
case 'V':
|
||||
opt->opt_mode = BMP_MODE_FLASH_VERIFY;
|
||||
|
@ -242,7 +244,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||
/* Checks */
|
||||
if ((opt->opt_flash_file) && ((opt->opt_mode == BMP_MODE_TEST ) ||
|
||||
(opt->opt_mode == BMP_MODE_RESET))) {
|
||||
printf("Ignoring filename in reset/test mode\n");
|
||||
DEBUG_WARN("Ignoring filename in reset/test mode\n");
|
||||
opt->opt_flash_file = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +252,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||
static void display_target(int i, target *t, void *context)
|
||||
{
|
||||
(void)context;
|
||||
DEBUG("*** %2d %c %s %s\n", i, target_attached(t)?'*':' ',
|
||||
DEBUG_INFO("*** %2d %c %s %s\n", i, target_attached(t)?'*':' ',
|
||||
target_driver_name(t),
|
||||
(target_core_name(t)) ? target_core_name(t): "");
|
||||
}
|
||||
|
@ -261,37 +263,38 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
int num_targets;
|
||||
#if defined(PLATFORM_HAS_POWER_SWITCH)
|
||||
if (opt->opt_tpwr) {
|
||||
printf("Powering up device");
|
||||
DEBUG_INFO("Powering up device");
|
||||
platform_target_set_power(true);
|
||||
platform_delay(500);
|
||||
}
|
||||
#endif
|
||||
if (opt->opt_connect_under_reset)
|
||||
printf("Connecting under reset\n");
|
||||
DEBUG_INFO("Connecting under reset\n");
|
||||
connect_assert_srst = opt->opt_connect_under_reset;
|
||||
platform_srst_set_val(opt->opt_connect_under_reset);
|
||||
if (opt->opt_mode == BMP_MODE_TEST)
|
||||
printf("Running in Test Mode\n");
|
||||
DEBUG_INFO("Running in Test Mode\n");
|
||||
if (platform_target_voltage())
|
||||
printf("Target voltage: %s Volt\n", platform_target_voltage());
|
||||
DEBUG_INFO("Target voltage: %s Volt\n", platform_target_voltage());
|
||||
if (opt->opt_usejtag) {
|
||||
num_targets = platform_jtag_scan(NULL);
|
||||
} else {
|
||||
num_targets = platform_adiv5_swdp_scan();
|
||||
}
|
||||
if (!num_targets) {
|
||||
DEBUG("No target found\n");
|
||||
DEBUG_WARN("No target found\n");
|
||||
return res;
|
||||
} else {
|
||||
target_foreach(display_target, NULL);
|
||||
}
|
||||
if (opt->opt_target_dev > num_targets) {
|
||||
DEBUG("Given target nummer %d not available\n", opt->opt_target_dev);
|
||||
DEBUG_WARN("Given target nummer %d not available\n",
|
||||
opt->opt_target_dev);
|
||||
return res;
|
||||
}
|
||||
target *t = target_attach_n(opt->opt_target_dev, NULL);
|
||||
if (!t) {
|
||||
DEBUG("Can not attach to target %d\n", opt->opt_target_dev);
|
||||
DEBUG_WARN("Can not attach to target %d\n", opt->opt_target_dev);
|
||||
goto target_detach;
|
||||
}
|
||||
if (opt->opt_mode == BMP_MODE_TEST) {
|
||||
|
@ -312,8 +315,8 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
if (sscanf(p, "<memory type=\"flash\" start=\"%x\" length=\"%x\">"
|
||||
"<property name=\"blocksize\">%x</property></memory>",
|
||||
&start, &size, &blocksize))
|
||||
printf("Flash Start: 0x%08x, length %#9x, blocksize %#8x\n",
|
||||
start, size, blocksize);
|
||||
DEBUG_INFO("Flash Start: 0x%08x, length %#9x, "
|
||||
"blocksize %#8x\n", start, size, blocksize);
|
||||
res = strstr(p, "</memory>");
|
||||
p = res + strlen("</memory>");
|
||||
continue;
|
||||
|
@ -322,7 +325,8 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
if (!match) {
|
||||
if (sscanf(p, "<memory type=\"ram\" start=\"%x\" length=\"%x\"/",
|
||||
&start, &size))
|
||||
printf("Ram Start: 0x%08x, length %#9x\n", start, size);
|
||||
DEBUG_INFO("Ram Start: 0x%08x, length %#9x\n",
|
||||
start, size);
|
||||
res = strstr(p, "/>");
|
||||
p = res + strlen("/>");
|
||||
continue;
|
||||
|
@ -337,7 +341,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
(opt->opt_mode == BMP_MODE_FLASH_VERIFY)) {
|
||||
int mmap_res = bmp_mmap(opt->opt_flash_file, &map);
|
||||
if (mmap_res) {
|
||||
DEBUG("Can not map file: %s. Aborting!\n", strerror(errno));
|
||||
DEBUG_WARN("Can not map file: %s. Aborting!\n", strerror(errno));
|
||||
goto target_detach;
|
||||
}
|
||||
} else if (opt->opt_mode == BMP_MODE_FLASH_READ) {
|
||||
|
@ -345,8 +349,8 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
read_file = open(opt->opt_flash_file, O_TRUNC | O_CREAT | O_RDWR | O_BINARY,
|
||||
S_IRUSR | S_IWUSR);
|
||||
if (read_file == -1) {
|
||||
printf("Error opening flashfile %s for read: %s\n",
|
||||
opt->opt_flash_file, strerror(errno));
|
||||
DEBUG_WARN("Error opening flashfile %s for read: %s\n",
|
||||
opt->opt_flash_file, strerror(errno));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -356,51 +360,52 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
if (opt->opt_mode == BMP_MODE_RESET) {
|
||||
target_reset(t);
|
||||
} else if (opt->opt_mode == BMP_MODE_FLASH_ERASE) {
|
||||
DEBUG("Erase %zu bytes at 0x%08" PRIx32 "\n", opt->opt_flash_size,
|
||||
DEBUG_INFO("Erase %zu bytes at 0x%08" PRIx32 "\n", opt->opt_flash_size,
|
||||
opt->opt_flash_start);
|
||||
unsigned int erased = target_flash_erase(t, opt->opt_flash_start,
|
||||
opt->opt_flash_size);
|
||||
if (erased) {
|
||||
DEBUG("Erased failed!\n");
|
||||
DEBUG_WARN("Erased failed!\n");
|
||||
goto free_map;
|
||||
}
|
||||
target_reset(t);
|
||||
} else if (opt->opt_mode == BMP_MODE_FLASH_WRITE) {
|
||||
DEBUG("Erase %zu bytes at 0x%08" PRIx32 "\n", map.size,
|
||||
DEBUG_INFO("Erase %zu bytes at 0x%08" PRIx32 "\n", map.size,
|
||||
opt->opt_flash_start);
|
||||
uint32_t start_time = platform_time_ms();
|
||||
unsigned int erased = target_flash_erase(t, opt->opt_flash_start,
|
||||
map.size);
|
||||
if (erased) {
|
||||
DEBUG("Erased failed!\n");
|
||||
DEBUG_WARN("Erased failed!\n");
|
||||
goto free_map;
|
||||
} else {
|
||||
DEBUG("Flashing %zu bytes at 0x%08" PRIx32 "\n",
|
||||
DEBUG_INFO("Flashing %zu bytes at 0x%08" PRIx32 "\n",
|
||||
map.size, opt->opt_flash_start);
|
||||
unsigned int flashed = target_flash_write(t, opt->opt_flash_start,
|
||||
map.data, map.size);
|
||||
/* Buffered write cares for padding*/
|
||||
if (flashed) {
|
||||
DEBUG("Flashing failed!\n");
|
||||
DEBUG_WARN("Flashing failed!\n");
|
||||
} else {
|
||||
DEBUG("Success!\n");
|
||||
DEBUG_INFO("Success!\n");
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
target_flash_done(t);
|
||||
target_reset(t);
|
||||
uint32_t end_time = platform_time_ms();
|
||||
printf("Flash Write succeeded for %d bytes, %8.3f kiB/s\n",
|
||||
DEBUG_WARN("Flash Write succeeded for %d bytes, %8.3f kiB/s\n",
|
||||
(int)map.size, (((map.size * 1.0)/(end_time - start_time))));
|
||||
} else {
|
||||
#define WORKSIZE 1024
|
||||
uint8_t *data = alloca(WORKSIZE);
|
||||
if (!data) {
|
||||
printf("Can not malloc memory for flash read/verify operation\n");
|
||||
DEBUG_WARN("Can not malloc memory for flash read/verify "
|
||||
"operation\n");
|
||||
return res;
|
||||
}
|
||||
if (opt->opt_mode == BMP_MODE_FLASH_READ)
|
||||
printf("Reading flash from 0x%08" PRIx32 " for %zu"
|
||||
DEBUG_INFO("Reading flash from 0x%08" PRIx32 " for %zu"
|
||||
" bytes to %s\n", opt->opt_flash_start, opt->opt_flash_size,
|
||||
opt->opt_flash_file);
|
||||
uint32_t flash_src = opt->opt_flash_start;
|
||||
|
@ -414,11 +419,11 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
int n_read = target_mem_read(t, data, flash_src, worksize);
|
||||
if (n_read) {
|
||||
if (opt->opt_flash_size == 0) {/* we reached end of flash */
|
||||
printf("Reached end of flash at size %" PRId32 "\n",
|
||||
DEBUG_INFO("Reached end of flash at size %" PRId32 "\n",
|
||||
flash_src - opt->opt_flash_start);
|
||||
break;
|
||||
} else {
|
||||
printf("Read failed at flash address 0x%08" PRIx32 "\n",
|
||||
DEBUG_WARN("Read failed at flash address 0x%08" PRIx32 "\n",
|
||||
flash_src);
|
||||
break;
|
||||
}
|
||||
|
@ -428,15 +433,15 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
if (opt->opt_mode == BMP_MODE_FLASH_VERIFY) {
|
||||
int difference = memcmp(data, flash, worksize);
|
||||
if (difference){
|
||||
printf("Verify failed at flash region 0x%08" PRIx32 "\n",
|
||||
flash_src);
|
||||
DEBUG_WARN("Verify failed at flash region 0x%08"
|
||||
PRIx32 "\n", flash_src);
|
||||
return -1;
|
||||
}
|
||||
flash += worksize;
|
||||
} else if (read_file != -1) {
|
||||
int written = write(read_file, data, worksize);
|
||||
if (written < worksize) {
|
||||
printf("Read failed at flash region 0x%08" PRIx32 "\n",
|
||||
DEBUG_WARN("Read failed at flash region 0x%08" PRIx32 "\n",
|
||||
flash_src);
|
||||
return -1;
|
||||
}
|
||||
|
@ -449,7 +454,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
uint32_t end_time = platform_time_ms();
|
||||
if (read_file != -1)
|
||||
close(read_file);
|
||||
printf("Read/Verified succeeded for %d bytes, %8.3f kiB/s\n",
|
||||
DEBUG_WARN("Read/Verify succeeded for %d bytes, %8.3f kiB/s\n",
|
||||
bytes_read, (((bytes_read * 1.0)/(end_time - start_time))));
|
||||
}
|
||||
free_map:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2019 Uwe Bonnes
|
||||
* Copyright (C) 2019 - 2020 Uwe Bonnes
|
||||
* Written by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -36,13 +36,6 @@ enum bmp_cl_mode {
|
|||
BMP_MODE_FLASH_VERIFY
|
||||
};
|
||||
|
||||
enum BMP_DEBUG {
|
||||
BMP_DEBUG_NONE = 0,
|
||||
BMP_DEBUG_INFO = 1,
|
||||
BMP_DEBUG_PLATFORM = 2,
|
||||
BMP_DEBUG_WIRE = 4
|
||||
};
|
||||
|
||||
typedef struct BMP_CL_OPTIONS_s {
|
||||
enum bmp_cl_mode opt_mode;
|
||||
bool opt_usejtag;
|
||||
|
@ -61,7 +54,6 @@ typedef struct BMP_CL_OPTIONS_s {
|
|||
char *opt_idstring;
|
||||
}BMP_CL_OPTIONS_t;
|
||||
|
||||
extern int cl_debuglevel;
|
||||
void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv);
|
||||
int cl_execute(BMP_CL_OPTIONS_t *opt);
|
||||
int serial_open(BMP_CL_OPTIONS_t *opt, char *serial);
|
||||
|
|
|
@ -89,7 +89,7 @@ int gdb_if_init(void)
|
|||
}
|
||||
break;
|
||||
} while(1);
|
||||
DEBUG("Listening on TCP: %4d\n", port);
|
||||
DEBUG_WARN("Listening on TCP: %4d\n", port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -125,9 +125,11 @@ unsigned char gdb_if_getchar(void)
|
|||
platform_delay(100);
|
||||
} else {
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
DEBUG("error when accepting connection: %d", WSAGetLastError());
|
||||
DEBUG_WARN("error when accepting connection: %d",
|
||||
WSAGetLastError());
|
||||
#else
|
||||
DEBUG("error when accepting connection: %s", strerror(errno));
|
||||
DEBUG_WARN("error when accepting connection: %s",
|
||||
strerror(errno));
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
@ -141,7 +143,7 @@ unsigned char gdb_if_getchar(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
DEBUG("Got connection\n");
|
||||
DEBUG_INFO("Got connection\n");
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
opt = 0;
|
||||
ioctlsocket(gdb_if_conn, FIONBIO, &opt);
|
||||
|
@ -154,9 +156,9 @@ unsigned char gdb_if_getchar(void)
|
|||
if(i <= 0) {
|
||||
gdb_if_conn = -1;
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
DEBUG("Dropped broken connection: %d\n", WSAGetLastError());
|
||||
DEBUG_INFO("Dropped broken connection: %d\n", WSAGetLastError());
|
||||
#else
|
||||
DEBUG("Dropped broken connection: %s\n", strerror(errno));
|
||||
DEBUG_INFO("Dropped broken connection: %s\n", strerror(errno));
|
||||
#endif
|
||||
/* Return '+' in case we were waiting for an ACK */
|
||||
return '+';
|
||||
|
|
|
@ -25,15 +25,15 @@ static void LIBUSB_CALL on_trans_done(struct libusb_transfer *trans)
|
|||
|
||||
if (trans->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
{
|
||||
fprintf(stderr, "on_trans_done: ");
|
||||
DEBUG_WARN("on_trans_done: ");
|
||||
if(trans->status == LIBUSB_TRANSFER_TIMED_OUT) {
|
||||
fprintf(stderr, " Timeout\n");
|
||||
DEBUG_WARN(" Timeout\n");
|
||||
} else if (trans->status == LIBUSB_TRANSFER_CANCELLED) {
|
||||
fprintf(stderr, " cancelled\n");
|
||||
DEBUG_WARN(" cancelled\n");
|
||||
} else if (trans->status == LIBUSB_TRANSFER_NO_DEVICE) {
|
||||
fprintf(stderr, " no device\n");
|
||||
DEBUG_WARN(" no device\n");
|
||||
} else {
|
||||
fprintf(stderr, " unknown\n");
|
||||
DEBUG_WARN(" unknown\n");
|
||||
}
|
||||
ctx->flags |= TRANS_FLAGS_HAS_ERROR;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ static int submit_wait(usb_link_t *link, struct libusb_transfer *trans) {
|
|||
trans->user_data = &trans_ctx;
|
||||
|
||||
if ((error = libusb_submit_transfer(trans))) {
|
||||
fprintf(stderr, "libusb_submit_transfer(%d): %s\n", error,
|
||||
DEBUG_WARN("libusb_submit_transfer(%d): %s\n", error,
|
||||
libusb_strerror(error));
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -62,18 +62,18 @@ static int submit_wait(usb_link_t *link, struct libusb_transfer *trans) {
|
|||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
if (libusb_handle_events_timeout(link->ul_libusb_ctx, &timeout)) {
|
||||
fprintf(stderr, "libusb_handle_events()\n");
|
||||
DEBUG_WARN("libusb_handle_events()\n");
|
||||
return -1;
|
||||
}
|
||||
uint32_t now = platform_time_ms();
|
||||
if (now - start_time > 1000) {
|
||||
libusb_cancel_transfer(trans);
|
||||
fprintf(stderr, "libusb_handle_events() timeout\n");
|
||||
DEBUG_WARN("libusb_handle_events() timeout\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (trans_ctx.flags & TRANS_FLAGS_HAS_ERROR) {
|
||||
fprintf(stderr, "libusb_handle_events() | has_error\n");
|
||||
DEBUG_WARN("libusb_handle_events() | has_error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -93,19 +93,17 @@ int send_recv(usb_link_t *link,
|
|||
link->ep_tx | LIBUSB_ENDPOINT_OUT,
|
||||
txbuf, txlen,
|
||||
NULL, NULL, 0);
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE) {
|
||||
int i = 0;
|
||||
printf(" Send (%3d): ", txlen);
|
||||
for (; i < txlen; i++) {
|
||||
printf("%02x", txbuf[i]);
|
||||
if ((i & 7) == 7)
|
||||
printf(".");
|
||||
if ((i & 31) == 31)
|
||||
printf("\n ");
|
||||
}
|
||||
if (!(i & 31))
|
||||
printf("\n");
|
||||
int i = 0;
|
||||
DEBUG_WIRE(" Send (%3d): ", txlen);
|
||||
for (; i < txlen; i++) {
|
||||
DEBUG_WIRE("%02x", txbuf[i]);
|
||||
if ((i & 7) == 7)
|
||||
DEBUG_WIRE(".");
|
||||
if ((i & 31) == 31)
|
||||
DEBUG_WIRE("\n ");
|
||||
}
|
||||
if (!(i & 31))
|
||||
DEBUG_WIRE("\n");
|
||||
if (submit_wait(link, link->req_trans)) {
|
||||
libusb_clear_halt(link->ul_libusb_device_handle, link->ep_tx);
|
||||
return -1;
|
||||
|
@ -119,7 +117,7 @@ int send_recv(usb_link_t *link,
|
|||
rxbuf, rxsize, NULL, NULL, 0);
|
||||
|
||||
if (submit_wait(link, link->rep_trans)) {
|
||||
DEBUG("clear 1\n");
|
||||
DEBUG_WARN("clear 1\n");
|
||||
libusb_clear_halt(link->ul_libusb_device_handle, link->ep_rx);
|
||||
return -1;
|
||||
}
|
||||
|
@ -127,17 +125,14 @@ int send_recv(usb_link_t *link,
|
|||
if (res >0) {
|
||||
int i;
|
||||
uint8_t *p = rxbuf;
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE) {
|
||||
printf(" Rec (%zu/%d)", rxsize, res);
|
||||
for (i = 0; i < res && i < 32 ; i++) {
|
||||
if ( i && ((i & 7) == 0))
|
||||
printf(".");
|
||||
printf("%02x", p[i]);
|
||||
}
|
||||
DEBUG_WIRE(" Rec (%zu/%d)", rxsize, res);
|
||||
for (i = 0; i < res && i < 32 ; i++) {
|
||||
if ( i && ((i & 7) == 0))
|
||||
DEBUG_WIRE(".");
|
||||
DEBUG_WIRE("%02x", p[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE)
|
||||
printf("\n");
|
||||
DEBUG_WIRE("\n");
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2019 Dave Marples <dave@marples.net>
|
||||
* with additions from Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
* Modifications (C) 2020 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
|
||||
|
@ -40,7 +40,7 @@ static int set_interface_attribs(void)
|
|||
struct termios tty;
|
||||
memset (&tty, 0, sizeof tty);
|
||||
if (tcgetattr (fd, &tty) != 0) {
|
||||
printf("error %d from tcgetattr", errno);
|
||||
DEBUG_WARN("error %d from tcgetattr", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ static int set_interface_attribs(void)
|
|||
tty.c_cflag &= ~CRTSCTS;
|
||||
|
||||
if (tcsetattr (fd, TCSANOW, &tty) != 0) {
|
||||
printf("error %d from tcsetattr", errno);
|
||||
DEBUG_WARN("error %d from tcsetattr", errno);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -77,7 +77,7 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char *serial)
|
|||
struct dirent *dp;
|
||||
DIR *dir = opendir(DEVICE_BY_ID);
|
||||
if (!dir) {
|
||||
printf("No serial device found\n");
|
||||
DEBUG_WARN("No serial device found\n");
|
||||
return -1;
|
||||
}
|
||||
int num_devices = 0;
|
||||
|
@ -95,24 +95,25 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char *serial)
|
|||
}
|
||||
closedir(dir);
|
||||
if ((num_devices == 0) && (num_total == 0)){
|
||||
printf("No BMP probe found\n");
|
||||
DEBUG_WARN("No BMP probe found\n");
|
||||
return -1;
|
||||
} else if (num_devices != 1) {
|
||||
printf("Available Probes:\n");
|
||||
DEBUG_INFO("Available Probes:\n");
|
||||
dir = opendir(DEVICE_BY_ID);
|
||||
if (dir) {
|
||||
while ((dp = readdir(dir)) != NULL) {
|
||||
if ((strstr(dp->d_name, BMP_IDSTRING)) &&
|
||||
(strstr(dp->d_name, "-if00")))
|
||||
printf("%s\n", dp->d_name);
|
||||
DEBUG_WARN("%s\n", dp->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
if (serial)
|
||||
printf("Do no match given serial \"%s\"\n", serial);
|
||||
DEBUG_WARN("Do no match given serial \"%s\"\n", serial);
|
||||
else
|
||||
printf("Select Probe with -s <(Partial) Serial Number\n");
|
||||
DEBUG_WARN("Select Probe with -s <(Partial) Serial "
|
||||
"Number\n");
|
||||
} else {
|
||||
printf("Could not opendir %s: %s\n", name, strerror(errno));
|
||||
DEBUG_WARN("Could not opendir %s: %s\n", name, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -121,7 +122,7 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char *serial)
|
|||
}
|
||||
fd = open(name, O_RDWR | O_SYNC | O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
printf("Couldn't open serial port %s\n", name);
|
||||
DEBUG_WARN("Couldn't open serial port %s\n", name);
|
||||
return -1;
|
||||
}
|
||||
/* BMP only offers an USB-Serial connection with no real serial
|
||||
|
@ -139,11 +140,10 @@ int platform_buffer_write(const uint8_t *data, int size)
|
|||
{
|
||||
int s;
|
||||
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE)
|
||||
printf("%s\n", data);
|
||||
DEBUG_WIRE("%s\n", data);
|
||||
s = write(fd, data, size);
|
||||
if (s < 0) {
|
||||
printf("Failed to write\n");
|
||||
DEBUG_WARN("Failed to write\n");
|
||||
return(-2);
|
||||
}
|
||||
|
||||
|
@ -170,11 +170,11 @@ int platform_buffer_read(uint8_t *data, int maxsize)
|
|||
|
||||
ret = select(fd + 1, &rset, NULL, NULL, &tv);
|
||||
if (ret < 0) {
|
||||
printf("Failed on select\n");
|
||||
DEBUG_WARN("Failed on select\n");
|
||||
return(-3);
|
||||
}
|
||||
if(ret == 0) {
|
||||
printf("Timeout on read RESP\n");
|
||||
DEBUG_WARN("Timeout on read RESP\n");
|
||||
return(-4);
|
||||
}
|
||||
|
||||
|
@ -187,25 +187,24 @@ int platform_buffer_read(uint8_t *data, int maxsize)
|
|||
FD_SET(fd, &rset);
|
||||
ret = select(fd + 1, &rset, NULL, NULL, &tv);
|
||||
if (ret < 0) {
|
||||
printf("Failed on select\n");
|
||||
DEBUG_WARN("Failed on select\n");
|
||||
exit(-4);
|
||||
}
|
||||
if(ret == 0) {
|
||||
printf("Timeout on read\n");
|
||||
DEBUG_WARN("Timeout on read\n");
|
||||
return(-5);
|
||||
}
|
||||
s = read(fd, c, 1);
|
||||
if (*c==REMOTE_EOM) {
|
||||
*c = 0;
|
||||
if (cl_debuglevel & BMP_DEBUG_WIRE)
|
||||
printf(" %s\n",data);
|
||||
DEBUG_WIRE(" %s\n",data);
|
||||
return (c - data);
|
||||
} else {
|
||||
c++;
|
||||
}
|
||||
}while ((s >= 0) && ((c - data) < maxsize));
|
||||
|
||||
printf("Failed to read\n");
|
||||
DEBUG_WARN("Failed to read\n");
|
||||
return(-6);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char * serial)
|
|||
{
|
||||
(void) serial; /* FIXME: Does Windows allow open with USB serial no? */
|
||||
if (!cl_opts->opt_device) {
|
||||
fprintf(stderr,"Specify the serial device to use!\n");
|
||||
DEBUG_WARN("Specify the serial device to use!\n");
|
||||
return -1;
|
||||
}
|
||||
char device[256];
|
||||
|
@ -48,19 +48,19 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char * serial)
|
|||
0, // Non Overlapped I/O
|
||||
NULL); // Null for Comm Devices}
|
||||
if (hComm == INVALID_HANDLE_VALUE) {
|
||||
fprintf(stderr, "Could not open %s: %ld\n", device,
|
||||
DEBUG_WARN("Could not open %s: %ld\n", device,
|
||||
GetLastError());
|
||||
return -1;
|
||||
}
|
||||
DCB dcbSerialParams;
|
||||
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
|
||||
if (!GetCommState(hComm, &dcbSerialParams)) {
|
||||
fprintf(stderr, "GetCommState failed %ld\n", GetLastError());
|
||||
DEBUG_WARN("GetCommState failed %ld\n", GetLastError());
|
||||
return -1;
|
||||
}
|
||||
dcbSerialParams.ByteSize = 8;
|
||||
if (!SetCommState(hComm, &dcbSerialParams)) {
|
||||
fprintf(stderr, "SetCommState failed %ld\n", GetLastError());
|
||||
DEBUG_WARN("SetCommState failed %ld\n", GetLastError());
|
||||
return -1;
|
||||
}
|
||||
COMMTIMEOUTS timeouts = {0};
|
||||
|
@ -70,7 +70,7 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char * serial)
|
|||
timeouts.WriteTotalTimeoutConstant = 10;
|
||||
timeouts.WriteTotalTimeoutMultiplier = 10;
|
||||
if (!SetCommTimeouts(hComm, &timeouts)) {
|
||||
fprintf(stderr, "SetCommTimeouts failed %ld\n", GetLastError());
|
||||
DEBUG_WARN("SetCommTimeouts failed %ld\n", GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -83,14 +83,13 @@ void serial_close(void)
|
|||
|
||||
int platform_buffer_write(const uint8_t *data, int size)
|
||||
{
|
||||
if (cl_debuglevel)
|
||||
printf("%s\n",data);
|
||||
DEBUG_WIRE("%s\n",data);
|
||||
int s = 0;
|
||||
|
||||
do {
|
||||
DWORD written;
|
||||
if (!WriteFile(hComm, data + s, size - s, &written, NULL)) {
|
||||
fprintf(stderr, "Serial write failed %ld, written %d\n",
|
||||
DEBUG_WARN("Serial write failed %ld, written %d\n",
|
||||
GetLastError(), s);
|
||||
return -1;
|
||||
}
|
||||
|
@ -106,34 +105,32 @@ int platform_buffer_read(uint8_t *data, int maxsize)
|
|||
uint32_t endTime = platform_time_ms() + RESP_TIMEOUT;
|
||||
do {
|
||||
if (!ReadFile(hComm, &response, 1, &s, NULL)) {
|
||||
fprintf(stderr,"ERROR on read RESP\n");
|
||||
DEBUG_WARN("ERROR on read RESP\n");
|
||||
exit(-3);
|
||||
}
|
||||
if (platform_time_ms() > endTime) {
|
||||
fprintf(stderr,"Timeout on read RESP\n");
|
||||
DEBUG_WARN("Timeout on read RESP\n");
|
||||
exit(-4);
|
||||
}
|
||||
} while (response != REMOTE_RESP);
|
||||
uint8_t *c = data;
|
||||
do {
|
||||
if (!ReadFile(hComm, c, 1, &s, NULL)) {
|
||||
fprintf(stderr,"Error on read\n");
|
||||
DEBUG_WARN("Error on read\n");
|
||||
exit(-3);
|
||||
}
|
||||
if (s > 0 ) {
|
||||
if (cl_debuglevel)
|
||||
printf("%c", *c);
|
||||
DEBUG_WIRE("%c", *c);
|
||||
if (*c == REMOTE_EOM) {
|
||||
*c = 0;
|
||||
if (cl_debuglevel)
|
||||
printf("\n");
|
||||
DEBUG_WIRE("\n");
|
||||
return (c - data);
|
||||
} else {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
} while (((c - data) < maxsize) && (platform_time_ms() < endTime));
|
||||
fprintf(stderr,"Failed to read EOM at %d\n",
|
||||
DEBUG_WARN("Failed to read EOM at %d\n",
|
||||
platform_time_ms() - startTime);
|
||||
exit(-3);
|
||||
return 0;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#ifdef ENABLE_DEBUG
|
||||
# define PLATFORM_HAS_DEBUG
|
||||
# define USBUART_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
#endif
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware " FIRMWARE_VERSION ")"
|
||||
|
@ -118,14 +120,6 @@
|
|||
#define USBUSART_TIM_IRQ NVIC_TIM4_IRQ
|
||||
#define USBUSART_TIM_ISR tim4_isr
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
# define DEBUG printf
|
||||
#else
|
||||
# define DEBUG(...)
|
||||
#endif
|
||||
|
||||
/* On F103, only USART1 is on AHB2 and can reach 4.5 MBaud at 72 MHz.*/
|
||||
#define SWO_UART USART1
|
||||
#define SWO_UART_DR USART1_DR
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#ifdef ENABLE_DEBUG
|
||||
# define PLATFORM_HAS_DEBUG
|
||||
# define USBUART_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
#endif
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware " FIRMWARE_VERSION ")"
|
||||
|
@ -122,14 +124,6 @@
|
|||
#define TRACE_IC_IN TIM_IC_IN_TI2
|
||||
#define TRACE_TRIG_IN TIM_SMCR_TS_IT1FP2
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
# define DEBUG printf
|
||||
#else
|
||||
# define DEBUG(...)
|
||||
#endif
|
||||
|
||||
/* On F103, only USART1 is on AHB2 and can reach 4.5 MBaud at 72 MHz.
|
||||
* USART1 is already used. sp maximum speed is 2.25 MBaud. */
|
||||
#define SWO_UART USART2
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*
|
||||
* Copyright (C) 2015 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* Copyright (C) 2018 - 2020 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
|
||||
|
@ -280,13 +282,13 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
|||
#endif
|
||||
|
||||
if (adiv5_dp_error(ap->dp)) {
|
||||
DEBUG("%sFault reading ID registers\n", indent);
|
||||
DEBUG_WARN("%sFault reading ID registers\n", indent);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* CIDR preamble sanity check */
|
||||
if ((cidr & ~CID_CLASS_MASK) != CID_PREAMBLE) {
|
||||
DEBUG("%s%d 0x%08" PRIx32": 0x%08" PRIx32
|
||||
DEBUG_WARN("%s%d 0x%08" PRIx32": 0x%08" PRIx32
|
||||
" <- does not match preamble (0x%X)\n",
|
||||
indent + 1, num_entry, addr, cidr, CID_PREAMBLE);
|
||||
return false;
|
||||
|
@ -303,19 +305,19 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
|||
ADIV5_ROM_MEMTYPE_SYSMEM;
|
||||
|
||||
if (adiv5_dp_error(ap->dp)) {
|
||||
DEBUG("Fault reading ROM table entry\n");
|
||||
DEBUG_WARN("Fault reading ROM table entry\n");
|
||||
}
|
||||
|
||||
DEBUG("ROM: Table BASE=0x%" PRIx32 " SYSMEM=0x%" PRIx32 ", PIDR 0x%02"
|
||||
PRIx32 "%08" PRIx32 "\n", addr, memtype, (uint32_t)(pidr >> 32),
|
||||
(uint32_t)pidr);
|
||||
DEBUG_INFO("ROM: Table BASE=0x%" PRIx32 " SYSMEM=0x%" PRIx32
|
||||
", PIDR 0x%02" PRIx32 "%08" PRIx32 "\n", addr,
|
||||
memtype, (uint32_t)(pidr >> 32), (uint32_t)pidr);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 960; i++) {
|
||||
adiv5_dp_error(ap->dp);
|
||||
uint32_t entry = adiv5_mem_read32(ap, addr + i*4);
|
||||
if (adiv5_dp_error(ap->dp)) {
|
||||
DEBUG("%sFault reading ROM table entry %d\n", indent, i);
|
||||
DEBUG_WARN("%sFault reading ROM table entry %d\n", indent, i);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -323,7 +325,7 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
|||
break;
|
||||
|
||||
if (!(entry & ADIV5_ROM_ROMENTRY_PRESENT)) {
|
||||
DEBUG("%s%d Entry 0x%" PRIx32 " -> Not present\n", indent,
|
||||
DEBUG_INFO("%s%d Entry 0x%" PRIx32 " -> Not present\n", indent,
|
||||
i, entry);
|
||||
continue;
|
||||
}
|
||||
|
@ -333,13 +335,13 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
|||
ap, addr + (entry & ADIV5_ROM_ROMENTRY_OFFSET),
|
||||
recursion + 1, i);
|
||||
}
|
||||
DEBUG("%sROM: Table END\n", indent);
|
||||
DEBUG_INFO("%sROM: Table END\n", indent);
|
||||
} else {
|
||||
/* Check if the component was designed by ARM, we currently do not support,
|
||||
* any components by other designers.
|
||||
*/
|
||||
if ((pidr & ~(PIDR_REV_MASK | PIDR_PN_MASK)) != PIDR_ARM_BITS) {
|
||||
DEBUG("%s0x%" PRIx32 ": 0x%02" PRIx32 "%08" PRIx32
|
||||
DEBUG_WARN("%s0x%" PRIx32 ": 0x%02" PRIx32 "%08" PRIx32
|
||||
" <- does not match ARM JEP-106\n",
|
||||
indent, addr, (uint32_t)(pidr >> 32), (uint32_t)pidr);
|
||||
return false;
|
||||
|
@ -353,7 +355,7 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
|||
int i;
|
||||
for (i = 0; pidr_pn_bits[i].arch != aa_end; i++) {
|
||||
if (pidr_pn_bits[i].part_number == part_number) {
|
||||
DEBUG("%s%d 0x%" PRIx32 ": %s - %s %s (PIDR = 0x%02" PRIx32
|
||||
DEBUG_INFO("%s%d 0x%" PRIx32 ": %s - %s %s (PIDR = 0x%02" PRIx32
|
||||
"%08" PRIx32 ")",
|
||||
indent + 1, num_entry, addr,
|
||||
cidc_debug_strings[cid_class],
|
||||
|
@ -364,29 +366,30 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
|||
*/
|
||||
if ((pidr_pn_bits[i].cidc != cidc_unknown) &&
|
||||
(cid_class != pidr_pn_bits[i].cidc)) {
|
||||
DEBUG("%sWARNING: \"%s\" !match expected \"%s\"\n", indent + 1,
|
||||
cidc_debug_strings[cid_class],
|
||||
cidc_debug_strings[pidr_pn_bits[i].cidc]);
|
||||
DEBUG_WARN("%sWARNING: \"%s\" !match expected \"%s\"\n",
|
||||
indent + 1,
|
||||
cidc_debug_strings[cid_class],
|
||||
cidc_debug_strings[pidr_pn_bits[i].cidc]);
|
||||
}
|
||||
res = true;
|
||||
switch (pidr_pn_bits[i].arch) {
|
||||
case aa_cortexm:
|
||||
DEBUG("%s-> cortexm_probe\n", indent + 1);
|
||||
DEBUG_INFO("%s-> cortexm_probe\n", indent + 1);
|
||||
cortexm_probe(ap, false);
|
||||
break;
|
||||
case aa_cortexa:
|
||||
DEBUG("\n -> cortexa_probe\n");
|
||||
DEBUG_INFO("\n -> cortexa_probe\n");
|
||||
cortexa_probe(ap, addr);
|
||||
break;
|
||||
default:
|
||||
DEBUG("\n");
|
||||
DEBUG_INFO("\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pidr_pn_bits[i].arch == aa_end) {
|
||||
DEBUG("%s0x%" PRIx32 ": %s - Unknown (PIDR = 0x%02" PRIx32
|
||||
DEBUG_WARN("%s0x%" PRIx32 ": %s - Unknown (PIDR = 0x%02" PRIx32
|
||||
"%08" PRIx32 ")\n",
|
||||
indent, addr, cidc_debug_strings[cid_class],
|
||||
(uint32_t)(pidr >> 32), (uint32_t)pidr);
|
||||
|
@ -410,7 +413,7 @@ ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel)
|
|||
/* It's valid to so create a heap copy */
|
||||
ap = malloc(sizeof(*ap));
|
||||
if (!ap) { /* malloc failed: heap exhaustion */
|
||||
DEBUG("malloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("malloc: failed in %s\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -422,14 +425,14 @@ ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel)
|
|||
~(ADIV5_AP_CSW_SIZE_MASK | ADIV5_AP_CSW_ADDRINC_MASK);
|
||||
|
||||
if (ap->csw & ADIV5_AP_CSW_TRINPROG) {
|
||||
DEBUG("AP transaction in progress. Target may not be usable.\n");
|
||||
DEBUG_WARN("AP transaction in progress. Target may not be usable.\n");
|
||||
ap->csw &= ~ADIV5_AP_CSW_TRINPROG;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_DEBUG)
|
||||
uint32_t cfg = adiv5_ap_read(ap, ADIV5_AP_CFG);
|
||||
DEBUG("AP %3d: IDR=%08"PRIx32" CFG=%08"PRIx32" BASE=%08"PRIx32" CSW=%08"PRIx32"\n",
|
||||
apsel, ap->idr, cfg, ap->base, ap->csw);
|
||||
DEBUG_INFO("AP %3d: IDR=%08"PRIx32" CFG=%08"PRIx32" BASE=%08" PRIx32
|
||||
" CSW=%08"PRIx32"\n", apsel, ap->idr, cfg, ap->base, ap->csw);
|
||||
#endif
|
||||
return ap;
|
||||
}
|
||||
|
@ -460,7 +463,7 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
|
|||
ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT);
|
||||
}
|
||||
if (e.type) {
|
||||
DEBUG("DP not responding! Trying abort sequence...\n");
|
||||
DEBUG_WARN("DP not responding! Trying abort sequence...\n");
|
||||
adiv5_dp_abort(dp, ADIV5_DP_ABORT_DAPABORT);
|
||||
ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT);
|
||||
}
|
||||
|
@ -493,11 +496,11 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
|
|||
platform_delay(20);
|
||||
ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT);
|
||||
if (ctrlstat & ADIV5_DP_CTRLSTAT_CDBGRSTACK) {
|
||||
DEBUG("RESET_SEQ succeeded.\n");
|
||||
DEBUG_INFO("RESET_SEQ succeeded.\n");
|
||||
break;
|
||||
}
|
||||
if (platform_timeout_is_expired(&timeout)) {
|
||||
DEBUG("RESET_SEQ failed\n");
|
||||
DEBUG_INFO("RESET_SEQ failed\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +511,7 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
|
|||
adiv5_dp_write(dp, ADIV5_DP_SELECT, ADIV5_DP_BANK2);
|
||||
dp->targetid = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT);
|
||||
adiv5_dp_write(dp, ADIV5_DP_SELECT, ADIV5_DP_BANK0);
|
||||
DEBUG("TARGETID %08" PRIx32 "\n", dp->targetid);
|
||||
DEBUG_INFO("TARGETID %08" PRIx32 "\n", dp->targetid);
|
||||
}
|
||||
/* Probe for APs on this DP */
|
||||
uint32_t last_base = 0;
|
||||
|
@ -533,7 +536,7 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
|
|||
continue;
|
||||
}
|
||||
if (ap->base == last_base) {
|
||||
DEBUG("AP %d: Duplicate base\n", i);
|
||||
DEBUG_WARN("AP %d: Duplicate base\n", i);
|
||||
#if PC_HOSTED == 1
|
||||
if (dp->ap_cleanup)
|
||||
dp->ap_cleanup(i);
|
||||
|
@ -569,7 +572,7 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
|
|||
/* The rest should only be added after checking ROM table */
|
||||
probed |= adiv5_component_probe(ap, ap->base, 0, 0);
|
||||
if (!probed && (dp->idcode & 0xfff) == 0x477) {
|
||||
DEBUG("-> cortexm_probe forced\n");
|
||||
DEBUG_INFO("-> cortexm_probe forced\n");
|
||||
cortexm_probe(ap, true);
|
||||
probed = true;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ void adiv5_jtag_dp_handler(jtag_dev_t *dev)
|
|||
{
|
||||
ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));
|
||||
if (!dp) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ int adiv5_swdp_scan(void)
|
|||
target_list_free();
|
||||
ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));
|
||||
if (!dp) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ int adiv5_swdp_scan(void)
|
|||
swd_proc.swdptap_seq_out(0xA5, 8);
|
||||
ack = swd_proc.swdptap_seq_in(3);
|
||||
if((ack != SWDP_ACK_OK) || swd_proc.swdptap_seq_in_parity(&dp->idcode, 32)) {
|
||||
DEBUG("\n");
|
||||
DEBUG_WARN("Read SW-DP IDCODE failed %1" PRIx32 "\n", ack);
|
||||
free(dp);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ static uint32_t va_to_pa(target *t, uint32_t va)
|
|||
if (par & 1)
|
||||
priv->mmu_fault = true;
|
||||
uint32_t pa = (par & ~0xfff) | (va & 0xfff);
|
||||
DEBUG("%s: VA = 0x%08"PRIx32", PAR = 0x%08"PRIx32", PA = 0x%08"PRIX32"\n",
|
||||
DEBUG_INFO("%s: VA = 0x%08"PRIx32", PAR = 0x%08"PRIx32", PA = 0x%08"PRIX32"\n",
|
||||
__func__, va, par, pa);
|
||||
return pa;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ bool cortexa_probe(ADIv5_AP_t *apb, uint32_t debug_base)
|
|||
adiv5_ap_ref(apb);
|
||||
struct cortexa_priv *priv = calloc(1, sizeof(*priv));
|
||||
if (!priv) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ bool cortexa_attach(target *t)
|
|||
dbgdscr |= DBGDSCR_HDBGEN | DBGDSCR_ITREN;
|
||||
dbgdscr = (dbgdscr & ~DBGDSCR_EXTDCCMODE_MASK) | DBGDSCR_EXTDCCMODE_STALL;
|
||||
apb_write(t, DBGDSCR, dbgdscr);
|
||||
DEBUG("DBGDSCR = 0x%08"PRIx32"\n", dbgdscr);
|
||||
DEBUG_INFO("DBGDSCR = 0x%08"PRIx32"\n", dbgdscr);
|
||||
|
||||
target_halt_request(t);
|
||||
tries = 10;
|
||||
|
@ -630,7 +630,7 @@ static enum target_halt_reason cortexa_halt_poll(target *t, target_addr *watch)
|
|||
if (!(dbgdscr & DBGDSCR_HALTED)) /* Not halted */
|
||||
return TARGET_HALT_RUNNING;
|
||||
|
||||
DEBUG("%s: DBGDSCR = 0x%08"PRIx32"\n", __func__, dbgdscr);
|
||||
DEBUG_INFO("%s: DBGDSCR = 0x%08"PRIx32"\n", __func__, dbgdscr);
|
||||
/* Reenable DBGITR */
|
||||
dbgdscr |= DBGDSCR_ITREN;
|
||||
apb_write(t, DBGDSCR, dbgdscr);
|
||||
|
@ -657,7 +657,7 @@ void cortexa_halt_resume(target *t, bool step)
|
|||
if (step) {
|
||||
uint32_t addr = priv->reg_cache.r[15];
|
||||
uint32_t bas = bp_bas(addr, (priv->reg_cache.cpsr & CPSR_THUMB) ? 2 : 4);
|
||||
DEBUG("step 0x%08"PRIx32" %"PRIx32"\n", addr, bas);
|
||||
DEBUG_INFO("step 0x%08"PRIx32" %"PRIx32"\n", addr, bas);
|
||||
/* Set match any breakpoint */
|
||||
apb_write(t, DBGBVR(0), priv->reg_cache.r[15] & ~3);
|
||||
apb_write(t, DBGBCR(0), DBGBCR_INST_MISMATCH | bas |
|
||||
|
@ -693,7 +693,7 @@ void cortexa_halt_resume(target *t, bool step)
|
|||
do {
|
||||
apb_write(t, DBGDRCR, DBGDRCR_CSE | DBGDRCR_RRQ);
|
||||
dbgdscr = apb_read(t, DBGDSCR);
|
||||
DEBUG("%s: DBGDSCR = 0x%08"PRIx32"\n", __func__, dbgdscr);
|
||||
DEBUG_INFO("%s: DBGDSCR = 0x%08"PRIx32"\n", __func__, dbgdscr);
|
||||
} while (!(dbgdscr & DBGDSCR_RESTARTED) &&
|
||||
!platform_timeout_is_expired(&to));
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2012 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
* and Koen De Vleeschauwer.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>,
|
||||
* Koen De Vleeschauwer and Uwe Bonne
|
||||
*
|
||||
* 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
|
||||
|
@ -296,7 +296,7 @@ bool cortexm_probe(ADIv5_AP_t *ap, bool forced)
|
|||
uint32_t identity = ap->idr & 0xff;
|
||||
struct cortexm_priv *priv = calloc(1, sizeof(*priv));
|
||||
if (!priv) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -657,7 +657,7 @@ static void cortexm_reset(target *t)
|
|||
!platform_timeout_is_expired(&to));
|
||||
#if defined(PLATFORM_HAS_DEBUG)
|
||||
if (platform_timeout_is_expired(&to))
|
||||
DEBUG("Reset seem to be stuck low!\n");
|
||||
DEBUG_WARN("Reset seem to be stuck low!\n");
|
||||
#endif
|
||||
/* 10 ms delay to ensure that things such as the STM32 HSI clock
|
||||
* have started up fully. */
|
||||
|
@ -1084,7 +1084,7 @@ static void probe_mem_read(target *t __attribute__((unused)), void *probe_dest,
|
|||
uint8_t *dst = (uint8_t *)probe_dest;
|
||||
uint8_t *src = (uint8_t *)target_src;
|
||||
|
||||
DEBUG("probe_mem_read\n");
|
||||
DEBUG_INFO("probe_mem_read\n");
|
||||
while (len--) *dst++=*src++;
|
||||
return;
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ static void probe_mem_write(target *t __attribute__((unused)), target_addr targe
|
|||
uint8_t *dst = (uint8_t *)target_dest;
|
||||
uint8_t *src = (uint8_t *)probe_src;
|
||||
|
||||
DEBUG("probe_mem_write\n");
|
||||
DEBUG_INFO("probe_mem_write\n");
|
||||
while (len--) *dst++=*src++;
|
||||
return;
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ static int cortexm_hostio_request(target *t)
|
|||
uint32_t syscall = arm_regs[0];
|
||||
int32_t ret = 0;
|
||||
|
||||
DEBUG("syscall 0"PRIx32"%"PRIx32" (%"PRIx32" %"PRIx32" %"PRIx32" %"PRIx32")\n",
|
||||
DEBUG_INFO("syscall 0"PRIx32"%"PRIx32" (%"PRIx32" %"PRIx32" %"PRIx32" %"PRIx32")\n",
|
||||
syscall, params[0], params[1], params[2], params[3]);
|
||||
switch (syscall) {
|
||||
#if PC_HOSTED == 1
|
||||
|
|
|
@ -543,7 +543,7 @@ static void efm32_add_flash(target *t, target_addr addr, size_t length,
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -724,7 +724,7 @@ static int efm32_flash_write(struct target_flash *f,
|
|||
/* Check the MSC_IF */
|
||||
uint32_t msc = device->msc_addr;
|
||||
uint32_t msc_if = target_mem_read32(t, EFM32_MSC_IF(msc));
|
||||
DEBUG("EFM32: Flash write done MSC_IF=%08"PRIx32"\n", msc_if);
|
||||
DEBUG_INFO("EFM32: Flash write done MSC_IF=%08"PRIx32"\n", msc_if);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ void efm32_aap_probe(ADIv5_AP_t *ap)
|
|||
{
|
||||
if ((ap->idr & EFM32_APP_IDR_MASK) == EFM32_AAP_IDR) {
|
||||
/* It's an EFM32 AAP! */
|
||||
DEBUG("EFM32: Found EFM32 AAP\n");
|
||||
DEBUG_INFO("EFM32: Found EFM32 AAP\n");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -1002,7 +1002,7 @@ void efm32_aap_probe(ADIv5_AP_t *ap)
|
|||
//efm32_aap_cmd_device_erase(t);
|
||||
|
||||
/* Read status */
|
||||
DEBUG("EFM32: AAP STATUS=%08"PRIx32"\n", adiv5_ap_read(ap, AAP_STATUS));
|
||||
DEBUG_INFO("EFM32: AAP STATUS=%08"PRIx32"\n", adiv5_ap_read(ap, AAP_STATUS));
|
||||
|
||||
sprintf(aap_driver_string,
|
||||
"EFM32 Authentication Access Port rev.%d",
|
||||
|
@ -1032,15 +1032,15 @@ static bool efm32_aap_cmd_device_erase(target *t, int argc, const char **argv)
|
|||
|
||||
/* Read status */
|
||||
status = adiv5_ap_read(ap, AAP_STATUS);
|
||||
DEBUG("EFM32: AAP STATUS=%08"PRIx32"\n", status);
|
||||
DEBUG_INFO("EFM32: AAP STATUS=%08"PRIx32"\n", status);
|
||||
|
||||
if (status & AAP_STATUS_ERASEBUSY) {
|
||||
DEBUG("EFM32: AAP Erase in progress\n");
|
||||
DEBUG("EFM32: -> ABORT\n");
|
||||
DEBUG_WARN("EFM32: AAP Erase in progress\n");
|
||||
DEBUG_WARN("EFM32: -> ABORT\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG("EFM32: Issuing DEVICEERASE...\n");
|
||||
DEBUG_INFO("EFM32: Issuing DEVICEERASE...\n");
|
||||
adiv5_ap_write(ap, AAP_CMDKEY, CMDKEY);
|
||||
adiv5_ap_write(ap, AAP_CMD, 1);
|
||||
|
||||
|
@ -1051,7 +1051,7 @@ static bool efm32_aap_cmd_device_erase(target *t, int argc, const char **argv)
|
|||
|
||||
/* Read status */
|
||||
status = adiv5_ap_read(ap, AAP_STATUS);
|
||||
DEBUG("EFM32: AAP STATUS=%08"PRIx32"\n", status);
|
||||
DEBUG_INFO("EFM32: AAP STATUS=%08"PRIx32"\n", status);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ int jtag_scan(const uint8_t *irlens)
|
|||
/* Run throught the SWD to JTAG sequence for the case where an attached SWJ-DP is
|
||||
* in SW-DP mode.
|
||||
*/
|
||||
DEBUG("Resetting TAP\n");
|
||||
DEBUG_INFO("Resetting TAP\n");
|
||||
#if PC_HOSTED == 1
|
||||
if (platform_jtagtap_init()) {
|
||||
DEBUG("JTAG not available\n");
|
||||
DEBUG_WARN("JTAG not available\n");
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
@ -78,8 +78,8 @@ int jtag_scan(const uint8_t *irlens)
|
|||
jtag_proc.jtagtap_reset();
|
||||
|
||||
if (irlens) {
|
||||
DEBUG("Given list of IR lengths, skipping probe\n");
|
||||
DEBUG("Change state to Shift-IR\n");
|
||||
DEBUG_WARN("Given list of IR lengths, skipping probe\n");
|
||||
DEBUG_INFO("Change state to Shift-IR\n");
|
||||
jtagtap_shift_ir();
|
||||
j = 0;
|
||||
while((jtag_dev_count <= JTAG_MAX_DEVS) &&
|
||||
|
@ -89,7 +89,7 @@ int jtag_scan(const uint8_t *irlens)
|
|||
break;
|
||||
jtag_proc.jtagtap_tdi_tdo_seq((uint8_t*)&irout, 0, ones, *irlens);
|
||||
if (!(irout & 1)) {
|
||||
DEBUG("check failed: IR[0] != 1\n");
|
||||
DEBUG_WARN("check failed: IR[0] != 1\n");
|
||||
return -1;
|
||||
}
|
||||
jtag_devs[jtag_dev_count].ir_len = *irlens;
|
||||
|
@ -100,12 +100,13 @@ int jtag_scan(const uint8_t *irlens)
|
|||
jtag_dev_count++;
|
||||
}
|
||||
} else {
|
||||
DEBUG("Change state to Shift-IR\n");
|
||||
DEBUG_INFO("Change state to Shift-IR\n");
|
||||
jtagtap_shift_ir();
|
||||
|
||||
DEBUG("Scanning out IRs\n");
|
||||
DEBUG_INFO("Scanning out IRs\n");
|
||||
if(!jtag_proc.jtagtap_next(0, 1)) {
|
||||
DEBUG("jtag_scan: Sanity check failed: IR[0] shifted out as 0\n");
|
||||
DEBUG_WARN("jtag_scan: Sanity check failed: IR[0] shifted out "
|
||||
"as 0\n");
|
||||
jtag_dev_count = -1;
|
||||
return -1; /* must be 1 */
|
||||
}
|
||||
|
@ -121,37 +122,37 @@ int jtag_scan(const uint8_t *irlens)
|
|||
j++;
|
||||
}
|
||||
if(jtag_dev_count > JTAG_MAX_DEVS) {
|
||||
DEBUG("jtag_scan: Maximum device count exceeded\n");
|
||||
DEBUG_WARN("jtag_scan: Maximum device count exceeded\n");
|
||||
jtag_dev_count = -1;
|
||||
return -1;
|
||||
}
|
||||
if(jtag_devs[jtag_dev_count].ir_len > JTAG_MAX_IR_LEN) {
|
||||
DEBUG("jtag_scan: Maximum IR length exceeded\n");
|
||||
DEBUG_WARN("jtag_scan: Maximum IR length exceeded\n");
|
||||
jtag_dev_count = -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG("Return to Run-Test/Idle\n");
|
||||
DEBUG_INFO("Return to Run-Test/Idle\n");
|
||||
jtag_proc.jtagtap_next(1, 1);
|
||||
jtagtap_return_idle();
|
||||
|
||||
/* All devices should be in BYPASS now */
|
||||
|
||||
/* Count device on chain */
|
||||
DEBUG("Change state to Shift-DR\n");
|
||||
DEBUG_INFO("Change state to Shift-DR\n");
|
||||
jtagtap_shift_dr();
|
||||
for(i = 0; (jtag_proc.jtagtap_next(0, 1) == 0) && (i <= jtag_dev_count); i++)
|
||||
jtag_devs[i].dr_postscan = jtag_dev_count - i - 1;
|
||||
|
||||
if(i != jtag_dev_count) {
|
||||
DEBUG("jtag_scan: Sanity check failed: "
|
||||
DEBUG_WARN("jtag_scan: Sanity check failed: "
|
||||
"BYPASS dev count doesn't match IR scan\n");
|
||||
jtag_dev_count = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
DEBUG("Return to Run-Test/Idle\n");
|
||||
DEBUG_INFO("Return to Run-Test/Idle\n");
|
||||
jtag_proc.jtagtap_next(1, 1);
|
||||
jtagtap_return_idle();
|
||||
if(!jtag_dev_count) {
|
||||
|
@ -173,7 +174,7 @@ int jtag_scan(const uint8_t *irlens)
|
|||
if(jtag_proc.jtagtap_next(0, 1)) jtag_devs[i].idcode |= j;
|
||||
|
||||
}
|
||||
DEBUG("Return to Run-Test/Idle\n");
|
||||
DEBUG_INFO("Return to Run-Test/Idle\n");
|
||||
jtag_proc.jtagtap_next(1, 1);
|
||||
jtagtap_return_idle();
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ static void kl_gen_add_flash(target *t, uint32_t addr, size_t length,
|
|||
struct target_flash *f;
|
||||
|
||||
if (!kf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static void lmi_add_flash(target *t, size_t length)
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ lpc11xx_probe(target *t)
|
|||
return true;
|
||||
}
|
||||
if (idcode) {
|
||||
DEBUG("LPC11xx: Unknown IDCODE 0x%08" PRIx32 "\n", idcode);
|
||||
DEBUG_INFO("LPC11xx: Unknown IDCODE 0x%08" PRIx32 "\n", idcode);
|
||||
}
|
||||
idcode = target_mem_read32(t, LPC8XX_DEVICE_ID);
|
||||
switch (idcode) {
|
||||
|
@ -196,7 +196,7 @@ lpc11xx_probe(target *t)
|
|||
return true;
|
||||
}
|
||||
if (idcode) {
|
||||
DEBUG("LPC8xx: Unknown IDCODE 0x%08" PRIx32 "\n", idcode);
|
||||
DEBUG_INFO("LPC8xx: Unknown IDCODE 0x%08" PRIx32 "\n", idcode);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -138,17 +138,20 @@ lpc17xx_cmd_erase(target *t, int argc, const char *argv[])
|
|||
struct flash_param param;
|
||||
|
||||
if (lpc17xx_iap_call(t, ¶m, IAP_CMD_PREPARE, 0, FLASH_NUM_SECTOR-1)) {
|
||||
DEBUG("lpc17xx_cmd_erase: prepare failed %d\n", (unsigned int)param.result[0]);
|
||||
DEBUG_WARN("lpc17xx_cmd_erase: prepare failed %d\n",
|
||||
(unsigned int)param.result[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lpc17xx_iap_call(t, ¶m, IAP_CMD_ERASE, 0, FLASH_NUM_SECTOR-1, CPU_CLK_KHZ)) {
|
||||
DEBUG("lpc17xx_cmd_erase: erase failed %d\n", (unsigned int)param.result[0]);
|
||||
DEBUG_WARN("lpc17xx_cmd_erase: erase failed %d\n",
|
||||
(unsigned int)param.result[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lpc17xx_iap_call(t, ¶m, IAP_CMD_BLANKCHECK, 0, FLASH_NUM_SECTOR-1)) {
|
||||
DEBUG("lpc17xx_cmd_erase: blankcheck failed %d\n", (unsigned int)param.result[0]);
|
||||
DEBUG_WARN("lpc17xx_cmd_erase: blankcheck failed %d\n",
|
||||
(unsigned int)param.result[0]);
|
||||
return false;
|
||||
}
|
||||
tc_printf(t, "Erase OK.\n");
|
||||
|
@ -198,4 +201,4 @@ lpc17xx_iap_call(target *t, struct flash_param *param, enum iap_cmd cmd, ...) {
|
|||
/* copy back just the parameters structure */
|
||||
target_mem_read(t, (void *)param, IAP_RAM_BASE, sizeof(struct flash_param));
|
||||
return param->result[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ struct lpc_flash *lpc_add_flash(target *t, target_addr addr, size_t length)
|
|||
struct target_flash *f;
|
||||
|
||||
if (!lf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ static void msp432_add_flash(target *t, uint32_t addr, size_t length, target_add
|
|||
struct msp432_flash *mf = calloc(1, sizeof(*mf));
|
||||
struct target_flash *f;
|
||||
if (!mf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ bool msp432_probe(target *t)
|
|||
|
||||
/* Check for the right HW revision: at least C, as no flash support for B */
|
||||
if (target_mem_read32(t, HWREV_ADDR) < HWREV_MIN_VALUE) {
|
||||
DEBUG("MSP432 Version not handled\n");
|
||||
DEBUG_INFO("MSP432 Version not handled\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -239,20 +239,21 @@ static bool msp432_sector_erase(struct target_flash *f, target_addr addr)
|
|||
|
||||
/* Unprotect sector */
|
||||
uint32_t old_prot = msp432_sector_unprotect(mf, addr);
|
||||
DEBUG("Flash protect: 0x%08"PRIX32"\n", target_mem_read32(t, mf->flash_protect_register));
|
||||
DEBUG_WARN("Flash protect: 0x%08"PRIX32"\n",
|
||||
target_mem_read32(t, mf->flash_protect_register));
|
||||
|
||||
/* Prepare input data */
|
||||
uint32_t regs[t->regs_size / sizeof(uint32_t)]; // Use of VLA
|
||||
target_regs_read(t, regs);
|
||||
regs[0] = addr; // Address of sector to erase in R0
|
||||
|
||||
DEBUG("Erasing sector at 0x%08"PRIX32"\n", addr);
|
||||
DEBUG_INFO("Erasing sector at 0x%08"PRIX32"\n", addr);
|
||||
|
||||
/* Call ROM */
|
||||
msp432_call_ROM(t, mf->FlashCtl_eraseSector, regs);
|
||||
|
||||
// Result value in R0 is true for success
|
||||
DEBUG("ROM return value: %"PRIu32"\n", regs[0]);
|
||||
DEBUG_INFO("ROM return value: %"PRIu32"\n", regs[0]);
|
||||
|
||||
/* Restore original protection */
|
||||
target_mem_write32(t, mf->flash_protect_register, old_prot);
|
||||
|
@ -291,7 +292,8 @@ static int msp432_flash_write(struct target_flash *f, target_addr dest,
|
|||
/* Unprotect sector, len is always < SECTOR_SIZE */
|
||||
uint32_t old_prot = msp432_sector_unprotect(mf, dest);
|
||||
|
||||
DEBUG("Flash protect: 0x%08"PRIX32"\n", target_mem_read32(t, mf->flash_protect_register));
|
||||
DEBUG_WARN("Flash protect: 0x%08"PRIX32"\n",
|
||||
target_mem_read32(t, mf->flash_protect_register));
|
||||
|
||||
/* Prepare input data */
|
||||
uint32_t regs[t->regs_size / sizeof(uint32_t)]; // Use of VLA
|
||||
|
@ -300,14 +302,14 @@ static int msp432_flash_write(struct target_flash *f, target_addr dest,
|
|||
regs[1] = dest; // Flash address to be write to in R1
|
||||
regs[2] = len; // Size of buffer to be flashed in R2
|
||||
|
||||
DEBUG("Writing 0x%04" PRIX32 " bytes at 0x%08zu\n", dest, len);
|
||||
DEBUG_INFO("Writing 0x%04" PRIX32 " bytes at 0x%08zu\n", dest, len);
|
||||
/* Call ROM */
|
||||
msp432_call_ROM(t, mf->FlashCtl_programMemory, regs);
|
||||
|
||||
/* Restore original protection */
|
||||
target_mem_write32(t, mf->flash_protect_register, old_prot);
|
||||
|
||||
DEBUG("ROM return value: %"PRIu32"\n", regs[0]);
|
||||
DEBUG_INFO("ROM return value: %"PRIu32"\n", regs[0]);
|
||||
// Result value in R0 is true for success
|
||||
return !regs[0];
|
||||
}
|
||||
|
@ -321,7 +323,7 @@ static bool msp432_cmd_erase_main(target *t, int argc, const char **argv)
|
|||
/* Usually, this is not wanted, so go sector by sector... */
|
||||
|
||||
uint32_t banksize = target_mem_read32(t, SYS_FLASH_SIZE) / 2;
|
||||
DEBUG("Bank Size: 0x%08"PRIX32"\n", banksize);
|
||||
DEBUG_INFO("Bank Size: 0x%08"PRIX32"\n", banksize);
|
||||
|
||||
/* Erase first bank */
|
||||
struct target_flash *f = get_target_flash(t, MAIN_FLASH_BASE);
|
||||
|
|
|
@ -99,7 +99,7 @@ static void nrf51_add_flash(target *t,
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ bool ke04_probe(target *t)
|
|||
/* Add flash, all KE04 have same write and erase size */
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ static void sam3_add_flash(target *t,
|
|||
struct target_flash *f;
|
||||
|
||||
if (!sf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ static void sam4_add_flash(target *t,
|
|||
struct target_flash *f;
|
||||
|
||||
if (!sf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ bool sam3x_probe(target *t)
|
|||
static int
|
||||
sam3x_flash_cmd(target *t, uint32_t base, uint8_t cmd, uint16_t arg)
|
||||
{
|
||||
DEBUG("%s: base = 0x%08"PRIx32" cmd = 0x%02X, arg = 0x%06X\n",
|
||||
DEBUG_INFO("%s: base = 0x%08"PRIx32" cmd = 0x%02X, arg = 0x%06X\n",
|
||||
__func__, base, cmd, arg);
|
||||
target_mem_write32(t, EEFC_FCR(base),
|
||||
EEFC_FCR_FKEY | cmd | ((uint32_t)arg << 8));
|
||||
|
|
|
@ -170,7 +170,7 @@ static void sam4l_add_flash(target *t, uint32_t addr, size_t length)
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(struct target_flash));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -237,15 +237,15 @@ bool sam4l_probe(target *t)
|
|||
target_add_ram(t, 0x20000000, ram_size);
|
||||
flash_size = sam_nvp_size(t->idcode);
|
||||
sam4l_add_flash(t, 0x0, flash_size);
|
||||
DEBUG("\nSAM4L: RAM = 0x%x (%dK), FLASH = 0x%x (%dK)\n",
|
||||
DEBUG_INFO("\nSAM4L: RAM = 0x%x (%dK), FLASH = 0x%x (%dK)\n",
|
||||
(unsigned int) ram_size, (unsigned int) (ram_size / 1024),
|
||||
(unsigned int) flash_size, (unsigned int)(flash_size / 1024));
|
||||
|
||||
/* enable SMAP if not, check for HCR and reset if set */
|
||||
sam4l_extended_reset(t);
|
||||
DEBUG("\nSAM4L: SAM4L Selected.\n");
|
||||
DEBUG_INFO("\nSAM4L: SAM4L Selected.\n");
|
||||
if (target_check_error(t)) {
|
||||
DEBUG("SAM4L: target_check_error returned true\n");
|
||||
DEBUG_WARN("SAM4L: target_check_error returned true\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -261,11 +261,11 @@ sam4l_extended_reset(target *t)
|
|||
uint32_t reg;
|
||||
int i;
|
||||
|
||||
DEBUG("SAM4L: Extended Reset\n");
|
||||
DEBUG_INFO("SAM4L: Extended Reset\n");
|
||||
/* enable SMAP in case we're dealing with a non-TCK SRST */
|
||||
target_mem_write32(t, SMAP_CR, 0x1); /* enable SMAP */
|
||||
reg = target_mem_read32(t, SMAP_SR);
|
||||
DEBUG("\nSAM4L: SMAP_SR has 0x%08lx\n", (long unsigned int) reg);
|
||||
DEBUG_INFO("\nSAM4L: SMAP_SR has 0x%08lx\n", (long unsigned int) reg);
|
||||
if ((reg & SMAP_SR_HCR) != 0) {
|
||||
/* write '1' bit to the status clear register */
|
||||
target_mem_write32(t, SMAP_SCR, SMAP_SR_HCR);
|
||||
|
@ -275,7 +275,8 @@ sam4l_extended_reset(target *t)
|
|||
}
|
||||
/* not sure what to do if we can't reset that bit */
|
||||
if (i > 249) {
|
||||
DEBUG("\nSAM4L: Reset failed. SMAP_SR has 0x%08lx\n", (long unsigned int) reg);
|
||||
DEBUG_INFO("\nSAM4L: Reset failed. SMAP_SR has 0x%08lx\n",
|
||||
(long unsigned int) reg);
|
||||
}
|
||||
}
|
||||
/* reset bus error if for some reason SMAP was disabled */
|
||||
|
@ -298,8 +299,9 @@ sam4l_flash_command(target *t, uint32_t page, uint32_t cmd)
|
|||
uint32_t cmd_reg;
|
||||
uint32_t status;
|
||||
int timeout;
|
||||
DEBUG("\nSAM4L: sam4l_flash_command: FSR: 0x%08x, page = %d, command = %d\n",
|
||||
(unsigned int)(FLASHCALW_FSR), (int) page, (int) cmd);
|
||||
DEBUG_INFO("\nSAM4L: sam4l_flash_command: FSR: 0x%08x, page = %d, "
|
||||
"command = %d\n", (unsigned int)(FLASHCALW_FSR),
|
||||
(int) page, (int) cmd);
|
||||
/* wait for Flash controller ready */
|
||||
for (timeout = 0; timeout < FLASH_TIMEOUT; timeout++) {
|
||||
status = target_mem_read32(t, FLASHCALW_FSR);
|
||||
|
@ -308,14 +310,16 @@ sam4l_flash_command(target *t, uint32_t page, uint32_t cmd)
|
|||
}
|
||||
}
|
||||
if (timeout == FLASH_TIMEOUT) {
|
||||
DEBUG("\nSAM4L: sam4l_flash_command: Not ready! Status = 0x%08x\n", (unsigned int) status);
|
||||
DEBUG_WARN("\nSAM4L: sam4l_flash_command: Not ready! "
|
||||
"Status = 0x%08x\n", (unsigned int) status);
|
||||
return -1; /* Failed */
|
||||
}
|
||||
/* load up the new command */
|
||||
cmd_reg = (cmd & FLASHCALW_FCMD_CMD_MASK) |
|
||||
((page & FLASHCALW_FCMD_PAGEN_MASK) << FLASHCALW_FCMD_PAGEN_SHIFT) |
|
||||
(0xA5 << FLASHCALW_FCMD_KEY_SHIFT);
|
||||
DEBUG("\nSAM4L: sam4l_flash_command: Wrting command word 0x%08x\n", (unsigned int) cmd_reg);
|
||||
DEBUG_INFO("\nSAM4L: sam4l_flash_command: Wrting command word 0x%08x\n",
|
||||
(unsigned int) cmd_reg);
|
||||
/* and kick it off */
|
||||
target_mem_write32(t, FLASHCALW_FCMD, cmd_reg);
|
||||
/* don't actually wait for it to finish, the next command will stall if it is not done */
|
||||
|
@ -334,7 +338,8 @@ sam4l_flash_write_buf(struct target_flash *f, target_addr addr, const void *src,
|
|||
uint32_t ndx;
|
||||
uint16_t page;
|
||||
|
||||
DEBUG("\nSAM4L: sam4l_flash_write_buf: addr = 0x%08lx, len %d\n", (long unsigned int) addr, (int) len);
|
||||
DEBUG_INFO("\nSAM4L: sam4l_flash_write_buf: addr = 0x%08lx, len %d\n",
|
||||
(long unsigned int) addr, (int) len);
|
||||
/* This will fail with unaligned writes, the write_buf version */
|
||||
page = addr / SAM4L_PAGE_SIZE;
|
||||
|
||||
|
@ -380,7 +385,7 @@ sam4l_flash_erase(struct target_flash *f, target_addr addr, size_t len)
|
|||
target *t = f->t;
|
||||
uint16_t page;
|
||||
|
||||
DEBUG("SAM4L: flash erase address 0x%08x for %d bytes\n",
|
||||
DEBUG_INFO("SAM4L: flash erase address 0x%08x for %d bytes\n",
|
||||
(unsigned int) addr, (unsigned int) len);
|
||||
/*
|
||||
* NB: if addr isn't aligned to a page boundary, or length
|
||||
|
|
|
@ -428,7 +428,7 @@ static void samd_add_flash(target *t, uint32_t addr, size_t length)
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ static void samx5x_add_flash(target *t, uint32_t addr, size_t length,
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_INFO("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -462,19 +462,19 @@ static void samx5x_unlock_current_address(target *t)
|
|||
static void samx5x_print_nvm_error(uint16_t errs)
|
||||
{
|
||||
if (errs & SAMX5X_INTFLAG_ADDRE) {
|
||||
DEBUG(" ADDRE");
|
||||
DEBUG_WARN(" ADDRE");
|
||||
}
|
||||
if (errs & SAMX5X_INTFLAG_PROGE) {
|
||||
DEBUG(" PROGE");
|
||||
DEBUG_WARN(" PROGE");
|
||||
}
|
||||
if (errs & SAMX5X_INTFLAG_LOCKE) {
|
||||
DEBUG(" LOCKE");
|
||||
DEBUG_WARN(" LOCKE");
|
||||
}
|
||||
if (errs & SAMX5X_INTFLAG_NVME) {
|
||||
DEBUG(" NVME");
|
||||
DEBUG_WARN(" NVME");
|
||||
}
|
||||
|
||||
DEBUG("\n");
|
||||
DEBUG_WARN("\n");
|
||||
}
|
||||
|
||||
static int samx5x_read_nvm_error(target *t)
|
||||
|
@ -499,7 +499,7 @@ static int samx5x_check_nvm_error(target *t)
|
|||
if (!errs)
|
||||
return 0;
|
||||
|
||||
DEBUG("NVM error(s) detected:");
|
||||
DEBUG_WARN("NVM error(s) detected:");
|
||||
samx5x_print_nvm_error(errs);
|
||||
return -1;
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ static int samx5x_flash_erase(struct target_flash *f, target_addr addr,
|
|||
target *t = f->t;
|
||||
uint16_t errs = samx5x_read_nvm_error(t);
|
||||
if (errs) {
|
||||
DEBUG(NVM_ERROR_BITS_MSG, "erase", addr, len);
|
||||
DEBUG_INFO(NVM_ERROR_BITS_MSG, "erase", addr, len);
|
||||
samx5x_print_nvm_error(errs);
|
||||
samx5x_clear_nvm_error(t);
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ static int samx5x_flash_write(struct target_flash *f,
|
|||
bool error = false;
|
||||
uint16_t errs = samx5x_read_nvm_error(t);
|
||||
if (errs) {
|
||||
DEBUG(NVM_ERROR_BITS_MSG, "write", dest, len);
|
||||
DEBUG_INFO(NVM_ERROR_BITS_MSG, "write", dest, len);
|
||||
samx5x_print_nvm_error(errs);
|
||||
samx5x_clear_nvm_error(t);
|
||||
}
|
||||
|
@ -604,9 +604,8 @@ static int samx5x_flash_write(struct target_flash *f,
|
|||
}
|
||||
|
||||
if (error || target_check_error(t) || samx5x_check_nvm_error(t)) {
|
||||
DEBUG("Error writing flash page at 0x%08"PRIx32
|
||||
" (len 0x%08zx)\n",
|
||||
dest, len);
|
||||
DEBUG_WARN("Error writing flash page at 0x%08"PRIx32
|
||||
" (len 0x%08zx)\n", dest, len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -623,9 +622,9 @@ static int samx5x_write_user_page(target *t, uint8_t *buffer)
|
|||
{
|
||||
uint16_t errs = samx5x_read_nvm_error(t);
|
||||
if (errs) {
|
||||
DEBUG(NVM_ERROR_BITS_MSG, "erase and write",
|
||||
(uint32_t)SAMX5X_NVM_USER_PAGE,
|
||||
(size_t)SAMX5X_PAGE_SIZE);
|
||||
DEBUG_INFO(NVM_ERROR_BITS_MSG, "erase and write",
|
||||
(uint32_t)SAMX5X_NVM_USER_PAGE,
|
||||
(size_t)SAMX5X_PAGE_SIZE);
|
||||
samx5x_print_nvm_error(errs);
|
||||
samx5x_clear_nvm_error(t);
|
||||
}
|
||||
|
@ -692,13 +691,13 @@ static int samx5x_update_user_word(target *t, uint32_t addr, uint32_t value,
|
|||
*value_written = new_word;
|
||||
|
||||
if (new_word != current_word) {
|
||||
DEBUG("Writing user page word 0x%08"PRIx32
|
||||
" at offset 0x%03"PRIx32"\n", new_word, addr);
|
||||
DEBUG_INFO("Writing user page word 0x%08"PRIx32
|
||||
" at offset 0x%03"PRIx32"\n", new_word, addr);
|
||||
memcpy(buffer + addr, &new_word, 4);
|
||||
return samx5x_write_user_page(t, buffer);
|
||||
}
|
||||
else {
|
||||
DEBUG("Skipping user page write as no change would be made");
|
||||
DEBUG_INFO("Skipping user page write as no change would be made");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -947,8 +946,8 @@ static bool samx5x_cmd_mbist(target *t, int argc, const char **argv)
|
|||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
DEBUG("Running MBIST for memory range 0x%08x-%08"PRIx32"\n",
|
||||
SAMX5X_RAM_START, samx5x_ram_size(t));
|
||||
DEBUG_INFO("Running MBIST for memory range 0x%08x-%08"PRIx32"\n",
|
||||
SAMX5X_RAM_START, samx5x_ram_size(t));
|
||||
|
||||
/* Write the memory parameters to the DSU
|
||||
* Note that the two least significant bits of the address are
|
||||
|
@ -1019,8 +1018,8 @@ static bool samx5x_cmd_write8(target *t, int argc, const char **argv)
|
|||
return false;
|
||||
}
|
||||
|
||||
DEBUG("Writing 8-bit value 0x%02"PRIx32" at address 0x%08"PRIx32"\n",
|
||||
value, addr);
|
||||
DEBUG_INFO("Writing 8-bit value 0x%02"PRIx32" at address 0x%08"PRIx32"\n",
|
||||
value, addr);
|
||||
target_mem_write8(t, addr, (uint8_t)value);
|
||||
|
||||
return true;
|
||||
|
@ -1051,8 +1050,8 @@ static bool samx5x_cmd_write16(target *t, int argc, const char **argv)
|
|||
return false;
|
||||
}
|
||||
|
||||
DEBUG("Writing 16-bit value 0x%04"PRIx32" at address 0x%08"PRIx32"\n",
|
||||
value, addr);
|
||||
DEBUG_INFO("Writing 16-bit value 0x%04"PRIx32" at address 0x%08"PRIx32"\n",
|
||||
value, addr);
|
||||
target_mem_write16(t, addr, (uint16_t)value);
|
||||
|
||||
return true;
|
||||
|
@ -1078,8 +1077,8 @@ static bool samx5x_cmd_write32(target *t, int argc, const char **argv)
|
|||
return false;
|
||||
}
|
||||
|
||||
DEBUG("Writing 32-bit value 0x%08"PRIx32" at address 0x%08"PRIx32"\n",
|
||||
value, addr);
|
||||
DEBUG_INFO("Writing 32-bit value 0x%08"PRIx32" at address 0x%08"PRIx32"\n",
|
||||
value, addr);
|
||||
target_mem_write32(t, addr, value);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -99,7 +99,7 @@ static void stm32f1_add_flash(target *t,
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ bool stm32f1_probe(target *t)
|
|||
if ((ap->idr >> 28) > 1) {
|
||||
t->driver = "STM32F1 (clone) medium density";
|
||||
#if defined(PLATFORM_HAS_DEBUG)
|
||||
DEBUG("Non-genuine STM32F1\n");
|
||||
DEBUG_WARN("Non-genuine STM32F1\n");
|
||||
#endif
|
||||
} else {
|
||||
t->driver = "STM32F1 medium density";
|
||||
|
@ -216,7 +216,7 @@ static int stm32f1_flash_erase(struct target_flash *f,
|
|||
/* Read FLASH_SR to poll for BSY bit */
|
||||
while (target_mem_read32(t, FLASH_SR) & FLASH_SR_BSY)
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("stm32f1 flash erase: comm error\n");
|
||||
DEBUG_WARN("stm32f1 flash erase: comm error\n");
|
||||
return -1;
|
||||
}
|
||||
if (len > f->blocksize)
|
||||
|
@ -229,7 +229,7 @@ static int stm32f1_flash_erase(struct target_flash *f,
|
|||
/* Check for error */
|
||||
uint32_t sr = target_mem_read32(t, FLASH_SR);
|
||||
if ((sr & SR_ERROR_MASK) || !(sr & SR_EOP)) {
|
||||
DEBUG("stm32f1 flash erase error 0x%" PRIx32 "\n", sr);
|
||||
DEBUG_INFO("stm32f1 flash erase error 0x%" PRIx32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -248,14 +248,14 @@ static int stm32f1_flash_write(struct target_flash *f,
|
|||
do {
|
||||
sr = target_mem_read32(t, FLASH_SR);
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("stm32f1 flash write: comm error\n");
|
||||
DEBUG_WARN("stm32f1 flash write: comm error\n");
|
||||
return -1;
|
||||
}
|
||||
} while (sr & FLASH_SR_BSY);
|
||||
|
||||
if (sr & SR_ERROR_MASK) {
|
||||
DEBUG("stm32f1 flash write error 0x%" PRIx32 "\n", sr);
|
||||
return -1;
|
||||
DEBUG_WARN("stm32f1 flash write error 0x%" PRIx32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ static void stm32f4_add_flash(target *t,
|
|||
struct stm32f4_flash *sf = calloc(1, sizeof(*sf));
|
||||
struct target_flash *f;
|
||||
if (!sf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ static int stm32f4_flash_erase(struct target_flash *f, target_addr addr,
|
|||
/* Read FLASH_SR to poll for BSY bit */
|
||||
while(target_mem_read32(t, FLASH_SR) & FLASH_SR_BSY)
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("stm32f4 flash erase: comm error\n");
|
||||
DEBUG_WARN("stm32f4 flash erase: comm error\n");
|
||||
return -1;
|
||||
}
|
||||
if (len > f->blocksize)
|
||||
|
@ -426,7 +426,7 @@ static int stm32f4_flash_erase(struct target_flash *f, target_addr addr,
|
|||
/* Check for error */
|
||||
sr = target_mem_read32(t, FLASH_SR);
|
||||
if(sr & SR_ERROR_MASK) {
|
||||
DEBUG("stm32f4 flash erase: sr error: 0x%" PRIu32 "\n", sr);
|
||||
DEBUG_WARN("stm32f4 flash erase: sr error: 0x%" PRIu32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -450,13 +450,13 @@ static int stm32f4_flash_write(struct target_flash *f,
|
|||
do {
|
||||
sr = target_mem_read32(t, FLASH_SR);
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("stm32f4 flash write: comm error\n");
|
||||
DEBUG_WARN("stm32f4 flash write: comm error\n");
|
||||
return -1;
|
||||
}
|
||||
} while (sr & FLASH_SR_BSY);
|
||||
|
||||
if (sr & SR_ERROR_MASK) {
|
||||
DEBUG("stm32f4 flash write error 0x%" PRIx32 "\n", sr);
|
||||
DEBUG_WARN("stm32f4 flash write error 0x%" PRIx32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2017-2018 Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de
|
||||
* Copyright (C) 2017-2020 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
|
||||
|
@ -165,7 +165,7 @@ static void stm32h7_add_flash(target *t,
|
|||
struct target_flash *f;
|
||||
|
||||
if (!sf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -288,19 +288,19 @@ static int stm32h7_flash_erase(struct target_flash *f, target_addr addr,
|
|||
target_mem_write32(t, sf->regbase + FLASH_CR, cr);
|
||||
cr |= FLASH_CR_START;
|
||||
target_mem_write32(t, sf->regbase + FLASH_CR, cr);
|
||||
DEBUG(" started cr %08" PRIx32 " sr %08" PRIx32 "\n",
|
||||
target_mem_read32(t, sf->regbase + FLASH_CR),
|
||||
target_mem_read32(t, sf->regbase + FLASH_SR));
|
||||
DEBUG_INFO(" started cr %08" PRIx32 " sr %08" PRIx32 "\n",
|
||||
target_mem_read32(t, sf->regbase + FLASH_CR),
|
||||
target_mem_read32(t, sf->regbase + FLASH_SR));
|
||||
do {
|
||||
sr = target_mem_read32(t, sf->regbase + FLASH_SR);
|
||||
if (target_check_error(t)) {
|
||||
DEBUG("stm32h7_flash_erase: comm failed\n");
|
||||
DEBUG_WARN("stm32h7_flash_erase: comm failed\n");
|
||||
return -1;
|
||||
}
|
||||
// target_mem_write32(t, H7_IWDG_BASE, 0x0000aaaa);
|
||||
}while (sr & (FLASH_SR_QW | FLASH_SR_BSY));
|
||||
if (sr & FLASH_SR_ERROR_MASK) {
|
||||
DEBUG("stm32h7_flash_erase: error, sr: %08" PRIx32 "\n", sr);
|
||||
DEBUG_WARN("stm32h7_flash_erase: error, sr: %08" PRIx32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
start_sector++;
|
||||
|
@ -326,12 +326,12 @@ static int stm32h7_flash_write(struct target_flash *f, target_addr dest,
|
|||
target_mem_write(t, dest, src, len);
|
||||
while ((sr = target_mem_read32(t, sr_reg)) & FLASH_SR_BSY) {
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("stm32h7_flash_write: BSY comm failed\n");
|
||||
DEBUG_WARN("stm32h7_flash_write: BSY comm failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (sr & FLASH_SR_ERROR_MASK) {
|
||||
DEBUG("stm32h7_flash_write: error sr %08" PRIx32 "\n", sr);
|
||||
DEBUG_WARN("stm32h7_flash_write: error sr %08" PRIx32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
/* Close write windows.*/
|
||||
|
@ -357,23 +357,23 @@ static bool stm32h7_cmd_erase(target *t, int bank_mask)
|
|||
/* Flash mass erase start instruction */
|
||||
if (do_bank1) {
|
||||
if (stm32h7_flash_unlock(t, BANK1_START) == false) {
|
||||
DEBUG("ME: Unlock bank1 failed\n");
|
||||
DEBUG_WARN("ME: Unlock bank1 failed\n");
|
||||
goto done;
|
||||
}
|
||||
uint32_t regbase = FPEC1_BASE;
|
||||
/* BER and start can be merged (3.3.10).*/
|
||||
target_mem_write32(t, regbase + FLASH_CR, cr);
|
||||
DEBUG("ME bank1 started\n");
|
||||
DEBUG_INFO("ME bank1 started\n");
|
||||
}
|
||||
if (do_bank2) {
|
||||
if (stm32h7_flash_unlock(t, BANK2_START) == false) {
|
||||
DEBUG("ME: Unlock bank2 failed\n");
|
||||
DEBUG_WARN("ME: Unlock bank2 failed\n");
|
||||
goto done;
|
||||
}
|
||||
uint32_t regbase = FPEC2_BASE;
|
||||
/* BER and start can be merged (3.3.10).*/
|
||||
target_mem_write32(t, regbase + FLASH_CR, cr);
|
||||
DEBUG("ME bank2 started\n");
|
||||
DEBUG_INFO("ME bank2 started\n");
|
||||
}
|
||||
|
||||
/* Read FLASH_SR to poll for QW bit */
|
||||
|
@ -383,7 +383,7 @@ static bool stm32h7_cmd_erase(target *t, int bank_mask)
|
|||
// target_mem_write32(t, H7_IWDG_BASE, 0x0000aaaa);
|
||||
tc_printf(t, "\b%c", spinner[spinindex++ % 4]);
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("ME bank1: comm failed\n");
|
||||
DEBUG_WARN("ME bank1: comm failed\n");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ static bool stm32h7_cmd_erase(target *t, int bank_mask)
|
|||
// target_mem_write32(t, H7_IWDG_BASE 0x0000aaaa);
|
||||
tc_printf(t, "\b%c", spinner[spinindex++ % 4]);
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("ME bank2: comm failed\n");
|
||||
DEBUG_WARN("ME bank2: comm failed\n");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ static bool stm32h7_cmd_erase(target *t, int bank_mask)
|
|||
uint32_t regbase = FPEC1_BASE;
|
||||
uint32_t sr = target_mem_read32(t, regbase + FLASH_SR);
|
||||
if (sr & FLASH_SR_ERROR_MASK) {
|
||||
DEBUG("ME bank1: sr %" PRIx32 "\n", sr);
|
||||
DEBUG_WARN("ME bank1, error sr %" PRIx32 "\n", sr);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ static bool stm32h7_cmd_erase(target *t, int bank_mask)
|
|||
uint32_t regbase = FPEC2_BASE;
|
||||
uint32_t sr = target_mem_read32(t, regbase + FLASH_SR);
|
||||
if (sr & FLASH_SR_ERROR_MASK) {
|
||||
DEBUG("ME bank2: sr %" PRIx32 "\n", sr);
|
||||
DEBUG_WARN("ME bank2, error: sr %" PRIx32 "\n", sr);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -467,13 +467,15 @@ static int stm32h7_crc_bank(target *t, uint32_t bank)
|
|||
target_mem_write32(t, regbase + FLASH_CRCCR, crccr);
|
||||
target_mem_write32(t, regbase + FLASH_CRCCR, crccr | FLASH_CRCCR_START_CRC);
|
||||
uint32_t sr;
|
||||
while ((sr = target_mem_read32(t, regbase + FLASH_SR)) & FLASH_SR_CRC_BUSY) {
|
||||
while ((sr = target_mem_read32(t, regbase + FLASH_SR)) &
|
||||
FLASH_SR_CRC_BUSY) {
|
||||
if(target_check_error(t)) {
|
||||
DEBUG("CRC bank %d: comm failed\n", (bank < BANK2_START) ? 1 : 2);
|
||||
DEBUG_WARN("CRC bank %d: comm failed\n",
|
||||
(bank < BANK2_START) ? 1 : 2);
|
||||
return -1;
|
||||
}
|
||||
if (sr & FLASH_SR_ERROR_READ) {
|
||||
DEBUG("CRC bank %d: error sr %08" PRIx32 "\n",
|
||||
DEBUG_WARN("CRC bank %d: error sr %08" PRIx32 "\n",
|
||||
(bank < BANK2_START) ? 1 : 2, sr);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ static void stm32l_add_flash(target *t,
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ static void stm32l_add_eeprom(target *t, uint32_t addr, size_t length)
|
|||
{
|
||||
struct target_flash *f = calloc(1, sizeof(*f));
|
||||
if (!f) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2015, 2017, 2018 Uwe Bonnes
|
||||
* Written by Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
|
||||
* Copyright (C) 2015, 2017 - 2020 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
|
||||
|
@ -262,7 +262,7 @@ static void stm32l4_add_flash(target *t,
|
|||
struct target_flash *f;
|
||||
|
||||
if (!sf) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -461,13 +461,13 @@ static int stm32l4_flash_write(struct target_flash *f,
|
|||
do {
|
||||
sr = target_mem_read32(t, FLASH_SR);
|
||||
if (target_check_error(t)) {
|
||||
DEBUG("stm32l4 flash write: comm error\n");
|
||||
DEBUG_WARN("stm32l4 flash write: comm error\n");
|
||||
return -1;
|
||||
}
|
||||
} while (sr & FLASH_SR_BSY);
|
||||
|
||||
if(sr & FLASH_SR_ERROR_MASK) {
|
||||
DEBUG("stm32l4 flash write error: sr 0x%" PRIu32 "\n", sr);
|
||||
DEBUG_WARN("stm32l4 flash write error: sr 0x%" PRIu32 "\n", sr);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -39,7 +39,7 @@ target *target_new(void)
|
|||
{
|
||||
target *t = (void*)calloc(1, sizeof(*t));
|
||||
if (!t) { /* calloc failed: heap exhaustion */
|
||||
DEBUG("calloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ void target_add_commands(target *t, const struct command_s *cmds, const char *na
|
|||
{
|
||||
struct target_command_s *tc = malloc(sizeof(*tc));
|
||||
if (!tc) { /* malloc failed: heap exhaustion */
|
||||
DEBUG("malloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("malloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ void target_add_ram(target *t, target_addr start, uint32_t len)
|
|||
{
|
||||
struct target_ram *ram = malloc(sizeof(*ram));
|
||||
if (!ram) { /* malloc failed: heap exhaustion */
|
||||
DEBUG("malloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("malloc: failed in %s\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ int target_flash_erase(target *t, target_addr addr, size_t len)
|
|||
while (len) {
|
||||
struct target_flash *f = flash_for_addr(t, addr);
|
||||
if (!f) {
|
||||
DEBUG("Erase stopped at 0x%06" PRIx32 "\n", addr);
|
||||
DEBUG_WARN("Erase stopped at 0x%06" PRIx32 "\n", addr);
|
||||
return ret;
|
||||
}
|
||||
size_t tmptarget = MIN(addr + len, f->start + f->length);
|
||||
|
@ -292,7 +292,7 @@ int target_flash_write_buffered(struct target_flash *f,
|
|||
/* Allocate flash sector buffer */
|
||||
f->buf = malloc(f->buf_size);
|
||||
if (!f->buf) { /* malloc failed: heap exhaustion */
|
||||
DEBUG("malloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("malloc: failed in %s\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
f->buf_addr = -1;
|
||||
|
@ -409,7 +409,7 @@ void target_set_cmdline(target *t, char *cmdline) {
|
|||
len_dst = sizeof(t->cmdline)-1;
|
||||
strncpy(t->cmdline, cmdline, len_dst -1);
|
||||
t->cmdline[strlen(t->cmdline)]='\0';
|
||||
DEBUG("cmdline: >%s<\n", t->cmdline);
|
||||
DEBUG_INFO("cmdline: >%s<\n", t->cmdline);
|
||||
}
|
||||
|
||||
/* Set heapinfo for semihosting */
|
||||
|
@ -440,7 +440,7 @@ int target_breakwatch_set(target *t,
|
|||
/* Success, make a heap copy */
|
||||
struct breakwatch *bwm = malloc(sizeof bw);
|
||||
if (!bwm) { /* malloc failed: heap exhaustion */
|
||||
DEBUG("malloc: failed in %s\n", __func__);
|
||||
DEBUG_WARN("malloc: failed in %s\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
memcpy(bwm, &bw, sizeof(bw));
|
||||
|
|
Loading…
Reference in New Issue