2011-02-04 07:23:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Black Magic Debug project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
|
|
|
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This file implements a basic command interpreter for GDB 'monitor'
|
|
|
|
* commands.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "general.h"
|
2015-03-01 04:56:03 +00:00
|
|
|
#include "exception.h"
|
2011-02-04 07:23:52 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "gdb_packet.h"
|
|
|
|
#include "target.h"
|
2015-03-01 06:05:10 +00:00
|
|
|
#include "morse.h"
|
2015-04-04 03:21:33 +00:00
|
|
|
#include "version.h"
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2013-04-16 19:36:19 +00:00
|
|
|
#ifdef PLATFORM_HAS_TRACESWO
|
|
|
|
# include "traceswo.h"
|
|
|
|
#endif
|
|
|
|
|
2016-06-30 02:18:05 +00:00
|
|
|
typedef bool (*cmd_handler)(target *t, int argc, const char **argv);
|
|
|
|
|
|
|
|
struct command_s {
|
|
|
|
const char *cmd;
|
|
|
|
cmd_handler handler;
|
|
|
|
|
|
|
|
const char *help;
|
|
|
|
};
|
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
static bool cmd_version(target *t, int argc, char **argv);
|
|
|
|
static bool cmd_help(target *t, int argc, char **argv);
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2012-06-30 04:47:23 +00:00
|
|
|
static bool cmd_jtag_scan(target *t, int argc, char **argv);
|
2019-09-27 12:02:18 +00:00
|
|
|
static bool cmd_swdp_scan(target *t, int argc, char **argv);
|
|
|
|
static bool cmd_targets(target *t, int argc, char **argv);
|
|
|
|
static bool cmd_morse(target *t, int argc, char **argv);
|
2018-06-13 10:50:04 +00:00
|
|
|
static bool cmd_halt_timeout(target *t, int argc, const char **argv);
|
2018-09-10 21:11:24 +00:00
|
|
|
static bool cmd_connect_srst(target *t, int argc, const char **argv);
|
2019-09-27 12:02:18 +00:00
|
|
|
static bool cmd_hard_srst(target *t, int argc, const char **argv);
|
2014-08-08 08:22:33 +00:00
|
|
|
#ifdef PLATFORM_HAS_POWER_SWITCH
|
2014-04-11 17:35:55 +00:00
|
|
|
static bool cmd_target_power(target *t, int argc, const char **argv);
|
2014-08-08 08:22:33 +00:00
|
|
|
#endif
|
2012-05-26 03:05:37 +00:00
|
|
|
#ifdef PLATFORM_HAS_TRACESWO
|
2017-10-26 13:11:55 +00:00
|
|
|
static bool cmd_traceswo(target *t, int argc, const char **argv);
|
2012-05-26 03:05:37 +00:00
|
|
|
#endif
|
2020-04-30 14:33:38 +00:00
|
|
|
static bool cmd_heapinfo(target *t, int argc, const char **argv);
|
2019-08-20 10:28:36 +00:00
|
|
|
#if defined(PLATFORM_HAS_DEBUG) && !defined(PC_HOSTED)
|
2016-06-18 08:26:56 +00:00
|
|
|
static bool cmd_debug_bmp(target *t, int argc, const char **argv);
|
|
|
|
#endif
|
2012-04-17 09:40:39 +00:00
|
|
|
|
2011-02-04 07:23:52 +00:00
|
|
|
const struct command_s cmd_list[] = {
|
|
|
|
{"version", (cmd_handler)cmd_version, "Display firmware version info"},
|
|
|
|
{"help", (cmd_handler)cmd_help, "Display help for monitor commands"},
|
|
|
|
{"jtag_scan", (cmd_handler)cmd_jtag_scan, "Scan JTAG chain for devices" },
|
|
|
|
{"swdp_scan", (cmd_handler)cmd_swdp_scan, "Scan SW-DP for devices" },
|
|
|
|
{"targets", (cmd_handler)cmd_targets, "Display list of available targets" },
|
|
|
|
{"morse", (cmd_handler)cmd_morse, "Display morse error message" },
|
2018-06-13 10:50:04 +00:00
|
|
|
{"halt_timeout", (cmd_handler)cmd_halt_timeout, "Timeout (ms) to wait until Cortex-M is halted: (Default 2000)" },
|
2018-09-10 21:11:24 +00:00
|
|
|
{"connect_srst", (cmd_handler)cmd_connect_srst, "Configure connect under SRST: (enable|disable)" },
|
2016-06-09 21:51:31 +00:00
|
|
|
{"hard_srst", (cmd_handler)cmd_hard_srst, "Force a pulse on the hard SRST line - disconnects target" },
|
2014-08-08 08:22:33 +00:00
|
|
|
#ifdef PLATFORM_HAS_POWER_SWITCH
|
2014-04-11 17:35:55 +00:00
|
|
|
{"tpwr", (cmd_handler)cmd_target_power, "Supplies power to the target: (enable|disable)"},
|
2014-08-08 08:22:33 +00:00
|
|
|
#endif
|
2012-05-26 03:05:37 +00:00
|
|
|
#ifdef PLATFORM_HAS_TRACESWO
|
2019-11-19 14:02:14 +00:00
|
|
|
#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
|
2016-06-18 08:26:56 +00:00
|
|
|
#endif
|
2020-04-30 14:33:38 +00:00
|
|
|
{"heapinfo", (cmd_handler)cmd_heapinfo, "Set semihosting heapinfo" },
|
2019-08-20 10:28:36 +00:00
|
|
|
#if defined(PLATFORM_HAS_DEBUG) && !defined(PC_HOSTED)
|
2016-06-18 08:26:56 +00:00
|
|
|
{"debug_bmp", (cmd_handler)cmd_debug_bmp, "Output BMP \"debug\" strings to the second vcom: (enable|disable)"},
|
2012-05-26 03:05:37 +00:00
|
|
|
#endif
|
2011-02-04 07:23:52 +00:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2019-09-04 11:09:43 +00:00
|
|
|
bool connect_assert_srst;
|
|
|
|
#if defined(PLATFORM_HAS_DEBUG) && !defined(PC_HOSTED)
|
2016-06-18 08:26:56 +00:00
|
|
|
bool debug_bmp;
|
|
|
|
#endif
|
2018-06-13 10:50:04 +00:00
|
|
|
long cortexm_wait_timeout = 2000; /* Timeout to wait for Cortex to react on halt command. */
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2012-06-27 09:26:08 +00:00
|
|
|
int command_process(target *t, char *cmd)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
|
|
|
const struct command_s *c;
|
2019-10-18 20:59:02 +00:00
|
|
|
int argc = 1;
|
2011-02-04 07:23:52 +00:00
|
|
|
const char **argv;
|
2019-10-18 20:59:02 +00:00
|
|
|
const char *part;
|
2011-02-04 07:23:52 +00:00
|
|
|
|
|
|
|
/* Initial estimate for argc */
|
2013-06-17 03:53:32 +00:00
|
|
|
for(char *s = cmd; *s; s++)
|
2011-02-04 07:23:52 +00:00
|
|
|
if((*s == ' ') || (*s == '\t')) argc++;
|
|
|
|
|
|
|
|
argv = alloca(sizeof(const char *) * argc);
|
|
|
|
|
|
|
|
/* Tokenize cmd to find argv */
|
2019-10-18 20:59:02 +00:00
|
|
|
argc = 0;
|
|
|
|
for (part = strtok(cmd, " \t"); part; part = strtok(NULL, " \t"))
|
|
|
|
argv[argc++] = part;
|
2011-02-04 07:23:52 +00:00
|
|
|
|
|
|
|
/* Look for match and call handler */
|
|
|
|
for(c = cmd_list; c->cmd; c++) {
|
2012-02-11 23:02:50 +00:00
|
|
|
/* Accept a partial match as GDB does.
|
2013-06-17 03:53:32 +00:00
|
|
|
* So 'mon ver' will match 'monitor version'
|
2012-02-11 23:02:50 +00:00
|
|
|
*/
|
2016-06-30 02:18:05 +00:00
|
|
|
if ((argc == 0) || !strncmp(argv[0], c->cmd, strlen(argv[0])))
|
2012-06-27 09:26:08 +00:00
|
|
|
return !c->handler(t, argc, argv);
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2012-06-27 09:26:08 +00:00
|
|
|
if (!t)
|
2012-06-26 07:48:50 +00:00
|
|
|
return -1;
|
|
|
|
|
2016-06-30 02:18:05 +00:00
|
|
|
return target_command(t, argc, argv);
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
bool cmd_version(target *t, int argc, char **argv)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
2019-09-27 12:02:18 +00:00
|
|
|
(void)t;
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2019-08-20 15:56:25 +00:00
|
|
|
#if defined PC_HOSTED
|
|
|
|
gdb_outf("Black Magic Probe, PC-Hosted for " PLATFORM_IDENT
|
|
|
|
", Version " FIRMWARE_VERSION "\n");
|
|
|
|
#else
|
2016-02-15 06:41:51 +00:00
|
|
|
gdb_outf("Black Magic Probe (Firmware " FIRMWARE_VERSION ") (Hardware Version %d)\n", platform_hwversion());
|
2019-08-20 15:56:25 +00:00
|
|
|
#endif
|
2015-04-04 03:21:33 +00:00
|
|
|
gdb_out("Copyright (C) 2015 Black Sphere Technologies Ltd.\n");
|
2011-02-05 02:12:24 +00:00
|
|
|
gdb_out("License GPLv3+: GNU GPL version 3 or later "
|
|
|
|
"<http://gnu.org/licenses/gpl.html>\n\n");
|
2012-06-24 09:37:10 +00:00
|
|
|
|
|
|
|
return true;
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
bool cmd_help(target *t, int argc, char **argv)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
2019-09-27 12:02:18 +00:00
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2011-02-04 07:23:52 +00:00
|
|
|
const struct command_s *c;
|
|
|
|
|
2012-06-24 09:37:10 +00:00
|
|
|
gdb_out("General commands:\n");
|
2013-06-17 03:53:32 +00:00
|
|
|
for(c = cmd_list; c->cmd; c++)
|
2012-06-24 09:37:10 +00:00
|
|
|
gdb_outf("\t%s -- %s\n", c->cmd, c->help);
|
|
|
|
|
2012-06-27 09:26:08 +00:00
|
|
|
if (!t)
|
2012-06-26 07:48:50 +00:00
|
|
|
return -1;
|
|
|
|
|
2016-06-30 02:18:05 +00:00
|
|
|
target_command_help(t);
|
2012-06-24 09:37:10 +00:00
|
|
|
|
|
|
|
return true;
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2012-06-30 04:47:23 +00:00
|
|
|
static bool cmd_jtag_scan(target *t, int argc, char **argv)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
2012-06-30 04:47:23 +00:00
|
|
|
(void)t;
|
2015-03-01 04:56:03 +00:00
|
|
|
uint8_t irlens[argc];
|
2012-06-30 04:47:23 +00:00
|
|
|
|
2012-05-23 09:44:39 +00:00
|
|
|
gdb_outf("Target voltage: %s\n", platform_target_voltage());
|
|
|
|
|
2012-06-30 04:47:23 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
/* Accept a list of IR lengths on command line */
|
|
|
|
for (int i = 1; i < argc; i++)
|
|
|
|
irlens[i-1] = atoi(argv[i]);
|
|
|
|
irlens[argc-1] = 0;
|
|
|
|
}
|
|
|
|
|
2018-09-10 21:11:24 +00:00
|
|
|
if(connect_assert_srst)
|
|
|
|
platform_srst_set_val(true); /* will be deasserted after attach */
|
2016-04-19 19:44:57 +00:00
|
|
|
|
2015-03-01 04:56:03 +00:00
|
|
|
int devs = -1;
|
|
|
|
volatile struct exception e;
|
|
|
|
TRY_CATCH (e, EXCEPTION_ALL) {
|
|
|
|
devs = jtag_scan(argc > 1 ? irlens : NULL);
|
|
|
|
}
|
|
|
|
switch (e.type) {
|
|
|
|
case EXCEPTION_TIMEOUT:
|
|
|
|
gdb_outf("Timeout during scan. Is target stuck in WFI?\n");
|
|
|
|
break;
|
|
|
|
case EXCEPTION_ERROR:
|
|
|
|
gdb_outf("Exception: %s\n", e.msg);
|
|
|
|
break;
|
|
|
|
}
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2016-04-19 19:44:57 +00:00
|
|
|
if(devs <= 0) {
|
|
|
|
platform_srst_set_val(false);
|
2011-02-04 07:23:52 +00:00
|
|
|
gdb_out("JTAG device scan failed!\n");
|
2012-06-24 09:37:10 +00:00
|
|
|
return false;
|
2013-06-17 03:53:32 +00:00
|
|
|
}
|
2019-09-27 12:02:18 +00:00
|
|
|
cmd_targets(NULL, 0, NULL);
|
2016-09-29 05:15:15 +00:00
|
|
|
morse(NULL, false);
|
2012-06-24 09:37:10 +00:00
|
|
|
return true;
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
bool cmd_swdp_scan(target *t, int argc, char **argv)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
2019-09-27 12:02:18 +00:00
|
|
|
(void)t;
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2012-05-23 09:44:39 +00:00
|
|
|
gdb_outf("Target voltage: %s\n", platform_target_voltage());
|
|
|
|
|
2018-09-10 21:11:24 +00:00
|
|
|
if(connect_assert_srst)
|
|
|
|
platform_srst_set_val(true); /* will be deasserted after attach */
|
2016-04-19 19:44:57 +00:00
|
|
|
|
2015-03-01 04:56:03 +00:00
|
|
|
int devs = -1;
|
|
|
|
volatile struct exception e;
|
|
|
|
TRY_CATCH (e, EXCEPTION_ALL) {
|
|
|
|
devs = adiv5_swdp_scan();
|
|
|
|
}
|
|
|
|
switch (e.type) {
|
|
|
|
case EXCEPTION_TIMEOUT:
|
|
|
|
gdb_outf("Timeout during scan. Is target stuck in WFI?\n");
|
|
|
|
break;
|
|
|
|
case EXCEPTION_ERROR:
|
|
|
|
gdb_outf("Exception: %s\n", e.msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-19 19:44:57 +00:00
|
|
|
if(devs <= 0) {
|
|
|
|
platform_srst_set_val(false);
|
2011-02-04 07:23:52 +00:00
|
|
|
gdb_out("SW-DP scan failed!\n");
|
2012-06-24 09:37:10 +00:00
|
|
|
return false;
|
2013-06-17 03:53:32 +00:00
|
|
|
}
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
cmd_targets(NULL, 0, NULL);
|
2016-09-29 05:15:15 +00:00
|
|
|
morse(NULL, false);
|
2012-06-24 09:37:10 +00:00
|
|
|
return true;
|
2013-06-17 03:53:32 +00:00
|
|
|
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2016-06-30 00:04:39 +00:00
|
|
|
static void display_target(int i, target *t, void *context)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
2016-06-30 00:04:39 +00:00
|
|
|
(void)context;
|
2019-06-25 12:11:52 +00:00
|
|
|
gdb_outf("%2d %c %s %s\n", i, target_attached(t)?'*':' ',
|
2019-07-18 15:10:48 +00:00
|
|
|
target_driver_name(t),
|
|
|
|
(target_core_name(t)) ? target_core_name(t): "");
|
2016-06-30 00:04:39 +00:00
|
|
|
}
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
bool cmd_targets(target *t, int argc, char **argv)
|
2016-06-30 00:04:39 +00:00
|
|
|
{
|
2019-09-27 12:02:18 +00:00
|
|
|
(void)t;
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2016-06-30 00:04:39 +00:00
|
|
|
gdb_out("Available Targets:\n");
|
|
|
|
gdb_out("No. Att Driver\n");
|
|
|
|
if (!target_foreach(display_target, NULL)) {
|
2011-02-04 07:23:52 +00:00
|
|
|
gdb_out("No usable targets found.\n");
|
2012-06-24 09:37:10 +00:00
|
|
|
return false;
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
2013-06-17 03:53:32 +00:00
|
|
|
|
2012-06-24 09:37:10 +00:00
|
|
|
return true;
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
bool cmd_morse(target *t, int argc, char **argv)
|
2011-02-04 07:23:52 +00:00
|
|
|
{
|
2019-09-27 12:02:18 +00:00
|
|
|
(void)t;
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2013-06-17 03:53:32 +00:00
|
|
|
if(morse_msg)
|
2011-02-04 07:23:52 +00:00
|
|
|
gdb_outf("%s\n", morse_msg);
|
2012-06-24 09:37:10 +00:00
|
|
|
return true;
|
2011-02-04 07:23:52 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 19:30:37 +00:00
|
|
|
bool parse_enable_or_disable(const char *s, bool *out) {
|
|
|
|
if (strlen(s) == 0) {
|
|
|
|
gdb_outf("'enable' or 'disable' argument must be provided\n");
|
|
|
|
return false;
|
|
|
|
} else if (!strncmp(s, "enable", strlen(s))) {
|
|
|
|
*out = true;
|
|
|
|
return true;
|
|
|
|
} else if (!strncmp(s, "disable", strlen(s))) {
|
|
|
|
*out = false;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
gdb_outf("Argument '%s' not recognized as 'enable' or 'disable'\n", s);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-10 21:11:24 +00:00
|
|
|
static bool cmd_connect_srst(target *t, int argc, const char **argv)
|
2013-05-04 20:46:47 +00:00
|
|
|
{
|
|
|
|
(void)t;
|
2019-03-19 19:30:37 +00:00
|
|
|
bool print_status = false;
|
|
|
|
if (argc == 1) {
|
|
|
|
print_status = true;
|
|
|
|
} else if (argc == 2) {
|
|
|
|
if (parse_enable_or_disable(argv[1], &connect_assert_srst)) {
|
|
|
|
print_status = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gdb_outf("Unrecognized command format\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_status) {
|
2018-09-10 21:11:24 +00:00
|
|
|
gdb_outf("Assert SRST during connect: %s\n",
|
|
|
|
connect_assert_srst ? "enabled" : "disabled");
|
2019-03-19 19:30:37 +00:00
|
|
|
}
|
2013-05-04 20:46:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-08-08 08:22:33 +00:00
|
|
|
|
2018-06-13 10:50:04 +00:00
|
|
|
static bool cmd_halt_timeout(target *t, int argc, const char **argv)
|
|
|
|
{
|
|
|
|
(void)t;
|
|
|
|
if (argc > 1)
|
|
|
|
cortexm_wait_timeout = atol(argv[1]);
|
|
|
|
gdb_outf("Cortex-M timeout to wait for device haltes: %d\n",
|
|
|
|
cortexm_wait_timeout);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-27 12:02:18 +00:00
|
|
|
static bool cmd_hard_srst(target *t, int argc, const char **argv)
|
2016-06-09 21:51:31 +00:00
|
|
|
{
|
2019-09-27 12:02:18 +00:00
|
|
|
(void)t;
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2016-06-09 21:51:31 +00:00
|
|
|
target_list_free();
|
|
|
|
platform_srst_set_val(true);
|
|
|
|
platform_srst_set_val(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-08 08:22:33 +00:00
|
|
|
#ifdef PLATFORM_HAS_POWER_SWITCH
|
2014-04-11 17:35:55 +00:00
|
|
|
static bool cmd_target_power(target *t, int argc, const char **argv)
|
|
|
|
{
|
|
|
|
(void)t;
|
2019-03-19 19:30:37 +00:00
|
|
|
if (argc == 1) {
|
2014-04-11 17:35:55 +00:00
|
|
|
gdb_outf("Target Power: %s\n",
|
2015-03-01 05:23:24 +00:00
|
|
|
platform_target_get_power() ? "enabled" : "disabled");
|
2019-03-19 19:30:37 +00:00
|
|
|
} else if (argc == 2) {
|
|
|
|
bool want_enable = false;
|
|
|
|
if (parse_enable_or_disable(argv[1], &want_enable)) {
|
|
|
|
platform_target_set_power(want_enable);
|
|
|
|
gdb_outf("%s target power\n", want_enable ? "Enabling" : "Disabling");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gdb_outf("Unrecognized command format\n");
|
|
|
|
}
|
2014-04-11 17:35:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-08-08 08:22:33 +00:00
|
|
|
#endif
|
2013-05-04 20:46:47 +00:00
|
|
|
|
2012-05-26 03:05:37 +00:00
|
|
|
#ifdef PLATFORM_HAS_TRACESWO
|
2017-10-26 13:11:55 +00:00
|
|
|
static bool cmd_traceswo(target *t, int argc, const char **argv)
|
2012-04-17 09:40:39 +00:00
|
|
|
{
|
2017-10-26 13:11:55 +00:00
|
|
|
#if defined(STM32L0) || defined(STM32F3) || defined(STM32F4)
|
|
|
|
extern char serial_no[13];
|
|
|
|
#else
|
2012-04-22 00:22:08 +00:00
|
|
|
extern char serial_no[9];
|
2017-10-26 13:11:55 +00:00
|
|
|
#endif
|
|
|
|
(void)t;
|
2019-11-19 14:02:14 +00:00
|
|
|
#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
|
2012-04-22 00:22:08 +00:00
|
|
|
gdb_outf("%s:%02X:%02X\n", serial_no, 5, 0x85);
|
2012-06-24 09:37:10 +00:00
|
|
|
return true;
|
2012-04-17 09:40:39 +00:00
|
|
|
}
|
2012-05-26 03:05:37 +00:00
|
|
|
#endif
|
2011-02-04 07:23:52 +00:00
|
|
|
|
2019-08-20 10:28:36 +00:00
|
|
|
#if defined(PLATFORM_HAS_DEBUG) && !defined(PC_HOSTED)
|
2016-06-18 08:26:56 +00:00
|
|
|
static bool cmd_debug_bmp(target *t, int argc, const char **argv)
|
|
|
|
{
|
|
|
|
(void)t;
|
2019-03-19 19:30:37 +00:00
|
|
|
bool print_status = false;
|
|
|
|
if (argc == 1) {
|
|
|
|
print_status = true;
|
|
|
|
} else if (argc == 2) {
|
|
|
|
if (parse_enable_or_disable(argv[1], &debug_bmp)) {
|
|
|
|
print_status = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gdb_outf("Unrecognized command format\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_status) {
|
|
|
|
gdb_outf("Debug mode is %s\n",
|
|
|
|
debug_bmp ? "enabled" : "disabled");
|
2016-06-18 08:26:56 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2020-04-30 14:33:38 +00:00
|
|
|
static bool cmd_heapinfo(target *t, int argc, const char **argv)
|
|
|
|
{
|
|
|
|
if (t == NULL) gdb_out("not attached\n");
|
|
|
|
else if (argc == 5) {
|
|
|
|
target_addr heap_base = strtoul(argv[1], NULL, 16);
|
|
|
|
target_addr heap_limit = strtoul(argv[2], NULL, 16);
|
|
|
|
target_addr stack_base = strtoul(argv[3], NULL, 16);
|
|
|
|
target_addr stack_limit = strtoul(argv[4], NULL, 16);
|
|
|
|
gdb_outf("heapinfo heap_base: %p heap_limit: %p stack_base: %p stack_limit: %p\n",
|
|
|
|
heap_base, heap_limit, stack_base, stack_limit);
|
|
|
|
target_set_heapinfo(t, heap_base, heap_limit, stack_base, stack_limit);
|
|
|
|
} else gdb_outf("heapinfo heap_base heap_limit stack_base stack_limit\n");
|
|
|
|
return true;
|
|
|
|
}
|