Why do some examples call nvs_flash_init while others don't (example 01 vs 20)? I assume there is a dependency on the flash for some applications, but I can't trace this dependency for something like example 01. What exactly is the nvs used for?
Also, why do some examples spawn tasks to run most of the program while others run most of the program in the app_main? I assume app_main itself is simply a task, so I don't know if I'm missing something.
Also (and this might be a stretch to ask ) but what generally are the kinds of background processes bring run aside from app_main?
Thanks in advance!
When to use nvs_flash_init and create task
-
- Posts: 1
- Joined: Tue Jan 03, 2017 4:10 am
Re: When to use nvs_flash_init and create task
if you look in esp-idf/components/esp32/cpu_start.c you can see nvs_flash_init() inside a "if defined" clause. I'm guessing you call nvs_flash_init() when you don't define or define CONFIG_ESP32_PHY_AUTO_INIT to 0 in your sdkconfig.
nvs is the non volatile storage, the flash chip on the esp32. you will probably want to use it.
Can be set to flash for example.
Yes app_main is called from a task called main_task spawned in cpu_start.c
Lets say you are going to run a big program and need a lot of stack space, you can either redefine CONFIG_MAIN_TASK_STACK_SIZE in skdconfig which defines the main_task stack. Or start a new task and define your own stack space, after which you can delete the main_task.
I think you can track what happens from cpu_start.c if you wanna know what background stuff is happening. The wdt is also started.
This is all I figured out, please correct me if i'm wrong =)
nvs is the non volatile storage, the flash chip on the esp32. you will probably want to use it.
Code: Select all
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));//instead of WIFI_STORAGE_RAM
Yes app_main is called from a task called main_task spawned in cpu_start.c
Lets say you are going to run a big program and need a lot of stack space, you can either redefine CONFIG_MAIN_TASK_STACK_SIZE in skdconfig which defines the main_task stack. Or start a new task and define your own stack space, after which you can delete the main_task.
I think you can track what happens from cpu_start.c if you wanna know what background stuff is happening. The wdt is also started.
This is all I figured out, please correct me if i'm wrong =)
Who is online
Users browsing this forum: Majestic-12 [Bot] and 92 guests