When to use nvs_flash_init and create task

RicardoStephen
Posts: 1
Joined: Tue Jan 03, 2017 4:10 am

When to use nvs_flash_init and create task

Postby RicardoStephen » Thu Jan 05, 2017 12:23 am

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 :D) but what generally are the kinds of background processes bring run aside from app_main?

Thanks in advance!

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: When to use nvs_flash_init and create task

Postby f.h-f.s. » Fri Jan 20, 2017 10:08 am

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.

Code: Select all

ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));//instead of WIFI_STORAGE_RAM
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 =)

Who is online

Users browsing this forum: No registered users and 121 guests