Merge pull request #138 from esden/debug_strings
Added black magic verbose/debug mode switch.
This commit is contained in:
commit
dcff9f9186
|
@ -1,6 +1,7 @@
|
|||
PROBE_HOST ?= native
|
||||
PLATFORM_DIR = platforms/$(PROBE_HOST)
|
||||
VPATH += platforms/common $(PLATFORM_DIR)
|
||||
ENABLE_DEBUG ?=
|
||||
|
||||
ifneq ($(V), 1)
|
||||
MAKEFLAGS += --no-print-dir
|
||||
|
@ -11,7 +12,11 @@ OPT_FLAGS ?= -O2
|
|||
|
||||
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts\
|
||||
$(OPT_FLAGS) -std=gnu99 -g3 -MD \
|
||||
-I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR) \
|
||||
-I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR)
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
CFLAGS += -DENABLE_DEBUG
|
||||
endif
|
||||
|
||||
SRC = \
|
||||
adiv5.c \
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "jtagtap.h"
|
||||
#include "command.h"
|
||||
#include "morse.h"
|
||||
#include "gdb_packet.h"
|
||||
|
||||
#define SWDP_ACK_OK 0x01
|
||||
#define SWDP_ACK_WAIT 0x02
|
||||
|
|
|
@ -50,6 +50,9 @@ static bool cmd_target_power(target *t, int argc, const char **argv);
|
|||
#ifdef PLATFORM_HAS_TRACESWO
|
||||
static bool cmd_traceswo(void);
|
||||
#endif
|
||||
#ifdef PLATFORM_HAS_DEBUG
|
||||
static bool cmd_debug_bmp(target *t, int argc, const char **argv);
|
||||
#endif
|
||||
|
||||
const struct command_s cmd_list[] = {
|
||||
{"version", (cmd_handler)cmd_version, "Display firmware version info"},
|
||||
|
@ -64,11 +67,17 @@ const struct command_s cmd_list[] = {
|
|||
#endif
|
||||
#ifdef PLATFORM_HAS_TRACESWO
|
||||
{"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture" },
|
||||
#endif
|
||||
#ifdef PLATFORM_HAS_DEBUG
|
||||
{"debug_bmp", (cmd_handler)cmd_debug_bmp, "Output BMP \"debug\" strings to the second vcom: (enable|disable)"},
|
||||
#endif
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static bool connect_assert_srst;
|
||||
#ifdef PLATFORM_HAS_DEBUG
|
||||
bool debug_bmp;
|
||||
#endif
|
||||
|
||||
int command_process(target *t, char *cmd)
|
||||
{
|
||||
|
@ -276,3 +285,15 @@ static bool cmd_traceswo(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_HAS_DEBUG
|
||||
static bool cmd_debug_bmp(target *t, int argc, const char **argv)
|
||||
{
|
||||
(void)t;
|
||||
if (argc > 1) {
|
||||
debug_bmp = !strcmp(argv[1], "enable");
|
||||
}
|
||||
gdb_outf("Debug mode is %s\n",
|
||||
debug_bmp ? "enabled" : "disabled");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
#define PLATFORM_HAS_TRACESWO
|
||||
#define PLATFORM_HAS_POWER_SWITCH
|
||||
#ifdef ENABLE_DEBUG
|
||||
#define PLATFORM_HAS_DEBUG
|
||||
#define USBUART_DEBUG
|
||||
#endif
|
||||
#define BOARD_IDENT "Black Magic Probe"
|
||||
#define BOARD_IDENT_DFU "Black Magic Probe (Upgrade)"
|
||||
#define BOARD_IDENT_UPD "Black Magic Probe (DFU Upgrade)"
|
||||
|
@ -142,7 +146,14 @@
|
|||
#define TRACE_IRQ NVIC_TIM3_IRQ
|
||||
#define TRACE_ISR tim3_isr
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
extern bool debug_bmp;
|
||||
void usbuart_debug_outf(const char *fmt, ...);
|
||||
|
||||
#define DEBUG(...) if (debug_bmp) {usbuart_debug_outf("bmp: ");usbuart_debug_outf(__VA_ARGS__);}
|
||||
#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);}
|
||||
|
@ -155,4 +166,3 @@
|
|||
#define vasprintf vasiprintf
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
#include "gdb_packet.h"
|
||||
|
||||
int jtagtap_init(void)
|
||||
{
|
||||
|
@ -60,7 +61,7 @@ inline uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDO)
|
|||
ret = gpio_get(TDO_PORT, TDO_PIN);
|
||||
gpio_clear(TCK_PORT, TCK_PIN);
|
||||
|
||||
DEBUG("jtagtap_next(TMS = %d, TDO = %d) = %d\n", dTMS, dTDO, ret);
|
||||
//DEBUG("jtagtap_next(TMS = %d, TDO = %d) = %d\n", dTMS, dTDO, ret);
|
||||
|
||||
return ret != 0;
|
||||
}
|
||||
|
|
|
@ -192,6 +192,47 @@ void usbuart_usb_out_cb(usbd_device *dev, uint8_t ep)
|
|||
gpio_clear(LED_PORT_UART, LED_UART);
|
||||
}
|
||||
|
||||
#ifdef USBUART_DEBUG
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Function to output debug data to usbuart port (ttyACM1 on linux) */
|
||||
void usbuart_debug_outf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *buf, *tmp;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (vasprintf(&buf, fmt, ap) < 0)
|
||||
return;
|
||||
tmp = buf;
|
||||
while( *tmp != 0 )
|
||||
{
|
||||
if( *tmp == '\n' && *(tmp-1) != '\r' )
|
||||
{
|
||||
/* insert into FIFO */
|
||||
buf_rx[buf_rx_in++] = '\r';
|
||||
|
||||
/* wrap out pointer */
|
||||
if (buf_rx_in >= FIFO_SIZE)
|
||||
{
|
||||
buf_rx_in = 0;
|
||||
}
|
||||
}
|
||||
/* insert into FIFO */
|
||||
buf_rx[buf_rx_in++] = *(tmp++);
|
||||
|
||||
/* wrap out pointer */
|
||||
if (buf_rx_in >= FIFO_SIZE)
|
||||
{
|
||||
buf_rx_in = 0;
|
||||
}
|
||||
}
|
||||
/* enable deferred processing if we put data in the FIFO */
|
||||
timer_enable_irq(USBUSART_TIM, TIM_DIER_UIE);
|
||||
free(buf);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
void usbuart_usb_in_cb(usbd_device *dev, uint8_t ep)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue