Skip to content

Commit

Permalink
Little FS
Browse files Browse the repository at this point in the history
  • Loading branch information
dzurikmiroslav committed Feb 22, 2024
1 parent d12e9ed commit b702a1a
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ sdkconfig.old
.project
.settings
.vscode
managed_components
2 changes: 1 addition & 1 deletion components/protocols/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "src"
EMBED_FILES "${embed_files}"
PRIV_REQUIRES nvs_flash esp_http_server esp_wifi esp_timer esp_https_ota driver app_update json vfs spiffs mbedtls
PRIV_REQUIRES nvs_flash esp_http_server esp_wifi esp_timer esp_https_ota driver app_update json vfs littlefs mbedtls
REQUIRES config network modbus script serial logger)
8 changes: 4 additions & 4 deletions components/protocols/src/http_dav.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include <sys/param.h>
#include "esp_log.h"
#include "esp_vfs.h"
#include "esp_spiffs.h"
#include "esp_littlefs.h"

#include "http_web.h"
#include "http.h"

#define DAV_BASE_PATH "/dav"
#define DAV_BASE_PATH_LEN 4
#define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
#define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_LITTLEFS_OBJ_NAME_LEN)
#define SCRATCH_BUFSIZE 1024

static const char* TAG = "http_dav";
Expand Down Expand Up @@ -77,10 +77,10 @@ static void propfind_response_directory(httpd_req_t* req, const char* path)
size_t total = 0, used = 0;
char str[16];
if (strcmp(path, "/cfg/") == 0) {
esp_spiffs_info("cfg", &total, &used);
esp_littlefs_info("cfg", &total, &used);
}
if (strcmp(path, "/data/") == 0) {
esp_spiffs_info("data", &total, &used);
esp_littlefs_info("data", &total, &used);
}

httpd_resp_send_chunk(req, "<response>\n", HTTPD_RESP_USE_STRLEN);
Expand Down
1 change: 0 additions & 1 deletion components/protocols/src/http_rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#define REST_BASE_PATH "/api/v1"
#define SCRATCH_BUFSIZE 1024
#define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
#define MAX_JSON_SIZE (50*1024) // 50 KB
#define MAX_JSON_SIZE_STR "50KB"
#define OTA_VERSION_URL "https://dzurikmiroslav.github.io/esp32-evse/firmware/version.txt"
Expand Down
15 changes: 15 additions & 0 deletions dependencies.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dependencies:
idf:
component_hash: null
source:
type: idf
version: 5.2.0
joltwallet/littlefs:
component_hash: 075fcf1e09264b6ca651bd7c7957145e219ec6e61b5f6ed8f721922224041685
source:
service_url: https://api.components.espressif.com/
type: service
version: 1.5.5
manifest_hash: 1b1169ee1e8134f0de14d0bed748f460840348a432e954b6b7fdaf02d59d8fa1
target: esp32
version: 1.0.0
2 changes: 1 addition & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ register_component()
if(CONFIG_BOARD_CONFIG_DEPLOY)
set(CFG_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cfg/${CONFIG_BOARD_CONFIG}")
if(EXISTS ${CFG_SRC_DIR}/board.cfg)
spiffs_create_partition_image(cfg ${CFG_SRC_DIR} FLASH_IN_PROJECT)
littlefs_create_partition_image(cfg ${CFG_SRC_DIR} FLASH_IN_PROJECT)
else()
message(FATAL_ERROR "${CFG_SRC_DIR}/board.cfg doesn't exit")
endif()
Expand Down
6 changes: 6 additions & 0 deletions main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## IDF Component Manager Manifest File
dependencies:
joltwallet/littlefs: "==1.5.5"
## Required IDF version
idf:
version: ">=5.2.0"
16 changes: 7 additions & 9 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "esp_err.h"
#include "nvs_flash.h"
#include "esp_event.h"
#include "esp_spiffs.h"
#include "esp_littlefs.h"
#include "driver/gpio.h"

#include "evse.h"
Expand Down Expand Up @@ -137,10 +137,10 @@ static void button_init(void)
ESP_ERROR_CHECK(gpio_isr_handler_add(board_config.button_wifi_gpio, button_isr_handler, NULL));
}

static void fs_info(esp_vfs_spiffs_conf_t* conf)
static void fs_info(esp_vfs_littlefs_conf_t* conf)
{
size_t total = 0, used = 0;
esp_err_t ret = esp_spiffs_info(conf->partition_label, &total, &used);
esp_err_t ret = esp_littlefs_info(conf->partition_label, &total, &used);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to get partition %s information %s", conf->partition_label, esp_err_to_name(ret));
} else {
Expand All @@ -150,21 +150,19 @@ static void fs_info(esp_vfs_spiffs_conf_t* conf)

static void fs_init(void)
{
esp_vfs_spiffs_conf_t cfg_conf = {
esp_vfs_littlefs_conf_t cfg_conf = {
.base_path = "/cfg",
.partition_label = "cfg",
.max_files = 1,
.format_if_mount_failed = false
};
ESP_ERROR_CHECK(esp_vfs_spiffs_register(&cfg_conf));
ESP_ERROR_CHECK(esp_vfs_littlefs_register(&cfg_conf));

esp_vfs_spiffs_conf_t data_conf = {
esp_vfs_littlefs_conf_t data_conf = {
.base_path = "/data",
.partition_label = "data",
.max_files = 5,
.format_if_mount_failed = true
};
ESP_ERROR_CHECK(esp_vfs_spiffs_register(&data_conf));
ESP_ERROR_CHECK(esp_vfs_littlefs_register(&data_conf));

fs_info(&cfg_conf);
fs_info(&data_conf);
Expand Down
14 changes: 7 additions & 7 deletions partitions.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, , 0x2000,
app0, app, ota_0, , 1856K,
app1, app, ota_1, , 1856K,
cfg, data, spiffs, , 16K,
data, data, spiffs, , 304K,
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, , 0x2000,
app0, app, ota_0, , 1856K,
app1, app, ota_1, , 1856K,
cfg, data, littlefs, , 16K,
data, data, littlefs, , 304K,

0 comments on commit b702a1a

Please sign in to comment.