'-n' in st-util will cause it to skip the reset step, and thus allow you
to begin debugging at whatever point the code may currently be at.
Adding this feature required changing the stlink_open functions to
accept a reset flag that tells them whether or not to reset after
connecting. Skipping reset does not seem to have any adverse effects on
stlink usb devices. Unfortunately, I have to stlink v1 devices to test.
if (o.devname != NULL) /* stlinkv1 */
{
if (o.devname != NULL) /* stlinkv1 */
{
- sl = stlink_v1_open(50);
+ sl = stlink_v1_open(50, 1);
if (sl == NULL) goto on_error;
sl->verbose = 50;
}
else /* stlinkv2 */
{
if (sl == NULL) goto on_error;
sl->verbose = 50;
}
else /* stlinkv2 */
{
- sl = stlink_open_usb(50);
+ sl = stlink_open_usb(50, 1);
if (sl == NULL) goto on_error;
sl->verbose = 50;
}
if (sl == NULL) goto on_error;
sl->verbose = 50;
}
int logging_level;
int listen_port;
int persistent;
int logging_level;
int listen_port;
int persistent;
{"stlinkv1", no_argument, NULL, '1'},
{"listen_port", required_argument, NULL, 'p'},
{"multi", optional_argument, NULL, 'm'},
{"stlinkv1", no_argument, NULL, '1'},
{"listen_port", required_argument, NULL, 'p'},
{"multi", optional_argument, NULL, 'm'},
+ {"no-reset", optional_argument, NULL, 'n'},
{0, 0, 0, 0},
};
const char * help_str = "%s - usage:\n\n"
{0, 0, 0, 0},
};
const char * help_str = "%s - usage:\n\n"
" -m, --multi\n"
"\t\t\tSet gdb server to extended mode.\n"
"\t\t\tst-util will continue listening for connections after disconnect.\n"
" -m, --multi\n"
"\t\t\tSet gdb server to extended mode.\n"
"\t\t\tst-util will continue listening for connections after disconnect.\n"
+ " -n, --no-reset\n"
+ "\t\t\tDo not reset board on connection.\n"
;
int option_index = 0;
int c;
int q;
;
int option_index = 0;
int c;
int q;
- while ((c = getopt_long(argc, argv, "hv::d:s:1p:m", long_options, &option_index)) != -1) {
+ while ((c = getopt_long(argc, argv, "hv::d:s:1p:mn", long_options, &option_index)) != -1) {
switch (c) {
case 0:
printf("XXXXX Shouldn't really normally come here, only if there's no corresponding option\n");
switch (c) {
case 0:
printf("XXXXX Shouldn't really normally come here, only if there's no corresponding option\n");
case 'm':
st->persistent = 1;
break;
case 'm':
st->persistent = 1;
break;
+ case 'n':
+ st->reset = 0;
+ break;
state.stlink_version = 2;
state.logging_level = DEFAULT_LOGGING_LEVEL;
state.listen_port = DEFAULT_GDB_LISTEN_PORT;
state.stlink_version = 2;
state.logging_level = DEFAULT_LOGGING_LEVEL;
state.listen_port = DEFAULT_GDB_LISTEN_PORT;
+ state.reset = 1; /* By default, reset board */
parse_options(argc, argv, &state);
switch (state.stlink_version) {
case 2:
parse_options(argc, argv, &state);
switch (state.stlink_version) {
case 2:
- sl = stlink_open_usb(state.logging_level);
+ sl = stlink_open_usb(state.logging_level, 0);
if(sl == NULL) return 1;
break;
case 1:
if(sl == NULL) return 1;
break;
case 1:
- sl = stlink_v1_open(state.logging_level);
+ sl = stlink_v1_open(state.logging_level, 0);
if(sl == NULL) return 1;
break;
}
if(sl == NULL) return 1;
break;
}
signal(SIGINT, &cleanup);
signal(SIGTERM, &cleanup);
signal(SIGINT, &cleanup);
signal(SIGTERM, &cleanup);
+ if (state.reset) {
+ stlink_reset(sl);
+ }
+
printf("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id);
sl->verbose=0;
printf("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id);
sl->verbose=0;
+
+ /* Continue */
+ stlink_run(sl);
} while (state.persistent);
#ifdef __MINGW32__
} while (state.persistent);
#ifdef __MINGW32__
#endif
/* Switch back to mass storage mode before closing. */
#endif
/* Switch back to mass storage mode before closing. */
stlink_exit_debug_mode(sl);
stlink_close(sl);
stlink_exit_debug_mode(sl);
stlink_close(sl);
- stlink_force_debug(sl);
- stlink_reset(sl);
- init_code_breakpoints(sl);
- init_data_watchpoints(sl);
-
printf("Listening at *:%d...\n", st->listen_port);
int client = accept(sock, NULL, NULL);
printf("Listening at *:%d...\n", st->listen_port);
int client = accept(sock, NULL, NULL);
+ stlink_force_debug(sl);
+ if (st->reset) {
+ stlink_reset(sl);
+ }
+ init_code_breakpoints(sl);
+ init_data_watchpoints(sl);
+
printf("GDB connected.\n");
/*
printf("GDB connected.\n");
/*
/* unused */
ac = ac;
av = av;
/* unused */
ac = ac;
av = av;
- sl = stlink_open_usb(10);
+ sl = stlink_open_usb(10, 1);
if (sl != NULL) {
printf("ST-Linky proof-of-concept terminal :: Created by Necromant for lulz\n");
stlink_version(sl);
if (sl != NULL) {
printf("ST-Linky proof-of-concept terminal :: Created by Necromant for lulz\n");
stlink_version(sl);
-stlink_t* stlink_v1_open(const int verbose) {
+stlink_t* stlink_v1_open(const int verbose, int reset) {
stlink_t *sl = stlink_v1_open_inner(verbose);
if (sl == NULL) {
fputs("Error: could not open stlink device\n", stderr);
stlink_t *sl = stlink_v1_open_inner(verbose);
if (sl == NULL) {
fputs("Error: could not open stlink device\n", stderr);
// by now, it _must_ be fully open and in a useful mode....
stlink_enter_swd_mode(sl);
/* Now we are ready to read the parameters */
// by now, it _must_ be fully open and in a useful mode....
stlink_enter_swd_mode(sl);
/* Now we are ready to read the parameters */
+ if (reset) {
+ stlink_reset(sl);
+ }
stlink_load_device_params(sl);
ILOG("Successfully opened a stlink v1 debugger\n");
return sl;
stlink_load_device_params(sl);
ILOG("Successfully opened a stlink v1 debugger\n");
return sl;
- stlink_t* stlink_v1_open(const int verbose);
+ stlink_t* stlink_v1_open(const int verbose, int reset);
-stlink_t* stlink_open_usb(const int verbose) {
+stlink_t* stlink_open_usb(const int verbose, int reset) {
stlink_t* sl = NULL;
struct stlink_libusb* slu = NULL;
int error = -1;
stlink_t* sl = NULL;
struct stlink_libusb* slu = NULL;
int error = -1;
stlink_enter_swd_mode(sl);
}
stlink_enter_swd_mode(sl);
}
+ if (reset) {
+ stlink_reset(sl);
+ }
stlink_load_device_params(sl);
stlink_version(sl);
stlink_load_device_params(sl);
stlink_version(sl);
- stlink_t* stlink_open_usb(const int verbose);
+ stlink_t* stlink_open_usb(const int verbose, int reset);
- stlink_t *sl = stlink_v1_open(99);
+ stlink_t *sl = stlink_v1_open(99, 1);
if (sl == NULL)
return EXIT_FAILURE;
if (sl == NULL)
return EXIT_FAILURE;
- sl = stlink_open_usb(10);
+ sl = stlink_open_usb(10, 1);
if (sl != NULL) {
printf("-- version\n");
stlink_version(sl);
if (sl != NULL) {
printf("-- version\n");
stlink_version(sl);