-
Notifications
You must be signed in to change notification settings - Fork 63
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
strange reset on Feather M0 after random minutes #9
Comments
I also have strange behavior while using Watchdog.sleep() with my Adafruit Feather M0 I'm logging two serial interfaces to two different files on a SD card using "threads", but after i have included all libraries necessary for SleepyDog, the two serial interfaces start mismatching with the threads and dump interface1 buffert into interface2 file and so on Feels like a lot of strange issues happens while using this library with M0 |
I build a very simple code with a LED "blink" in setup, and a sleep in the main loop. It blinks for example in 70min, 12min, 20min, 5min, 3min ... The code was similar to this: #include <Adafruit_SleepyDog.h>
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
}
void loop() {
Watchdog.sleep(250);
} |
I'll add that our group is also seeing random resets on the Adafruit Adalogger M0. We have the sleep set to sleep for Also, we think but are not sure that these resets are associated with some strange data coming out of the Adalogger's serial TX pin. We have our Adalogger M0 hooked up to a device that receives commands over serial, and sometimes when the M0 resets our device will receive garbage commands. Strangely, if we intentionally use the watchdog to reset every 5000ms using |
As a sanity check, we tried only replacing |
I also get random resets and note that the frequency of the resets varies between 2 different M0 LoRa Feathers, I find that one resets infrequently - after 50000 sleeps or so while the other resets every 8000 sleeps or so. As noted by Daterdots, if I replace sleep(1000) with delay(1000) the problem goes away. |
We dug into the library a bit, and we modified the library so that WatchDog.sleep() does not use the window mode. However, with everything stripped down, the problem still persists. Has anyone heard of a general problem with these ATMEL M0s having reset issues in general? I am starting to think this is an M0 issue more than a library issue. |
I wonder whether it is a hardware problem (given the variation between Feathers) - maybe a poor connection between the reset pullup resistor and the reset line. I have tied the reset pin high and have had no spurious resets in 3 days. There again given the low frequency of the intermittent fault I could be kidding myself. |
Sadly, tying the reset line high didn't prevent a reset. Having had none for 3 days I had two in the last four hours. |
We also thought it might be a hardware problem, but we have no issues if we replace |
I'm seeing this issue also running an a feather M0 RF96 (868 radio), my code: int wait; //Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { void loop() { so been running this one a few times: .. seems there is no constant in there.. |
ps, I also don't have the issue when replacing the watchdog by delay(), then original code runs for months (indoor air monitor) |
is there anybody that has the sleepdog lib up and running without any issue on the M0?! .. do we miss somthing in setup?! |
Still no joy with Sleepydog but I'm trying the Arduino Zero RTC library and so far it hasn't caused the Feather to reset. It provides alarm (and implicitly timer) functions but goes nowhere near watchdog timing. |
Hi Phec, I found that video also, but did not dear to use it yet.. now since you did, I will also start performing it .. |
I'm wondering if this has something to do with serial comms. I've found that I can get the watchdog to trigger with serial writes/reads. Increasing the timeout to something much larger helped (like 250ms) but still not gone completely. |
@killer4king I have used the SleepyDog library for almost a year now on multiple Feather M0s and it has behaved fine. I am only using it as a watchdog, however. I am not using the sleep functionality. |
this might be caused by this issue // Disable systick interrupt disabling it fixed my issue. |
I found the issue with M0 Random resets, it's in how the library defines Sleep mode. in /utility/WatchdogSAMD.cpp Line#119-124 M4 version above it also needs to be checked ALSO USERS SHOULD NOTE |
@bt20304 we tried disabling window mode, and it did not help us #9 (comment):
|
I'm also having this issue, using an itsybitsy m0 express, logging analogRead data to the built-in SPI flash, sleeping for 500ms in between reads. It typically runs for about an hour, but then resets. Did you guys ever figure out a solution @daterdots? Thanks! |
Unfortunately not, @kjloope - sorry for the bad news! |
Actually, I think ravelab has the answer. I set up my M0 adalogger to sleep for 100 ms, then flash the built in LED on wakeup, so about 10 sleep cycles per second. Using the sleepydog library as is, the board would reset in about 30 minutes. To check ravelabs answer, I went into the WatchdogSAMD.cpp file, and added and I've tried the same code after changing this, and it has run fine for the last 20 hours. |
@NAPtime2 do you want to make the PR, or should I? |
PR's welcome :) thanx! |
Go for it! (not even sure what you mean by PR tbh) |
@skot and @underpickled maybe you can help me with this PR when we have a sec? |
@daterdots sure, I'll take a look tomorrow |
Disabling the systick timer interrupt during sleep has previously been discussed on the Microchip/Atmel community forum: https://community.atmel.com/comment/2625116#comment-2625116. After an enquiry on the forum about the WDT issue, Microchip/Atmel responded:
|
I've issued a pull request here: #24. It addresses the issue by disabling the SysTick timer interrupts before putting the SAMD21 to sleep, then enabling them again after waking up. A second issue is that the SAMD20 and SAMD21 definitions doesn't exsist, meaning that the line of code that prevents the flash from powering down never gets called:
I've replaced the SAMD20 and SAMD21 definitions with SAMD20_SERIES and SAMD21_SERIES, these cover all chip variants. |
Martin This fixed it for me. I don't understand why this hasn't been merged yet. THANKS! |
Thanks for the discussion and PR! This has been merged, and version # bumped to 1.6.1; should be present in Arduino Library manager after that percolates for an hour or two. |
Hi Adafuit.
I use your lib on Adafruit Feather M0 and getting randomly a reset after many minutes. The idea was to use:
Watchdog.sleep(250)
instead of
delay(250)
to save power. It works and runs 3 times longer, but it was resetting my device after a random time of minutes.
For debugging I adopt your code into my project: no-go/featherM0_ssd1331_watch@e403386
It worked but it was still resetting device after minutes :-(
I compared my attiny wdt sleep code with your code and decide to add
#include <wdt.h>
and rename the ISR:void WDT_Handler(void) {
to
ISR(WDT_vect) {
but it does not fix the bug. I am sorry, but I add a lot of stuff to my feather M0 and I did not have a second, fresh one for testing with a simple, easy code. With
delay(250)
instead ofWatchdog.sleep(250)
and without your lib, I did not have a reset issue. I think, running the wdt in sleep mode for more than 1h couse a reset on a feather m0 - maybe a device bug or a bug in your lib.I hope, you have the possibility to reproduce my issue and you can fix it.
:-D
The text was updated successfully, but these errors were encountered: