From: Ivan Grokhotkov Date: Sun, 28 Jan 2018 15:17:54 +0000 (+0800) Subject: spiffs: add Kconfig option for logical page size X-Git-Tag: v3.1-beta1~429^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=507a3a6391834bf09e922cf6050028c1bbe44578;p=esp-idf spiffs: add Kconfig option for logical page size --- diff --git a/components/spiffs/Kconfig b/components/spiffs/Kconfig index 1f7a196d72..4eeb18762b 100644 --- a/components/spiffs/Kconfig +++ b/components/spiffs/Kconfig @@ -59,6 +59,18 @@ config SPIFFS_GC_STATS Enable/disable statistics on gc. Debug/test purpose only. +config SPIFFS_PAGE_SIZE + int "SPIFFS logical page size" + default 256 + range 256 1024 + help + Logical page size of SPIFFS partition, in bytes. Must be multiple + of flash page size (which is usually 256 bytes). + Larger page sizes reduce overhead when storing large files, and + improve filesystem performance when reading large files. + Smaller page sizes reduce overhead when storing small (< page size) + files. + config SPIFFS_OBJ_NAME_LEN int "Set SPIFFS Maximum Name Length" default 32 diff --git a/components/spiffs/esp_spiffs.c b/components/spiffs/esp_spiffs.c index 2c454e9dd3..83eba96ee4 100644 --- a/components/spiffs/esp_spiffs.c +++ b/components/spiffs/esp_spiffs.c @@ -222,6 +222,14 @@ static esp_err_t esp_spiffs_init(const esp_vfs_spiffs_conf_t* conf) return ESP_ERR_INVALID_STATE; } + uint32_t flash_page_size = g_rom_flashchip.page_size; + uint32_t log_page_size = CONFIG_SPIFFS_PAGE_SIZE; + if (log_page_size % flash_page_size != 0) { + ESP_LOGE(TAG, "SPIFFS_PAGE_SIZE is not multiple of flash chip page size (%d)", + flash_page_size); + return ESP_ERR_INVALID_ARG; + } + esp_partition_subtype_t subtype = conf->partition_label ? ESP_PARTITION_SUBTYPE_ANY : ESP_PARTITION_SUBTYPE_DATA_SPIFFS; const esp_partition_t* partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, @@ -247,7 +255,7 @@ static esp_err_t esp_spiffs_init(const esp_vfs_spiffs_conf_t* conf) efs->cfg.hal_read_f = spiffs_api_read; efs->cfg.hal_write_f = spiffs_api_write; efs->cfg.log_block_size = g_rom_flashchip.sector_size; - efs->cfg.log_page_size = g_rom_flashchip.page_size; + efs->cfg.log_page_size = log_page_size; efs->cfg.phys_addr = 0; efs->cfg.phys_erase_block = g_rom_flashchip.sector_size; efs->cfg.phys_size = partition->size;