Skip to content

Commit

Permalink
Merge pull request #215 from Adam5Wu/compat/support_esp8266_rtos
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh authored Jan 22, 2025
2 parents 1d30193 + b0dbabb commit 1aeae11
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ 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)
list(APPEND pub_requires esp_partition)
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}
Expand Down
5 changes: 5 additions & 0 deletions include/esp_littlefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/esp_littlefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1aeae11

Please sign in to comment.