🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Random restarts of the M5Stack Core 2 (code/backtrace included)

    Scheduled Pinned Locked Moved Core 2
    3 Posts 3 Posters 5.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      JackRazors
      last edited by

      Hi! I am building a tower light. It has the following features:

      • Battery (AXP125)
      • 3 x 12 5050 Neopixel rings
      • Enclosure that fits the M5Stack Core 2
      • OOB, it goes into config mode (AP mode) and has a web interface to 'scan' and join a WiFi network as a client
      • RESTful API for controlling the lights

      I've been having random reboots of the M5Stack Core 2 using tasks. I've stripped down 99% of my code to a simple example. Any ideas how I can figure out whats causing the restarts?

      Also, M5.BtnA.wasPressed() doesn't work either when the button is pressed.

      My code:

      #include <Arduino.h>
      #include <M5Core2.h>
      #include <Adafruit_NeoPixel.h>
      #include "logo.h"
      
      // create a couple task handles
      TaskHandle_t TaskBtnScr;
      TaskHandle_t Task2;
      
      //BtnScrController: Displays sprite output and looks for button presses
      void BtnScrController( void * pvParameters ){
        for(;;){ // emulate a void loop()
          M5.update();
          if (M5.BtnA.wasPressed()) {
            Serial.println("Button was pressed.");
            delay(1000);
          }    
        } 
      }
      
      //Task2code: blinks an LED every 700 ms
      void Task2code( void * pvParameters ){
        Serial.print("Task2 running on core ");
        Serial.println(xPortGetCoreID());
      
        for(;;){
          M5.Lcd.clearDisplay();
          M5.Lcd.setCursor(0, 0);
          M5.Lcd.setTextColor(WHITE);
          M5.Lcd.println("task 2 code");
          delay(2500);
        }
      }
      
      
      void setup() {
        M5.begin(true, true, false, true, kMBusModeOutput);
        Serial.begin(115200);
      
        // logo
        M5.Lcd.pushImage(0, 0, 320, 240, (uint16_t *)gImage_logo);
        delay(2500);
        M5.Lcd.clearDisplay();
        M5.Lcd.setCursor(0, 0);
        M5.Lcd.setTextColor(WHITE);
      
        //create a task that will be executed in the Task1code() function, with priority 1 and executed on core 0
        xTaskCreatePinnedToCore(
                          BtnScrController,   /* Task function. */
                          "ButtonScreenController",     /* name of task. */
                          10000,       /* Stack size of task */
                          NULL,        /* parameter of the task */
                          1,           /* priority of the task */
                          &TaskBtnScr,      /* Task handle to keep track of created task */
                          0);          /* pin task to core 0 */                  
        delay(500); 
      
          //create a task that will be executed in the Task2code() function, with priority 1 and executed on core 1
        xTaskCreatePinnedToCore(
                          Task2code,   /* Task function. */
                          "Task2",     /* name of task. */
                          10000,       /* Stack size of task */
                          NULL,        /* parameter of the task */
                          1,           /* priority of the task */
                          &Task2,      /* Task handle to keep track of created task */
                          1);          /* pin task to core 1 */
          delay(500); 
      }
      
      void loop() {
        
      }
      

      Terminal:

      
      rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
      configsip: 0, SPIWP:0xee
      clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
      mode:DIO, clock div:2
      load:0x3fff0018,len:4
      load:0x3fff001c,len:1044
      load:0x40078000,len:10124
      load:0x40080400,len:5828
      entry 0x400806a8
      [E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
      [E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
      [E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
      Task2 running on core 1
      E (19249) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
      E (19249) task_wdt:  - IDLE0 (CPU 0)
      E (19249) task_wdt: Tasks currently running:
      E (19249) task_wdt: CPU 0: ButtonScreenCon
      E (19249) task_wdt: CPU 1: loopTask
      E (19249) task_wdt: Aborting.
      abort() was called at PC 0x400e7717 on core 0
      
      ELF file SHA256: 0000000000000000
      
      Backtrace: 0x4008a490:0x3ffbe4f0 0x4008a709:0x3ffbe510 0x400e7717:0x3ffbe530 0x40086195:0x3ffbe550 0x4000cffa:0x3ffb4600 0x40081573:0x3ffb4620 0x400d1d70:0x3ffb4640 0x400d1ee5:0x3ffb4690 0x400d15f5:0x3ffb46b0 0x400d14ca:0x3ffb46d0 0x4008b70e:0x3ffb46f0
      
      Rebooting...
      ets Jul 29 2019 12:21:46
      
      rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
      configsip: 0, SPIWP:0xee
      clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
      mode:DIO, clock div:2
      load:0x3fff0018,len:4
      load:0x3fff001c,len:1044
      load:0x40078000,len:10124
      load:0x40080400,len:5828
      entry 0x400806a8
      [E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
      [E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
      [E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
      Task2 running on core 1
      E (19249) task_wdt: Task 
      
      1 Reply Last reply Reply Quote 0
      • felmueF Offline
        felmue
        last edited by

        Hello @JackRazors

        to avoid the crash add a delay(1) into the for loop of the BtnScrController() task function. This allows the system to reset the watchdog.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • M Offline
          Minxster
          last edited by

          I don't know if you got this sorted, but we're not really supposed to user core 0, as this can cause panics. That's advice from Espressif. Also, adding in a delay @felmue said should really help in allowing the thread to free-up some cycles.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post