Undefined reference to `nvs_flash_secure_init_partition` and to `nvs_flash_read_security_c` when executing flash command

jettyjett
Posts: 4
Joined: Fri Aug 14, 2020 1:23 pm

Undefined reference to `nvs_flash_secure_init_partition` and to `nvs_flash_read_security_c` when executing flash command

Postby jettyjett » Fri Aug 14, 2020 1:34 pm

As mentioned in the title I'm getting an error when running

Code: Select all

idf.py flash monitor

the snippet that causing the problem is the following:

Code: Select all

   #include 'nvs.h'
   #include 'nvs_flash.h'

    // find partition with nvs_keys
    const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
                                                                ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS,
                                                                KEYS_PARTITION_LABEL);

    // read nvs_keys from key partition
    nvs_sec_cfg_t cfg;
    esp_err_t error = nvs_flash_read_security_cfg(partition, &cfg);
    if (error != ESP_OK)
    {
        printf("Failed to read nvs keys (rc=0x%x)", error);
    }

    // initialize the custom nvs partition
    error = nvs_flash_secure_init_partition(PARTITION_LABEL, &cfg);
    if (error != ESP_OK)
    {
        printf("failed to initialize nvs partition (err=0x%x). Aborting.", error);
    };
I added this snippet to the hello world project inside the hello_world_main.c file and under the app_main function.
My goal is to initialize an encrypted custom nvs partition and read its content. Before doing that I managed to create a custom partition without encryption and I successfully read its content.

The error seems like I'm missing an include, but I checked the two functions in question inside my sdk source code and they're both there in the nvs_flash.h file.

Any information is much appreciated

jettyjett
Posts: 4
Joined: Fri Aug 14, 2020 1:23 pm

Re: Undefined reference to `nvs_flash_secure_init_partition` and to `nvs_flash_read_security_c` when executing flash com

Postby jettyjett » Mon Aug 17, 2020 9:27 am

Problem resolved. I had to activate the flag

Code: Select all

CONFIG_NVS_ENCRYPTION
from the menuconfig. It's situated under

Code: Select all

component config/nvs

Who is online

Users browsing this forum: No registered users and 81 guests