Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed connect under reset for st-flash and st-util #983

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/st-flash/flash.c
Original file line number Diff line number Diff line change
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,11 @@ int main(int ac, char** av) {

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

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

sl = stlink_open_usb(o.log_level, 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
Original file line number Diff line number Diff line change
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