custom memory partition on ESP32-c6

MohamedTrabelsi
Posts: 4
Joined: Fri Nov 03, 2023 4:07 pm

custom memory partition on ESP32-c6

Postby MohamedTrabelsi » Fri Nov 03, 2023 4:31 pm

Hello guys,
I'm working on a project that needs to store configuration data on the flash memory so I generated this csv file
then I tried to initialize the desired partition using a this function
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "nvs_flash.h"
  5.  
  6.  
  7. void init_nvs(const char *partition_name) {
  8.     esp_err_t ret = nvs_flash_init_partition(partition_name);
  9.     if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  10.         ESP_ERROR_CHECK(nvs_flash_erase_partition(partition_name));
  11.         ret = nvs_flash_init_partition(partition_name);
  12.         printf("done");
  13.     }
  14.     ESP_ERROR_CHECK(ret);
  15.     printf("error");
  16. }
  17.  
  18. void app_main() {
  19.    
  20.     init_nvs("wifi");
  21. }
but I got error and that how it looks like
Attachments
log.PNG
log
log.PNG (47.47 KiB) Viewed 1393 times
Capture3.PNG
error
Capture3.PNG (77.02 KiB) Viewed 1393 times
Capture2.PNG
partitions.cvs
Capture2.PNG (16.35 KiB) Viewed 1393 times

ESP_adokitkat
Posts: 50
Joined: Thu Jun 22, 2023 12:50 pm

Re: custom memory partition on ESP32-c6

Postby ESP_adokitkat » Mon Nov 06, 2023 2:41 am

Hello.

The minimal size for a NVS partition is 0x3000 bytes and recommended size is 0x6000 bytes. It seems like you put sizes too small (0x24 and 0x4 bytes) into the partition table .csv file (which you don't need to do - when left blank it the partition will start from the offset to the next one). However, the difference in your offsets is too little as well to fit 0x3000 or 0x6000 bytes there (0xa000-0x9000=0x1000).

Also I don't think need to create so many NVS partitions - create just one and use namespaces to avoid key name conflicts (1 nvs partition with 6 namespaces: ap1, ap2, ap3, wifi, ble, cfg).

Code: Select all

# Partition table .csv file
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
...

MohamedTrabelsi
Posts: 4
Joined: Fri Nov 03, 2023 4:07 pm

Re: custom memory partition on ESP32-c6

Postby MohamedTrabelsi » Mon Nov 06, 2023 10:06 am

Thank you for pointing out the partition size discrepancy.
Regarding the suggestion to create just one NVS partition with multiple namespaces, that makes a lot of sense.
Thanks again for your assistance.

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 92 guests