[已解决] 求助,spiffs初始化失败,报错ESP_ERR_INVALID_ARG
Posted: Wed Jun 23, 2021 10:37 am
芯片:ESP32-WROVER-B
IDF版本:release/v4.3
开发环境:Windows10
各位好,我遇到spiffs初始化失败的问题,但我感觉我给的config应该没啥问题?
然后串口打印如下
我的sdkconfig里spiffs相关的内容如下
IDF版本:release/v4.3
开发环境:Windows10
各位好,我遇到spiffs初始化失败的问题,但我感觉我给的config应该没啥问题?
整段代码如下:esp_vfs_spiffs_conf_t conf = {
.base_path = "/abcdefghi_files", .partition_label = NULL, .max_files = 4, .format_if_mount_failed = false};
Code: Select all
void storageInit() {
static const char* tag = "storageInit";
ESP_LOGD(tag, "storageInit() called");
esp_vfs_spiffs_conf_t conf = {
.base_path = "/abcdefghi_files", .partition_label = NULL, .max_files = 4, .format_if_mount_failed = false};
// Use settings defined above to initialize and mount SPIFFS filesystem.
// Note: esp_vfs_spiffs_register is an all-in-one convenience function.
esp_err_t ret = esp_vfs_spiffs_register(&conf);
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGE(tag, "Failed to mount or format filesystem");
throw std::runtime_error("fail to mount");
} else if (ret == ESP_ERR_NOT_FOUND) {
ESP_LOGE(tag, "Failed to find SPIFFS partition");
throw std::runtime_error("no partition");
} else {
ESP_LOGE(tag, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
throw std::runtime_error("fail to init");
}
return;
}
size_t total = 0, used = 0;
ret = esp_spiffs_info(NULL, &total, &used);
if (ret != ESP_OK) {
ESP_LOGE(tag, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
} else {
ESP_LOGD(tag, "Partition size: total: %d, used: %d", total, used);
}
}
请问这个ESP_ERR_INVALID_ARG是怎么导致的?D (1823) storageInit: storageInit() called
D (1833) partition: Loading the partition table
D (1843) SPIFFS: SPIFFS_mount sz:0 logpgsz:0 logblksz:0 perasz:0 addr:00000000 fdsz:192 cachesz:1124
D (1923) SPIFFS: page index byte len: 256
D (1923) SPIFFS: object lookup pages: 1
D (1923) SPIFFS: page pages per block: 16
D (1923) SPIFFS: page header length: 5
D (1933) SPIFFS: object header index entries: 87
D (1933) SPIFFS: object index entries: 124
D (1943) SPIFFS: available file descriptors: 4
D (1943) SPIFFS: free blocks: 255
D (1953) SPIFFS: SPIFFS_unmount
E (1953) storageInit: Failed to initialize SPIFFS (ESP_ERR_INVALID_ARG)
我的sdkconfig里spiffs相关的内容如下
partition如下:#
# SPIFFS Configuration
#
CONFIG_SPIFFS_MAX_PARTITIONS=3
#
# SPIFFS Cache Configuration
#
CONFIG_SPIFFS_CACHE=y
CONFIG_SPIFFS_CACHE_WR=y
# CONFIG_SPIFFS_CACHE_STATS is not set
# end of SPIFFS Cache Configuration
CONFIG_SPIFFS_PAGE_CHECK=y
CONFIG_SPIFFS_GC_MAX_RUNS=10
# CONFIG_SPIFFS_GC_STATS is not set
CONFIG_SPIFFS_PAGE_SIZE=256
CONFIG_SPIFFS_OBJ_NAME_LEN=128
# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set
CONFIG_SPIFFS_USE_MAGIC=y
CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
CONFIG_SPIFFS_META_LENGTH=4
CONFIG_SPIFFS_USE_MTIME=y
#
# Debug Configuration
#
CONFIG_SPIFFS_DBG=y
CONFIG_SPIFFS_API_DBG=y
CONFIG_SPIFFS_GC_DBG=y
# CONFIG_SPIFFS_CACHE_DBG is not set
CONFIG_SPIFFS_CHECK_DBG=y
CONFIG_SPIFFS_TEST_VISUALISATION=y
# end of Debug Configuration
# end of SPIFFS Configuration
storage里面只有一个文件,文件名长度24字节,文件大小46字节# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
storage, data, spiffs, , 1M,