Hi, I'm working on a project which uses 3 RTOS tasks, it works fine but when I add a new task that saves
a uint32 variable to the EEPROM every 5 seconds, ESP32 always reset, even when I init only this task and
delete the other 3 tasks.
And when I delete this task and add its code in another task, it works well.
In addition to, I call the function "save_dose_counts()" somewhere else in the code and it also works well.
This is the code implementation.
uint16_t dose_addr = 505;
uint32_t dose_counter = 60;
void tasks_init()
{
// xTaskCreatePinnedToCore(stepper_task, "STEEPER", 1000, NULL,
// 3, &stepper_task_handler, 0);
// xTaskCreatePinnedToCore(lcd_task, "LCD", 10000, NULL,
// 3, NULL, 1);
// xTaskCreatePinnedToCore(alarms_task, "ALARMS", 10000, NULL,
// 2, NULL, 1);
xTaskCreatePinnedToCore(dose_count_task, "DOSE_COUNT", 1000, NULL,
1, NULL, 1);
}
void dose_count_task(void *pvParameters)
{
for( ;; )
{
while(external_trigger_flag)delay(1);
save_dose_counts();
delay(5000);
}
vTaskDelete(NULL); /* Passing NULL will cause the calling task to be deleted */
}
void save_dose_counts()
{
EEPROM.begin(512);
EEPROM.put(dose_addr, dose_counter);
EEPROM.commit();
}
AND when I replace the code of this task with a blinky one,
it also works well without any reset.
output from the serial:
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (DOSE_COUNT)
Core 1 register dump:
PC : 0x400885ef PS : 0x00060e36 A0 : 0x80088794 A1 : 0x3ffb8990
A2 : 0x3ffba8bc A3 : 0x00000000 A4 : 0xffffffff A5 : 0x00000000
A6 : 0x000000ff A7 : 0x3ffb8bbc A8 : 0x8008976d A9 : 0x3ffb89a0
A10 : 0x00000003 A11 : 0x00060e23 A12 : 0x00060e20 A13 : 0x00000025
A14 : 0x00000002 A15 : 0x3ffb8bbc SAR : 0x00000008 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40001609 LEND : 0x4000160d LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000
Backtrace: 0x400885ef:0x3ffb8990 0x40088791:0x3ffb89d0 0x400e2720:0x3ffb89f0 0x40083f2f:0x3ffb8a10 0x400844ad:0x3ffb8a30 0x400e5bad:0x3ffb8aa0 0x400e445d:0x3ffb8ac0 0x400e48ab:0x3ffb8ae0 0x400e3241:0x3ffb8b50 0x400e3d24:0x3ffb8ba0 0x400e2885:0x3ffb8c00 0x400e2d71:0x3ffb8c40 0x400d1fe4:0x3ffb8c60 0x400d1a8e:0x3ffb8c90 0x40088921:0x3ffb8cc0
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (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:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
RTOS task to save value in EEPROM on core 1 always resets ESP32
-
- Posts: 3
- Joined: Mon Mar 23, 2020 11:04 am
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: RTOS task to save value in EEPROM on core 1 always resets ESP32
Code: Select all
Debug exception reason: Stack canary watchpoint triggered (DOSE_COUNT)
-
- Posts: 3
- Joined: Mon Mar 23, 2020 11:04 am
Re: RTOS task to save value in EEPROM on core 1 always resets ESP32
Very good, it worked well when i increased the stack size of the task from 1000 to 10000, and value is correctly saved.
Thank you, ESP_Sprite
But how to know the required stack size for the task ??
like for this example:
Thank you, ESP_Sprite
But how to know the required stack size for the task ??
like for this example:
- void save_dose_counts()
- {
- EEPROM.begin(512);
- EEPROM.put(dose_addr, dose_counter);
- EEPROM.commit();
- }
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: RTOS task to save value in EEPROM on core 1 always resets ESP32
Either you can just use trial and error, or you can use the uxTaskGetStackHighWaterMark() function at the end of the task to figure out how far away from a stack overflow you were.
-
- Posts: 3
- Joined: Mon Mar 23, 2020 11:04 am
Re: RTOS task to save value in EEPROM on core 1 always resets ESP32
wow, it worked well.
Thank you for your help.
Thank you for your help.
Who is online
Users browsing this forum: No registered users and 62 guests