Skip to content

ESP8266 servo causes crash after updating from core 2.0.0 to 2.2.0  #2083

Closed
@p4yl04d3r

Description

@p4yl04d3r

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

#include <Servo.h>  
#include <ESP8266WiFi.h>
#include <PubSubClient.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
const int button_pin=4 ;  //Button or relay driven by x10 switch for manual control
/* 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 
int button_value;  //high or low button values
int next=1;

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) { 
    if (!client.connected()) {
       delay(10);
       reconnect();
    }
    client.loop();
    button_value = digitalRead(button_pin); 
    if(button_value==LOW){  // button press
      debug and Serial.println("button pressed: "); 
      if (next > 4) {
        next=1;
      }
      if (next == 1) { //First pull is OPEN
        moveblinds(OPEN);     //Move to next position
      } 
      if (next == 2) {                //Second pull is HALF
        moveblinds(HALF);
      } 
      if (next == 3) {                //Third pull is CLOSE 
        moveblinds(CLOSE);                    
      } 
      if (next == 4) {                 //Forth pull is CLOSEUP 
        moveblinds(CLOSEUP);                  
      }
      next++;
   }
   delay(60);
}

Debug Messages

Connecting to <ssid>
......
WiFi connected
IP address: xx.xx.xx.xx
Moving blind1 to: 180 <-- never on this move
button pressed: 
Moving blind1 to: 90  <-- never on this move
button pressed: 
Moving blind1 to: 30  <-- I crash here almost every time.

Exception (0):
epc1=0x40201134 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys 
sp: 3ffffc70 end: 3fffffb0 offset: 01a0

>>>stack>>>
3ffffe10:  4021250c 3ffed750 3ffffed0 00000016  
3ffffe20:  3fffc200 40106c24 00000020 40106c40  
3ffffe30:  402102b5 3ffffed0 3fffc248 4000050c  
3ffffe40:  4000437d 00000030 00000016 ffffffff  
3ffffe50:  60000200 00000008 00000000 80000000  
3ffffe60:  20000000 3fff0da8 80000000 203fc060  
3ffffe70:  80000000 3fffc6fc 3ffeed1c 3fff0dac  
3ffffe80:  00000294 003fc060 3ffecf40 00000030  
3ffffe90:  3ffedd78 40201154 00000000 bfffffff  
3ffffea0:  ffffffff 3fffc6fc 3ffedd78 3ffeed1c  
3ffffeb0:  3ffedda0 03d3a63d 60000600 00000030  
3ffffec0:  40000f58 00000000 00000020 00000000  
3ffffed0:  00000013 40201154 3ffedd78 00000000  
3ffffee0:  ffffffff 3ffecef4 3ffedd78 3fffdab0  
3ffffef0:  00000000 3fffdcb0 3ffeddb0 00000030  
3fffff00:  3fff04a4 3ffee9d8 00002238 40105cb0  
3fffff10:  401051fc 004f9272 3ffe89d4 00000000  
3fffff20:  3ffedda0 3ffe89d4 0000000f 4010707c  
3fffff30:  00000000 400042db 402053c7 3ffecf40  
3fffff40:  40004b31 3fff0d4c 000002f4 003fc000  
3fffff50:  401054a2 00000000 3ffece40 401070c0  
3fffff60:  40208621 3ffece40 00000000 3fffdc00  
3fffff70:  3fff0d4c 00001000 40208ab6 00000002  
3fffff80:  4021a282 3fffdab0 40209cb7 3fffdab0  
3fffff90:  00000000 3fffdab0 3ffeee08 40203ceb  
3fffffa0:  40000f49 40000f49 3fffdab0 40000f49  
<<<stack<<<


Decoding 25 results
0x4021250c: cnx_update_bss_more at ?? line ?
0x40106c24: timer0_isr_handler at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_timer.c line 71
0x40106c40: timer0_isr_handler at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_timer.c line 71
0x402102b5: scan_parse_beacon at ?? line ?
0x40201154: delay_end at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_wiring.c line 38
0x40201154: delay_end at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_wiring.c line 38
0x40105cb0: _UserExceptionVector_1 at ?? line ?
0x401051fc: ets_timer_arm_new at ?? line ?
0x4010707c: pvPortMalloc at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/heap.c line 13
0x402053c7: pp_enable_noise_timer at ?? line ?
0x401054a2: spi_flash_read at ?? line ?
0x401070c0: pvPortZalloc at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/heap.c line 33
0x40208621: pm_set_sleep_time at ?? line ?
0x40208ab6: pm_get_sleep_type at ?? line ?
0x4021a282: ets_timer_handler_isr at ?? line ?
0x40209cb7: pm_post at ?? line ?
0x40203ceb: loop_task at C:\Users\chris\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/core_esp8266_main.cpp line 43

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions