kopia lustrzana https://github.com/stlink-org/stlink
Added --connect-under-reset to st-flash and st-info
rodzic
ce0df3ba3c
commit
25d0e56161
|
@ -27,9 +27,10 @@ struct flash_opts
|
|||
size_t flash_size; /* --flash=n[k][m] */
|
||||
int opt; /* enable empty tail data drop optimization */
|
||||
int freq; /* --freq=n[k][m] frequency of JTAG/SWD */
|
||||
bool connect_under_reset;
|
||||
};
|
||||
|
||||
#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
|
||||
int flash_get_opts(struct flash_opts* o, int ac, char** av);
|
||||
|
||||
|
|
|
@ -225,6 +225,9 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) {
|
|||
if (result != 0) return bad_arg ("--flash");
|
||||
else o->flash_size = (size_t) flash_size;
|
||||
}
|
||||
else if (strcmp(av[0],"--connect-under-reset")== 0){
|
||||
o->connect_under_reset = true;
|
||||
}
|
||||
else {
|
||||
break; // non-option found
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ static void usage(void)
|
|||
puts("st-info --probe");
|
||||
puts("st-info --serial");
|
||||
puts("st-info --hla-serial");
|
||||
puts("st-info --flash");
|
||||
puts("st-info --pagesize");
|
||||
puts("st-info --sram");
|
||||
puts("st-info --chipid");
|
||||
puts("st-info --descr");
|
||||
puts("st-info --flash [--connect-under-reset]");
|
||||
puts("st-info --pagesize [--connect-under-reset]");
|
||||
puts("st-info --sram [--connect-under-reset]");
|
||||
puts("st-info --chipid [--connect-under-reset]");
|
||||
puts("st-info --descr [--connect-under-reset]");
|
||||
}
|
||||
|
||||
/* Print normal or OpenOCD hla_serial with newline */
|
||||
|
@ -76,19 +76,25 @@ static void stlink_probe(void)
|
|||
stlink_probe_usb_free(&stdevs, size);
|
||||
}
|
||||
|
||||
static stlink_t *stlink_open_first(void)
|
||||
static stlink_t *stlink_open_first(bool under_reset)
|
||||
{
|
||||
stlink_t* sl = NULL;
|
||||
sl = stlink_v1_open(0, 1);
|
||||
if (sl == NULL)
|
||||
sl = stlink_open_usb(0, 1, NULL, 0);
|
||||
if (sl == NULL) {
|
||||
if (under_reset) {
|
||||
sl = stlink_open_usb(0, 2, NULL, 0);
|
||||
} else {
|
||||
sl = stlink_open_usb(0, 1, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return sl;
|
||||
}
|
||||
|
||||
static int print_data(char **av)
|
||||
static int print_data(int ac, char **av)
|
||||
{
|
||||
stlink_t* sl = NULL;
|
||||
bool under_reset = false;
|
||||
|
||||
// Probe needs all devices unclaimed
|
||||
if (strcmp(av[1], "--probe") == 0) {
|
||||
|
@ -99,7 +105,16 @@ static int print_data(char **av)
|
|||
return 0;
|
||||
}
|
||||
|
||||
sl = stlink_open_first();
|
||||
if (ac == 3) {
|
||||
if (strcmp(av[2],"--connect-under-reset") == 0) {
|
||||
under_reset = true;
|
||||
} else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
sl = stlink_open_first(under_reset);
|
||||
|
||||
if (sl == NULL) {
|
||||
return -1;
|
||||
|
@ -149,7 +164,7 @@ int main(int ac, char** av)
|
|||
return -1;
|
||||
}
|
||||
|
||||
err = print_data(av);
|
||||
err = print_data(ac,av);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
10
src/usb.c
10
src/usb.c
|
@ -1145,7 +1145,15 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, int reset, char serial[STL
|
|||
break;
|
||||
}
|
||||
|
||||
if (reset == 2) stlink_jtag_reset(sl,0);
|
||||
if (reset == 2) {
|
||||
stlink_jtag_reset(sl,0);
|
||||
if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl);
|
||||
stlink_force_debug(sl);
|
||||
stlink_jtag_reset(sl,1);
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
|
||||
if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl);
|
||||
|
||||
if (reset == 1) {
|
||||
|
|
Ładowanie…
Reference in New Issue