Make baudrate parameter of traceswo command mandatory for stlink/swlink, and superfluous on other platforms; change help message accordingly.

This commit is contained in:
Thiadmer Riemersma 2019-11-19 15:02:14 +01:00 committed by UweBonnes
parent e7e34600a4
commit 1924aa4999
6 changed files with 28 additions and 8 deletions

View File

@ -77,7 +77,11 @@ const struct command_s cmd_list[] = {
{"tpwr", (cmd_handler)cmd_target_power, "Supplies power to the target: (enable|disable)"},
#endif
#ifdef PLATFORM_HAS_TRACESWO
{"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture [(baudrate) for async swo]" },
#if defined TRACESWO_PROTOCOL && TRACESWO_PROTOCOL == 2
{"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture, NRZ mode: (baudrate)" },
#else
{"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture, Manchester mode" },
#endif
#endif
#if defined(PLATFORM_HAS_DEBUG) && !defined(PC_HOSTED)
{"debug_bmp", (cmd_handler)cmd_debug_bmp, "Output BMP \"debug\" strings to the second vcom: (enable|disable)"},
@ -356,13 +360,21 @@ static bool cmd_traceswo(target *t, int argc, const char **argv)
#else
extern char serial_no[9];
#endif
uint32_t baudrate = 0;
(void)t;
if (argc > 1)
baudrate = atoi(argv[1]);
traceswo_init(baudrate);
#if defined TRACESWO_PROTOCOL && TRACESWO_PROTOCOL == 2
if (argc > 1) {
uint32_t baudrate = atoi(argv[1]);
traceswo_init(baudrate);
} else {
gdb_outf("Missing baudrate parameter in command\n");
}
#else
(void)argv;
traceswo_init();
if (argc > 1) {
gdb_outf("Superfluous parameter(s) ignored\n");
}
#endif
gdb_outf("%s:%02X:%02X\n", serial_no, 5, 0x85);
return true;
}

View File

@ -22,7 +22,12 @@
#include <libopencm3/usb/usbd.h>
#if defined TRACESWO_PROTOCOL && TRACESWO_PROTOCOL == 2
void traceswo_init(uint32_t baudrate);
#else
void traceswo_init(void);
#endif
void trace_buf_drain(usbd_device *dev, uint8_t ep);
#endif

View File

@ -70,6 +70,7 @@
#define PLATFORM_HAS_TRACESWO 1
#define NUM_TRACE_PACKETS (128) /* This is an 8K buffer */
#define TRACESWO_PROTOCOL 2 /* 1 = Manchester, 2 = NRZ / async */
# define SWD_CR GPIO_CRH(SWDIO_PORT)
# define SWD_CR_MULT (1 << ((14 - 8) << 2))

View File

@ -33,6 +33,7 @@
*/
#include "general.h"
#include "cdcacm.h"
#include "traceswo.h"
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/timer.h>

View File

@ -30,7 +30,7 @@
#include "general.h"
#include "cdcacm.h"
#include "platform.h"
#include "traceswo.h"
#include <libopencmsis/core_cm3.h>
#include <libopencm3/cm3/nvic.h>

View File

@ -64,6 +64,7 @@
#define PLATFORM_HAS_TRACESWO 1
#define NUM_TRACE_PACKETS (128) /* This is an 8K buffer */
#define TRACESWO_PROTOCOL 2 /* 1 = Manchester, 2 = NRZ / async */
# define SWD_CR GPIO_CRH(SWDIO_PORT)
# define SWD_CR_MULT (1 << ((13 - 8) << 2))