Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program crashes when adding wifi support #39

Closed
cbarransunny opened this issue Dec 7, 2019 · 13 comments
Closed

Program crashes when adding wifi support #39

cbarransunny opened this issue Dec 7, 2019 · 13 comments
Labels
stale This will not be worked on

Comments

@cbarransunny
Copy link

cbarransunny commented Dec 7, 2019

We use GitHub issues for development related discussions.
Please use the forum to ask questions.

Describe the issue
added wifi station code from esp-idf mqtt example:
https://github.com/espressif/esp-idf/blob/release/v3.3/examples/protocols/mqtt/tcp/main/app_main.c#L171

Code to reproduce the issue

  esp_register_freertos_tick_hook(lv_tick_task);
  xTaskCreate(display_task, "display_task", 2048, NULL, 5, NULL); 
  esp_err_t error_test = nvs_flash_init();
  if(error_test == ESP_OK)
  {
    wifi_init_sta();
  }
  while(1)
  {
		vTaskDelay(1000/portTICK_PERIOD_MS);
	}
}

static void display_task(void *pvParameter)
{
  Demo();
  while(1) {
		vTaskDelay(5/portTICK_PERIOD_MS);
		lv_task_handler();
	}

}

Expected Results
The display shows to demo and wifi connects
Actual Results
Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed)
ESP32 Chip version

ESP-IDF version
3.3
Development kit used
NodeMCU 32s
Development machine OS
Windows 10, Platoformio
Compilation warnings/errors (if available)

If possible, copy the compilation log into a file and attach it here

@stale
Copy link

stale bot commented Dec 28, 2019

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Dec 28, 2019
@embeddedt
Copy link
Member

Not stale. (I can't help with this issue as I don't use ESP32.)

@stale stale bot removed the stale This will not be worked on label Dec 28, 2019
@embeddedt
Copy link
Member

@kisvegabor @amirgon Perhaps one of you can help with this?

@amirgon
Copy link

amirgon commented Jan 16, 2020

Where is the stack trace?
On a crash report, the very minimum is providing a parsed stack trace.

@justbarran
Copy link

Problem was solved by running Littlevgl only on core 1 while wifi and everything else runs on core 0. And using esp_timer_start_periodic(_lv_tick_timer, LV_TICK_MS*1000) to run the ticker.

@embeddedt
Copy link
Member

It's probably a concurrency issue (LittlevGL needs you to wrap calls with some type of synchronization primitive to work with multithreaded systems).

@jeremyjh
Copy link
Contributor

I should have noticed that just looking at this code, I had a similar thing happen to me. I use a pinned task to run the lv_task_handler(). I felt better about that approach than adding a mutex because there is absolutely no chance of a deadlock.

@justbarran
Copy link

Yea the main problem came from esp_register_freertos_tick_hook(lv_tick_task); This should never be used. And I used a Recursive mutex around the LittleVGL functions.

@monkeytronics
Copy link
Sponsor

Hey guys. I've just got this up and running on ESP32, but am crashing every couple of minutes... I am using esp_register_freertos_tick_hook(lv_tick_task); So, I guess I'm not doing it right?! I posted the stack trace and some extra info here:

espressif/esp-iot-solution#37 (comment)

Any chance you guys know what I'm doing wrong?? Thanks all.

@amirgon
Copy link

amirgon commented Jan 23, 2020

Any chance you guys know what I'm doing wrong?? Thanks all.

  • One thing I don't understand about your code: from the stack trace it looks like ili9341_flush is calling vPortYield.
    However, I don't see where vPortYield is called anywhere in this project.
    Did you change ili9341? Where are your sources?

  • Try to run it all on a single core (disable the second core when configuring ESP32) and check if the problem still happens. Even if the problem is still there, it would be easier to debug.

@monkeytronics
Copy link
Sponsor

Hmmm. I just downloaded the ili9341 code from here. I haven't touched it at all.

I've just built it again on a single core like you suggested. It's been running for a half hour now without crashing... It looks encouraging that you've fixed the immediate fault. Any idea why it might have been crashing with the dual core. Suggestions above that using esp_register_freertos_tick_hook(lv_tick_task) is a bad thing. Any clue as to why that is? Is there a better ESP32 approach somewhere? I don't really need the processing power as it happens, but keen to keep my code robust if possible...

Cheers,

@amirgon
Copy link

amirgon commented Jan 23, 2020

Hmmm. I just downloaded the ili9341 code from here. I haven't touched it at all.

Your stack trace:

0x4009742d: vPortYield at C:/msys32/home/thebi/esp/esp-idf/components/freertos/portasm.S:555
0x40142d70: ili9341_flush at C:/msys32/home/thebi/esp/esp-jumpstart/components/lvgl_ili9341/ili9341.c:130

Code from here:
https://github.com/littlevgl/lv_port_esp32_ili9341/blob/edf5bf19083e911876318c0842c091a6dfdc6d24/components/lvgl_ili9341/ili9341.c#L127-L137

That doesn't add up. line 130 on ili9341.c is an empty line, but on your stack trace it's calling vPortYield.
Are you aligned to HEAD?

Suggestions above that using esp_register_freertos_tick_hook(lv_tick_task) is a bad thing

I would try using xTimerCreate for calling lv_tick_inc, and xTaskCreate pinned to core for calling lv_task_handler (with some delay inside to yield).

I'm doing something like that on modlvesp32 (although I'm using micropython scheduler instead of xTaskCreate, but under the hoods micropython is calling xTaskCreate).

@stale
Copy link

stale bot commented Feb 13, 2020

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Feb 13, 2020
@stale stale bot closed this as completed Feb 20, 2020
NickXia007 pushed a commit to NickXia007/lv_port_esp32 that referenced this issue Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants