<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Random restarts of the M5Stack Core 2 (code&#x2F;backtrace included)]]></title><description><![CDATA[<p dir="auto">Hi!  I am building a tower light. It has the following features:</p>
<ul>
<li>Battery (AXP125)</li>
<li>3 x 12 5050 Neopixel rings</li>
<li><a href="https://imgur.com/VUF6pl3" target="_blank" rel="noopener noreferrer nofollow ugc">Enclosure that fits the M5Stack Core 2</a></li>
<li>OOB, it goes into config mode (AP mode) and has a web interface to 'scan' and join a WiFi network as a client</li>
<li>RESTful API for controlling the lights</li>
</ul>
<p dir="auto">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?</p>
<p dir="auto">Also, M5.BtnA.wasPressed() doesn't work either when the button is pressed.</p>
<p dir="auto">My code:</p>
<pre><code>#include &lt;Arduino.h&gt;
#include &lt;M5Core2.h&gt;
#include &lt;Adafruit_NeoPixel.h&gt;
#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 */
                    &amp;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 */
                    &amp;Task2,      /* Task handle to keep track of created task */
                    1);          /* pin task to core 1 */
    delay(500); 
}

void loop() {
  
}
</code></pre>
<p dir="auto">Terminal:</p>
<pre><code>
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 
</code></pre>
]]></description><link>https://community.m5stack.com/topic/3948/random-restarts-of-the-m5stack-core-2-code-backtrace-included</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 14:54:39 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3948.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Jan 2022 17:44:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Random restarts of the M5Stack Core 2 (code&#x2F;backtrace included) on Wed, 23 Feb 2022 13:04:31 GMT]]></title><description><![CDATA[<p dir="auto">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 <a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> said should really help in allowing the thread to free-up some cycles.</p>
]]></description><link>https://community.m5stack.com/post/16740</link><guid isPermaLink="true">https://community.m5stack.com/post/16740</guid><dc:creator><![CDATA[Minxster]]></dc:creator><pubDate>Wed, 23 Feb 2022 13:04:31 GMT</pubDate></item><item><title><![CDATA[Reply to Random restarts of the M5Stack Core 2 (code&#x2F;backtrace included) on Thu, 20 Jan 2022 10:18:04 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/jackrazors" aria-label="Profile: JackRazors">@<bdi>JackRazors</bdi></a></p>
<p dir="auto">to avoid the crash add a <code>delay(1)</code> into the <code>for</code> loop of the <code>BtnScrController()</code> task function. This allows the system to reset the watchdog.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/16262</link><guid isPermaLink="true">https://community.m5stack.com/post/16262</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Thu, 20 Jan 2022 10:18:04 GMT</pubDate></item></channel></rss>