diff --git a/CMakeLists.txt b/CMakeLists.txt index bd6d847..3d23559 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ list(APPEND SOURCES src/esp_littlefs.c src/littlefs_esp_part.c src/lfs_config.c) if(CONFIG_LITTLEFS_SDMMC_SUPPORT) list(APPEND SOURCES src/littlefs_sdmmc.c) + list(APPEND pub_requires sdmmc) endif() if(IDF_VERSION_MAJOR GREATER_EQUAL 5) @@ -12,7 +13,7 @@ if(IDF_VERSION_MAJOR GREATER_EQUAL 5) else() list(APPEND pub_requires spi_flash) endif() -list(APPEND priv_requires esptool_py spi_flash vfs sdmmc) +list(APPEND priv_requires esptool_py spi_flash vfs) idf_component_register( SRCS ${SOURCES} diff --git a/include/esp_littlefs.h b/include/esp_littlefs.h index 101445a..ad4fbe5 100644 --- a/include/esp_littlefs.h +++ b/include/esp_littlefs.h @@ -19,6 +19,11 @@ extern "C" { #define ESP_LITTLEFS_VERSION_MINOR 16 #define ESP_LITTLEFS_VERSION_PATCH 2 +#ifdef ESP8266 +// ESP8266 RTOS SDK default enables VFS DIR support +#define CONFIG_VFS_SUPPORT_DIR 1 +#endif + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 2) && CONFIG_VFS_SUPPORT_DIR #define ESP_LITTLEFS_ENABLE_FTRUNCATE #endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 2) diff --git a/src/esp_littlefs.c b/src/esp_littlefs.c index ebc7a88..711dc10 100644 --- a/src/esp_littlefs.c +++ b/src/esp_littlefs.c @@ -899,13 +899,21 @@ static int esp_littlefs_flags_conv(int m) { static void esp_littlefs_take_efs_lock(void) { if( _efs_lock == NULL ){ +#ifdef ESP8266 + taskENTER_CRITICAL(); +#else static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; portENTER_CRITICAL(&mux); +#endif if( _efs_lock == NULL ){ _efs_lock = xSemaphoreCreateMutex(); assert(_efs_lock); } +#ifdef ESP8266 + taskEXIT_CRITICAL(); +#else portEXIT_CRITICAL(&mux); +#endif } xSemaphoreTake(_efs_lock, portMAX_DELAY);