ESP32 crashes if I use vTaskDelay in app_main function

mdaupu
Posts: 2
Joined: Sun Sep 13, 2020 6:23 pm

ESP32 crashes if I use vTaskDelay in app_main function

Postby mdaupu » Sun Sep 13, 2020 6:52 pm

Hello everyone,
I have written a simple program using amazon freertos. I am using ESP32-WROOM-32UE module. If I use vTaskDelay in the app_main function, the ESP32 restarts. But if I use 9 or less than 9 value in the vTaskDelay, it works.

My question is, why esp32 restarts if I use more than 9ms delay in the app_main function?


My Code:

Code: Select all

int app_main(void)
{
      printf("Hello World \r\n");
      prvMiscInitialization();
      config_gpio();
      display_task_create();
      while(1){
        vTaskDelay(100 / portTICK_PERIOD_MS);
      }
  return 0;
}
Error Code:
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
Debug exception reason: BREAK instr
Core 0 register dump:
PC : 0x40081258 PS : 0x00000016 A0 : 0x40080306 A1 : 0x3ffc01b0
Attachments
Output.PNG
Output.PNG (42.6 KiB) Viewed 5578 times

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 crashes if I use vTaskDelay in app_main function

Postby ESP_Sprite » Mon Sep 14, 2020 7:48 am

Hard to say. Perhaps the initialization routines you call before the vTaskDelay corrupt something? What happens if you comment those out?

abansal22
Posts: 105
Joined: Wed Apr 22, 2020 8:24 am

Re: ESP32 crashes if I use vTaskDelay in app_main function

Postby abansal22 » Mon Sep 14, 2020 5:28 pm

mdaupu wrote:
Sun Sep 13, 2020 6:52 pm
Hello everyone,
I have written a simple program using amazon freertos. I am using ESP32-WROOM-32UE module. If I use vTaskDelay in the app_main function, the ESP32 restarts. But if I use 9 or less than 9 value in the vTaskDelay, it works.

My question is, why esp32 restarts if I use more than 9ms delay in the app_main function?


My Code:

Code: Select all

int app_main(void)
{
      printf("Hello World \r\n");
      prvMiscInitialization();
      config_gpio();
      display_task_create();
      while(1){
        vTaskDelay(100 / portTICK_PERIOD_MS);
      }
  return 0;
}
Error Code:
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
Debug exception reason: BREAK instr
Core 0 register dump:
PC : 0x40081258 PS : 0x00000016 A0 : 0x40080306 A1 : 0x3ffc01b0
Could you post the entire code and also let me know from where you get the source I could execute and let you know if same problem is with me or not!

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: ESP32 crashes if I use vTaskDelay in app_main function

Postby PeterR » Mon Sep 14, 2020 9:07 pm

Great offer!

Or try adding 10K to your main & display task. You have a simple program so do 10/20K as a no brainer - you have the ram. Premature optimisation & all....
9 out of 10 crash issues tend to be stack size (assuming you know one end of a pointer from another).
LOG/printf() will burn a lot of stack & stack issues are hard to debug as you cannot diagnostic printf() without dieing (doh!)

If +10K stack doesn't do you then your into daft pointer issues IMHO.
Last edited by PeterR on Tue Sep 15, 2020 10:47 am, edited 1 time in total.
& I also believe that IDF CAN should be fixed.

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 crashes if I use vTaskDelay in app_main function

Postby chegewara » Mon Sep 14, 2020 9:56 pm

Just idea, are you sure that display_task_create(); task does not exit?
I see you are using esp-idf v3.3 and im not 100% sure that exiting task will display proper error message.

mdaupu
Posts: 2
Joined: Sun Sep 13, 2020 6:23 pm

Re: ESP32 crashes if I use vTaskDelay in app_main function

Postby mdaupu » Fri Sep 18, 2020 6:50 pm

Thank you guys for your replies. I have found the solution of this issue. In the main.c file, there is a define named IDLE_TASK_SIZE. The value was 100. I have changed it to 1000. Now I can use different vTaskDelay in the app_main function. The ESP32 does not reset now.
Attachments
main.JPG
main.JPG (105.55 KiB) Viewed 5397 times

Who is online

Users browsing this forum: No registered users and 115 guests