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

[feature] Add "Connect under Reset" option #577

Closed
6 tasks done
Gamadril opened this issue Mar 21, 2017 · 6 comments · Fixed by #963
Closed
6 tasks done

[feature] Add "Connect under Reset" option #577

Gamadril opened this issue Mar 21, 2017 · 6 comments · Fixed by #963

Comments

@Gamadril
Copy link

Gamadril commented Mar 21, 2017

  • Programmer/board type: e.g Stlink/v2-onboard
  • Programmer firmware version: e.g STSW-LINK007 2.27.15
  • Operating system: Mac OS X
  • Stlink tools version and/or git commit hash: 1.3.1-9-gc04df7f
  • Stlink commandline tool name: st-flash
  • Target chip (and optional board): e.g STM32F030F4

SWCLK and SWDIO pins of my mcu are used and configured as output. That means to program the flash I have to use the "Connect Under Reset" option. This option seems to be missing. At least adding --reset does not help in that case.

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Mar 21, 2017
@xor-gate
Copy link
Member

Connect under reset is not to difficult the stlink has a command to assert the nRST pin and then try to connect. But this needs to be implemented.

@iglooom
Copy link

iglooom commented Apr 8, 2017

I have a same trouble and use this workaround iglooom@19381ff
It is not fully "connect under reset", but working for me.

@xor-gate
Copy link
Member

xor-gate commented Apr 8, 2017

The nRST reset pin is assert differently. I'm not sure what the output state of the pin is in your commit. First we need to measure and then implement a fix which works for everybody.

@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, v1.7.0, Feedback required Mar 14, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: Feedback required, Reset issues Mar 28, 2020
@geoffreymbrown
Copy link
Collaborator

geoffreymbrown commented May 22, 2020

I also needed this functionality. While I added it to my own copy of the repo, it'd be nice if it made it in somehow. Here are the issues in stlink_open_usb:

  1. Reset has to be asserted before any mode change can happen
  2. It's somewhat less than optimal that stlink_load_device_params(sl); happens in this routine, since loading flash parameters doesn't seem to work under reset.

Here's what I changed --

  1. reset parameter from bool to number : values 0,1 keep current behavior. reset == 2 is used to change the following code :
    if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl);

    if (reset) {
        if ( sl->version.stlink_v > 1) stlink_jtag_reset(sl, 2);
        stlink_reset(sl);
        usleep(10000);
    }`

To:

   if (reset == 2)  stlink_jtag_reset(sl,0);
   if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl);

    if (reset == 1) {
        if ( sl->version.stlink_v > 1) stlink_jtag_reset(sl, 2);
        stlink_reset(sl);
        usleep(10000);
    }

@Nightwalker-87
Copy link
Member

@geoffreymbrown: What about proposing a PR?

@geoffreymbrown
Copy link
Collaborator

The various existing apps wouldn't automatically make use of it, but anything using the library could.
I'm happy to propose a narrow PR (just the changes to make this work)
Geoffrey

@Nightwalker-87 Nightwalker-87 modified the milestones: Reset issues, v1.6.1 May 22, 2020
@Nightwalker-87 Nightwalker-87 changed the title Add "Connect under Reset" option [feature] Add "Connect under Reset" option May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants