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

Issuing a reboot on ATmega328p makes the board loop-reboot #6836

Closed
zqad opened this issue Mar 31, 2017 · 17 comments
Closed

Issuing a reboot on ATmega328p makes the board loop-reboot #6836

zqad opened this issue Mar 31, 2017 · 17 comments
Assignees
Labels
Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@zqad
Copy link

zqad commented Mar 31, 2017

Consider this sample program:

#include <stdio.h>
#include <periph/pm.h>

int main(void)
{
	puts("Rebooting!\n");
	pm_reboot();
	return 0;
}

Running it on the board gives this result on my serial console:

Rebooting!



main(): This 
             
main(): This é
              
main(): This 
             
main(): This é

The error is due to the usage of the watchdog as the reboot method, without properly clearing the WDRF bit in MCUSR. This means that the watchdog will be activated with a 250ms timeout on the next reboot.

I have prepared a patch which I will add as a pull request to this issue. Feel free to give feedback on it, in case you find anything noteworthy with it.

Thanks,
/Jonas

@zqad
Copy link
Author

zqad commented Mar 31, 2017

The pull request is added as #6837 , the result of which is this serial port output for the same program:

main(): This is RIOT! (Version: 2017.04-devel-638-gdf32c-lisen)
Rebooting!



main(): This is RIOT! (Version: 2017.04-devel-638-gdf32c-lisen)
Rebooting!



main(): This is RIOT! (Version: 2017.04-devel-638-gdf32c-lisen)
Rebooting!

@mali
Copy link
Contributor

mali commented Jun 26, 2017

Hummm .. I think I've bricked my board while testing the code above.
avrdude fail to flash because board reboot on loop

avrdude -p m328p -c arduino -P /dev/ttyUSB0 -b 57600 -F -D -U flash:w:bin/arduino-duemilanove/default.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
and so on ...

@zqad Any good idea on how to recover from this situation ?

@mali
Copy link
Contributor

mali commented Jun 27, 2017

Ok, board unbricked !

@zqad
Copy link
Author

zqad commented Jun 27, 2017

Ah, good. Could not find anything matching that situation myself.

@mali
Copy link
Contributor

mali commented Jun 27, 2017

But the bad news is that I've tested with your patch applied and result is the same ... loop-reboot ...

@zqad
Copy link
Author

zqad commented Jun 27, 2017

That is bad news. Are you using the same avrdude command as above? I hope that I can get some time in the beginning of next week to try it again myself.

@mali
Copy link
Contributor

mali commented Jun 28, 2017

@zqad , yes the same avrdude commande, in fact i just do a make BOARD=arduino-duemilanove flash term

@miri64 miri64 added Area: arduino API Area: Arduino wrapper API Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) labels Oct 25, 2017
@miri64 miri64 added this to the Release 2017.10 milestone Oct 25, 2017
@kYc0o kYc0o removed this from the Release 2017.10 milestone Oct 31, 2017
@ZetaR60
Copy link
Contributor

ZetaR60 commented Apr 15, 2018

The ATmega1284P has this reboot-loop issue as well. Tested on BOARD=mega-xplained

@kYc0o
Copy link
Contributor

kYc0o commented May 15, 2018

Is this issue still valid on current master?

@ZetaR60
Copy link
Contributor

ZetaR60 commented May 15, 2018

@kYc0o Confirmed just now on mega-xplained.

@mali
Copy link
Contributor

mali commented May 22, 2018

@kYc0o Confirmed on duemilanove, the strange thing is that it works well with uno (these two boards are atmega328p based). And the #9141 don't fix for duemilanove.

@ZetaR60
Copy link
Contributor

ZetaR60 commented May 22, 2018

@mali Are there fuse setting differences between boards that work and those that don't? The only other things I can think of that's significantly different between the two is the bootloader and UART adapter.

@mali
Copy link
Contributor

mali commented May 23, 2018

@ZetaR60 fuses settings attached, honestly, I don't know how to interpret this ..

uno.txt
duemilanove.txt

@ZetaR60
Copy link
Contributor

ZetaR60 commented May 23, 2018

Weird. It is reading the fuses as all being set to 0. Maybe retrieving it over USB is unsupported.

I found the default fuse settings for both boards on some website and neither have watchdog always on set.

@miri64 miri64 removed the Area: arduino API Area: Arduino wrapper API label Sep 1, 2018
@kYc0o
Copy link
Contributor

kYc0o commented Sep 3, 2018

Strangely I don't experience this on current master EDIT: in arduino-uno. Can anyone re-confirm this issue in another platform?

@ZetaR60
Copy link
Contributor

ZetaR60 commented Sep 3, 2018

arduino-uno: fixed?
arduino-duemilanove: crashes when executing reboot
mega-xplained: still reboot loops

Not sure what has changed to make Arduino-Uno work now (and Duemilanove crash).

@ZetaR60
Copy link
Contributor

ZetaR60 commented Nov 4, 2018

Fixed by #9866. Closing.

@ZetaR60 ZetaR60 closed this as completed Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

5 participants