Skip to content

Commit

Permalink
Merge pull request #983 from adrienbruant/connect_under_reset
Browse files Browse the repository at this point in the history
[bugfix] Connect under reset for st-flash and st-util
  • Loading branch information
Nightwalker-87 committed Jun 17, 2020
2 parents 5fae7e4 + 9ec7eee commit 3b520df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/st-flash/flash.c
Expand Up @@ -42,6 +42,7 @@ int main(int ac, char** av) {
struct flash_opts o;
int err = -1;
uint8_t * mem = NULL;
int reset = 1;

o.size = 0;

Expand All @@ -53,7 +54,9 @@ int main(int ac, char** av) {

printf("st-flash %s\n", STLINK_VERSION);

sl = stlink_open_usb(o.log_level, 0, 1, (char *)o.serial, o.freq);
if(o.connect_under_reset) { reset = 2; }

sl = stlink_open_usb(o.log_level, 0, reset, (char *)o.serial, o.freq);

if (sl == NULL) { return(-1); }

Expand Down
8 changes: 7 additions & 1 deletion src/st-util/gdb-server.c
Expand Up @@ -108,6 +108,7 @@ int parse_options(int argc, char** argv, st_state_t *st) {
{"version", no_argument, NULL, 'V'},
{"semihosting", no_argument, NULL, SEMIHOSTING_OPTION},
{"serial", required_argument, NULL, SERIAL_OPTION},
{"connect-under-reset", no_argument, NULL, 'u'},
{0, 0, 0, 0},
};
const char * help_str = "%s - usage:\n\n"
Expand All @@ -133,14 +134,16 @@ int parse_options(int argc, char** argv, st_state_t *st) {
"The STLINK device to use can be specified in the environment\n"
"variable STLINK_DEVICE on the format <USB_BUS>:<USB_ADDR>.\n"
"\n"
" -u, --connect-under-reset\n"
"\t\t\t Keep the board under reset while connecting\n"
;


int option_index = 0;
int c;
int q;

while ((c = getopt_long(argc, argv, "hv::p:mn", long_options, &option_index)) != -1)
while ((c = getopt_long(argc, argv, "hv::p:mnu", long_options, &option_index)) != -1)
switch (c) {
case 0:
break;
Expand Down Expand Up @@ -197,6 +200,9 @@ int parse_options(int argc, char** argv, st_state_t *st) {

serial_specified = true;
break;
case 'u':
st->reset = 2;
break;
}


Expand Down

0 comments on commit 3b520df

Please sign in to comment.