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

Target is reset twice. #77

Closed
jcarrano opened this issue Mar 7, 2019 · 4 comments
Closed

Target is reset twice. #77

jcarrano opened this issue Mar 7, 2019 · 4 comments

Comments

@jcarrano
Copy link

jcarrano commented Mar 7, 2019

Description

This change (b65dc24#diff-00259a9e325566089cd936bcc3e75e50R564) caused targets to be reset twice. This is relevant when one just wants to reset (using, e.g., edbg -t atmel_cm0p)

The first reset:

edbg/edbg.c

Line 564 in b65dc24

dap_reset_target_hw(1);

The second reset:

edbg/edbg.c

Line 680 in b65dc24

dap_reset_target_hw(1);

Why is it relevant

In the RIOT OS test suite we reset the boards at the beginning of each test. The test script waits for a known string to start the test. With the current edbg behaviour the test starts and shortly afterwards the board is reset, causing it to fail. Since this is happening only with atmel boards using edbg, I'd like to avoid having to add a specific kludge to handle it in the test infrastructure if I can avoid it.

Steps to reproduce

Load an program that does something immediately after boot, for example output a string over the UART. In my case I'm running the RIOT OS test suite, and listening on the serial connection.

Reset the board with edbg -t <target type> (in my case atmel_cm0p.)

Expected result

Board is reset once thus the message is sent once.

Actual result

Board is reset twice in a short span thus the message is sent twice.

jcarrano added a commit to jcarrano/RIOT that referenced this issue Mar 7, 2019
A few commits ago edbg changed its behavior and now it resets the board
twice. This makes some tests fail, as the start on the first reset, but
shortly after the board is reset again.

See: ataradov/edbg#77

This comments out RESET and RESET_FLAGS in the edbg tool setting. Reset
will now be done via OpenOCD, which is available and used anyways because
it is needed for `make debug`.
@ataradov
Copy link
Owner

ataradov commented Mar 7, 2019

It is probably safe to switch to "dap_reset_target_hw(0);" CM4v2 at this point does a reset with extension in the target_select() code anyway.

The next problem would be that target_deselect() does a software reset, which would be followed by the hardware reset. This is done to ensure operation without a reset pin.

I have no problem with the first change, in fact I think the whole reset may be removed from here and moved to individual targets select procedure. I will do that later today after some testing.

But the second one will be remain as is, so if this is still a problem, removing the first reset will not help much.

It is possible that target_deselect() and dap_reset_target_hw(1) happen fast enough that MCU does not have time to run any useful code, of course.

@jcarrano
Copy link
Author

jcarrano commented Mar 7, 2019

@ataradov Thanks for the quick response.

It is possible that target_deselect() and dap_reset_target_hw(1) happen fast enough that MCU does not have time to run any useful code, of course.

Yes, I think that is the case, because I don't experience any issue with commits prior to b65dc24.

@ataradov
Copy link
Owner

ataradov commented Mar 8, 2019

I've moved the initial reset into the target specific code. This should fix your issue.

@ataradov ataradov closed this as completed Mar 8, 2019
@jcarrano
Copy link
Author

I can confirm that the issue is solved. Thanks for the prompt response!

jcarrano added a commit to jcarrano/RIOT that referenced this issue Mar 11, 2019
The lastest version of edbg solves a double-reset issue that was
hindering testing (see RIOT-OS#11125 and ataradov/edbg#77)

It also adds support for SAMR34 and SAMR35, needed by @dylad for MCU
port.
jcarrano added a commit to jcarrano/RIOT that referenced this issue Mar 12, 2019
The lastest version of edbg solves a double-reset issue that was
hindering testing (see RIOT-OS#11125 and ataradov/edbg#77)

It also adds support for SAMR34 and SAMR35, needed by @dylad for MCU
port.
jcarrano added a commit to jcarrano/RIOT that referenced this issue Mar 13, 2019
The lastest version of edbg solves a double-reset issue that was
hindering testing (see RIOT-OS#11125 and ataradov/edbg#77)

It also adds support for SAMR34 and SAMR35, needed by @dylad for MCU
port.
aabadie pushed a commit to aabadie/RIOT that referenced this issue Mar 26, 2019
The lastest version of edbg solves a double-reset issue that was
hindering testing (see RIOT-OS#11125 and ataradov/edbg#77)

It also adds support for SAMR34 and SAMR35, needed by @dylad for MCU
port.
aabadie pushed a commit to aabadie/RIOT that referenced this issue Mar 28, 2019
The lastest version of edbg solves a double-reset issue that was
hindering testing (see RIOT-OS#11125 and ataradov/edbg#77)

It also adds support for SAMR34 and SAMR35, needed by @dylad for MCU
port.
geromueller pushed a commit to geromueller/RIOT that referenced this issue Jun 19, 2019
The lastest version of edbg solves a double-reset issue that was
hindering testing (see RIOT-OS#11125 and ataradov/edbg#77)

It also adds support for SAMR34 and SAMR35, needed by @dylad for MCU
port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants