Custom partition table make slow boot

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Custom partition table make slow boot

Postby urbanze » Thu Mar 22, 2018 5:03 pm

I am doing an internal LOG using NVS and needed to change the size of the partition. The default is 24K and now I put 1M, however, the boot takes ~ 7 seconds to happen (when the device starts, an indicative LED go ON).

Did I do something wrong? Does changing the factory to the first one on the list do any issue?

How to fix this slow boot?


Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
factory,  app,  factory, 0x10000, 1M,
nvs,      data, nvs,     ,  1M,
phy_init, data, phy,     ,  4K,

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Custom partition table make slow boot

Postby loboris » Thu Mar 22, 2018 7:23 pm

Your partition table is wrong.

See the Partition table documentation

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Custom partition table make slow boot

Postby urbanze » Thu Mar 22, 2018 8:02 pm

loboris wrote:Your partition table is wrong.

See the Partition table documentation
Where? I only change offset, size and order.
Offset is automatic, size is my choise and order..?

nvs need to be first? If it's wrong, why work?

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Custom partition table make slow boot

Postby fly135 » Thu Mar 22, 2018 8:31 pm

Did you notice this line in the partition file?

"# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild"

I guess they mean the "defaults" in ...components/partition/Kconfig.projbuild. But if you ran make menuconfig and assigned the correct values then I figure you are good.

John A

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Custom partition table make slow boot

Postby ESP_igrr » Fri Mar 23, 2018 3:55 am

Initializing a 1MB NVS partition can take quite a large amount of time. nvs_flash_init will need to read through all the partition, build the list of 256 pages, and figure out if there are any errors in data.

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Custom partition table make slow boot

Postby urbanze » Fri Mar 23, 2018 11:08 am

ESP_igrr wrote:Initializing a 1MB NVS partition can take quite a large amount of time. nvs_flash_init will need to read through all the partition, build the list of 256 pages, and figure out if there are any errors in data.
I thought about this possibility, however, I refuted the fact that when I use OTA, there are two 1MB partitions and this does not delay the boot.

What can I do to reduce this gigantic delay? 7 seconds is a long time.

I need this NVS with 1MB and also that it is faster.

Markus Becker
Posts: 22
Joined: Fri Mar 02, 2018 3:24 pm

Re: Custom partition table make slow boot

Postby Markus Becker » Fri Mar 23, 2018 1:02 pm

executing

Code: Select all

   ESP_LOGI( TAG, "Initializing NVS..")
    esp_err_t err = nvs_flash_init();
    if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
        // NVS partition was truncated and needs to be erased
        // Retry nvs_flash_init
        ESP_ERROR_CHECK(nvs_flash_erase());
        err = nvs_flash_init();
    }
    ESP_ERROR_CHECK(err);
    ESP_LOGI( TAG, "NVS up.")
having a large NVS partition of

Code: Select all

nvs,      data, nvs,     0x310000, 0x0f0000
prints in monitor

Code: Select all

I (45) APP: Initializing NVS..
I (120) APP: NVS up.
which means, initialization completes within 75ms if formating is not needed. I did not test 1M size though.

Best
Markus

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Custom partition table make slow boot

Postby urbanze » Fri Mar 23, 2018 1:30 pm

Markus Becker wrote:executing

Code: Select all

   ESP_LOGI( TAG, "Initializing NVS..")
    esp_err_t err = nvs_flash_init();
    if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
        // NVS partition was truncated and needs to be erased
        // Retry nvs_flash_init
        ESP_ERROR_CHECK(nvs_flash_erase());
        err = nvs_flash_init();
    }
    ESP_ERROR_CHECK(err);
    ESP_LOGI( TAG, "NVS up.")
having a large NVS partition of

Code: Select all

nvs,      data, nvs,     0x310000, 0x0f0000
prints in monitor

Code: Select all

I (45) APP: Initializing NVS..
I (120) APP: NVS up.
which means, initialization completes within 75ms if formating is not needed. I did not test 1M size though.

Best
Markus
The delay is before app_main() begin, see how the print of the log was.

Code: Select all

I (177) cpu_start: Pro cpu up.
I (177) cpu_start: Starting app cpu, entry point is 0x40081244
0x40081244: call_start_cpu1 at /home/ze/esp/esp-idf/components/esp32/./cpu_start.c:225

I (0) cpu_start: App cpu up.
I (180) heap_init: Initializing. RAM available for dynamic allocation:
I (187) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (193) heap_init: At 3FFB8E80 len 00027180 (156 KiB): DRAM
I (199) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (205) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (212) heap_init: At 4008E270 len 00011D90 (71 KiB): IRAM
I (218) cpu_start: Pro cpu start user code
I (235) cpu_start: Starting scheduler on PRO CPU.
[b]I (0) cpu_start: Starting scheduler on APP CPU.
I (12606) ESP32: Initializing NVS..
I (12606) ESP32: done[/b]


User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Custom partition table make slow boot

Postby urbanze » Fri Mar 23, 2018 8:40 pm

fly135 wrote:Did you notice this line in the partition file?

"# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild"

I guess they mean the "defaults" in ...components/partition/Kconfig.projbuild. But if you ran make menuconfig and assigned the correct values then I figure you are good.

John A
Yes, I did this change.

How can I increase boot time with large NVS? Help guys :(

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Custom partition table make slow boot

Postby fly135 » Sat Mar 24, 2018 3:59 pm

Can you create a fat file system in a 1M partition and save your data there instead? Then you won't get the last delay on boot.

John A

Who is online

Users browsing this forum: Majestic-12 [Bot] and 86 guests