Add SPIFFS
This commit is contained in:
parent
54a8879924
commit
2d108751db
|
@ -3,5 +3,6 @@
|
|||
nvs, data, nvs, , 0x4000,
|
||||
otadata, data, ota, , 0x2000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, , 1952k,
|
||||
ota_1, app, ota_1, , 1952k,
|
||||
storage, data, spiffs, , 512k,
|
||||
ota_0, app, ota_0, , 1728k,
|
||||
ota_1, app, ota_1, , 1728k,
|
|
27
src/main.c
27
src/main.c
|
@ -7,6 +7,7 @@
|
|||
#include "nvs_flash.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_spiffs.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
#include "artnet.h"
|
||||
|
@ -173,6 +174,32 @@ void app_main(void) {
|
|||
strncpy(hostname, CONFIG_PROJ_DEFAULT_HOSTNAME, hostname_length - 1);
|
||||
}
|
||||
|
||||
esp_vfs_spiffs_conf_t spiffs_config = {
|
||||
.base_path = "/spiffs",
|
||||
.partition_label = NULL,
|
||||
.max_files = 5,
|
||||
.format_if_mount_failed = true
|
||||
};
|
||||
ESP_LOGI(LOG_TAG, "Initializing SPIFFS");
|
||||
ret = esp_vfs_spiffs_register(&spiffs_config);
|
||||
if (ret != ESP_OK) {
|
||||
if (ret == ESP_FAIL) {
|
||||
ESP_LOGE(LOG_TAG, "Failed to mount or format filesystem");
|
||||
} else if (ret == ESP_ERR_NOT_FOUND) {
|
||||
ESP_LOGE(LOG_TAG, "Failed to find SPIFFS partition");
|
||||
} else {
|
||||
ESP_LOGE(LOG_TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
|
||||
}
|
||||
return;
|
||||
}
|
||||
size_t total = 0, used = 0;
|
||||
ret = esp_spiffs_info(spiffs_config.partition_label, &total, &used);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(LOG_TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
|
||||
} else {
|
||||
ESP_LOGI(LOG_TAG, "Partition size: total: %d, used: %d", total, used);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_FAN_ENABLED)
|
||||
ESP_ERROR_CHECK(fan_init());
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue