On 02.11.2017 23:13, Åke Rehnman wrote:

On 2017-11-02 11:14, Tomas Vanek wrote:
So I propose for #3952 (the real code should check errors of course):

Were you able to have a look at the implementation I cooked up in the latest change set? Basically I just emit a mode enter before stlink_usb_assert_srst() if we are about to go swimming. Then the rest of the original code mode_enter etc etc.

Of course I looked at that. My proposal is my reaction to your code.
1) I hope that calling stlink_usb_assert_srst() twice is safer than doubling stlink_usb_mode_enter() 2) Calling stlink_usb_assert_srst() after mode enter in SWD mode is a kind of safety measure for cases like SWIM was the previous active mode or default protocol is changed in some fw. 3) I'm curious if SWIM works when stlink_usb_assert_srst() is issued before and after mode enter. 4) Such peculiar fragment of code should be extensively commented or somebody
"fixes" it in the future. We should say why we doing this hack.
    if (connect_under_reset) {
        /* if we are going to use swim we need to switch mode early */
        if (emode == STLINK_MODE_DEBUG_SWIM) {
            res = stlink_usb_mode_enter(handle, emode);
            if (res != ERROR_OK)
                return res;
        }
        res = stlink_usb_assert_srst(handle, 0);
        if (res != ERROR_OK)
            return res;
    }

    res = stlink_usb_mode_enter(handle, emode);

    if (res != ERROR_OK)
        return res;

    res = stlink_usb_current_mode(handle, &mode);



BTW Thanks for a huge contribution

Well, lets see if it gets merged eventually maybe....

/Ake

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to