Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make this library compatible for ESP8266 RTOS SDK. #215

Merged
merged 8 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 priv_requires sdmmc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure sdmmc has to be in pub_requires because it is referenced in the public include/esp_littlefs.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, PTAL~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's in pub_requires, then we don't have to add it to priv_requires, so we should be able to delete this line (line 8).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. I am not very familar with the conventions. :P

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
BrianPugh marked this conversation as resolved.
Show resolved Hide resolved

#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
4 changes: 4 additions & 0 deletions src/esp_littlefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,13 +899,17 @@ static int esp_littlefs_flags_conv(int m) {

static void esp_littlefs_take_efs_lock(void) {
if( _efs_lock == NULL ){
#ifdef ESP32 // ESP8266 only has one core, no need for SMP protection
BrianPugh marked this conversation as resolved.
Show resolved Hide resolved
static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&mux);
#endif
if( _efs_lock == NULL ){
_efs_lock = xSemaphoreCreateMutex();
assert(_efs_lock);
}
#ifdef ESP32
portEXIT_CRITICAL(&mux);
#endif
}

xSemaphoreTake(_efs_lock, portMAX_DELAY);
Expand Down
Loading