-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
ESP8266 servo causes crash after updating from core 2.0.0 to 2.2.0 #2083
Comments
The sketch doesn't compile for me,
|
After commenting out some stuff and adding a |
Sorry, I should have included the full or at least functioning sketch. If you cycle through the if statements a few times (button on gpio 4) the servo.write (HALF) causes a crash. I'll post the complete sketch in a bit. I am also publishing data to an mqtt broker. |
I wrote a quick sketch (bare bones) but close to the original sketch in regards to the code path that controls the servo. Took a bit more time but it did trigger a crash. #include <Servo.h>
/* Setup number of servos */
#define SERVO1
//#define SERVO2
//#define SERVO3
/* ENABLE DEBUG */
int debug = 1; //Set this to 1 for serial debug output
/* Configure GPIO servo pins*/
const int servoPin1=13; //Pin for servo1
//const int servoPin2=12; //Pin for servo2
//const int servoPin3=14; //Pin for servo3
/* Blind tilt settings */
const int OPEN=90; //Global settings for open
const int HALF=30; //Global settings for half way opened
const int CLOSE=0; //Global settings for close in down position
const int CLOSEUP=180; //Global setting to close in the up position
/***********************************************************************************/
Servo myservo; // create servo object to control a servo
void setup(void) {
Serial.begin(9600); //Comment out this line if you don't want debugging enabled
moveblinds(CLOSEUP); // call function to close all blinds
delay(2000);
}
void moveblinds(int value) {
#ifdef SERVO1
delay(60);
debug and Serial.print("Moving blind1 to: ");
debug and Serial.println(value);
myservo.attach(servoPin1);
myservo.write(value);
delay(600);
myservo.detach();
#endif
#ifdef SERVO2
delay(60);
debug and Serial.print("Moving blind2 to: ");
debug and Serial.println(value);
myservo.attach(servoPin2);
myservo.write(value);
delay(600);
myservo.detach();
#endif
#ifdef SERVO3
delay(60);
debug and Serial.print("Moving blind3 to: ");
debug and Serial.println(value);
myservo.attach(servoPin3);
myservo.write(value);
delay(600);
myservo.detach();
#endif
}
void loop(void) {
moveblinds(HALF); //Move to next position
delay(500);
moveblinds(HALF);
delay(500);
moveblinds(HALF);
delay(500);
} Serial output:
|
@p4yl04d3r Could you please try the following: change line 53 of void timer1_detachInterrupt() { to void ICACHE_RAM_ATTR timer1_detachInterrupt() { |
These functions are used from ISR in Servo library, so must be in IRAM.
@igrr changing line 53 was not enough. It still crashed. I also made the following change to line 48 same file: Stack of only changing line 53: |
I have yet had it fail, how long does it need to run before it fails? |
@Makuna It took about 1 - 2 minutes. But the stack is random. |
I created https://gitter.im/Makuna/ArduinoEsp8266Issue2083 so we talk live. |
@Makuna I tried the link above earlier, I got a 404 error. |
Basically, I have been running your sketch above for hours and still have not had a single repro. There is something more to causing this issue than just the servo code. |
Michael, Em Sex, 3 de jun de 2016 18:58, Michael Miller notifications@github.com
|
I thought the same thing until I tried it with the minimal logic sketch above. Basically I removing all the MQTT stuff and was able to trigger. Could it be that I am not defining the ESP-12 correctly to the IDE? |
Ok, I got a repro. It does require that networking was configured. I merged in the code for the HelloServer sample. My esp8266 I have cleared the network settings normally. Remember that the esp8266 will reconnect with the last settings unless they are cleared; so I suspect the networking is needed to apply pressure so it can reproduce. |
Glad you could reproduce and it's not just my ESPs. |
@p4yl04d3r I was able to get a consistent repro every few minutes, I then applied the fix that @igrr referenced above and I have not be able to get it repro at all. It has been running for 5 hours straight without an issue. Confirm that you really did apply the change that igrr referenced above. |
I confirmed by looking at the line number in the stack trace. After applying @igrr fix the line in core_esp8266_timer.c was incremented by one. |
Dear all, Many thanks... |
@woodsgood I am assuming you are using core 2.2.0. On windows the path for me was "C:\Users\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_timer.c". |
Thanks... This appears to be working fine although I'll see if the problems exist over the next few hours. |
@woodsgood How did your testing go? Did you end up changing both |
Thanks p4yl04d3r |
Now, I have another issue on another project which has two steppers. `Soft WDT reset ctx: cont
ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x4010f000, len 1264, room 16 Here's the simple code... int stepcount; //****************************************************************************************// //****************************************************************************************// |
Messing with the WDT is a bad idea, you need to remove |
Thanks igrr |
I am still having a problem. Went back and compiled the original program with MQTT and I am still crashing on the same statements. button pressed:
|
Forgot to mention I have modified the following lines in core_esp8266_timer.c |
This is the program:
|
Just shooting in the dark, but a couple of things to try...
|
It will crash with and without a servo attached. |
@p4yl04d3r Please edit your post above and the code attributes to it so it shows up correctly (right now the includes are hidden). |
Any luck with the yield() statements?? |
yield should not matter here — exception 0 means that some code from flash got called when flash cache was disabled. I would like to know what code is at 0x402010d8. |
I have updated my post above fixing the formatting. |
@igrr I got the requested line:
I think I want to add |
@p4yl04d3r I thought we stated above you needed to add ICACHE_RAM_ATTR to timer0_detachInterrupt() above? Did you not? specifically referencing this change by @igrr |
I added ICACHE_RAM_ATTR to line 53 So I modified the base 2.2.0 core_esp8266_timer.c with the following: |
I ran an additional test removing the change on line 53 and only including the modified line 98. Program seems stable also. |
For the first 12 servos (unless a special define is used), it will use the timer0, only after 12 or the use of a special define does it then use timer 1. |
I am happy with the proposed change in 2.3.0. we can close or promote this bug. |
Dear all, Many thanks, |
@woodsgood this commit has all necessary changes: d1fc700 |
Basic Infos
Hardware
Hardware: ESP-12F
Core Version: 2.2.0
Description
Servo movement to specific positions causes esp8266 to crash. I am using Arduino IDE 1.6.9.
I am using the same function to call the servo and only passing in a different value. But only when I pass in a lower/mid value does the controller crash. I have confirmed the following values (5,30,40,45) trigger a crash.
Other values (0 90,100,175,180) are OK.
Having a servo connected is optional to trigger the crash.
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: dio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck
Debug Messages
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: