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

Add support for mutliple backends #25

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
11de355
Initial changes
raldone01 Nov 25, 2020
08cee1e
Merge branch 'master' of https://github.com/joltwallet/esp_littlefs i…
raldone01 Nov 25, 2020
de0b20a
Initial changes
raldone01 Nov 25, 2020
7b2db55
Began adapting the vfs layer.
raldone01 Nov 25, 2020
912a50f
Adapted the time functions.
raldone01 Nov 25, 2020
bda05fa
Refactored more functions.
raldone01 Nov 25, 2020
40993fd
Refactored the remaining vfs functions.
raldone01 Nov 25, 2020
a2f4f43
Refactored the remaining vfs functions.
raldone01 Nov 25, 2020
d023bc5
Began writing the abs interface.
raldone01 Nov 26, 2020
d0473ce
Implemented the abs api.
raldone01 Nov 26, 2020
3e83d95
Implemented the flash and ram backends.
raldone01 Nov 27, 2020
846293a
Fixed some errors.
raldone01 Nov 27, 2020
132e8e8
Fixed the tests. Fixed bugs.
raldone01 Dec 1, 2020
14b5fde
Added the sdcard backend. Updated the README.md.
raldone01 Dec 1, 2020
8835286
Ran code cleanup.
raldone01 Dec 1, 2020
f268021
Fixed include directories.
raldone01 Dec 1, 2020
95bc245
Added littlefs component to the embedded project.
raldone01 Dec 7, 2020
4c0ca6a
Improved the sdcard backend.
raldone01 Dec 8, 2020
1f8b9cb
The mount_point string and the sdmmc_card_t are now copied.
raldone01 Dec 20, 2020
6604d61
The mount_point string and the sdmmc_card_t are now copied.
raldone01 Dec 20, 2020
8edfe16
Add the CONFIG_LITTLEFS_UNLINK_CAN_RMDIR esp_littlefs_vfs driver opti…
raldone01 Jan 10, 2021
eb0dd96
Merge branch 'master' into pr/25
raldone01 Jan 10, 2021
f43f160
Merge remote-tracking branch 'github-desktop-raldone01/master' into p…
raldone01 Jan 10, 2021
22f5e22
Allocate one dma capable buffer for sdcard access.
raldone01 Jul 22, 2021
3283deb
Merge branch 'master' into pullReq
raldone01 Jul 22, 2021
e7b1d5e
Merge remote-tracking branch 'foreign/master' into pullReq
raldone01 Apr 17, 2022
c744bfd
Catchup to upstream.
raldone01 Apr 17, 2022
2cb45c1
Merge upstream changes.
raldone01 Apr 17, 2022
71527c8
Merge upstream changes.
raldone01 Apr 17, 2022
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
20 changes: 20 additions & 0 deletions .github/workflows/esp_upload_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Push LittleFS to Espressif Component Service

on:
push:
branches:
- master

jobs:
upload_components:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: recursive
- name: Upload component to component service
uses: espressif/github-actions/upload_components@master
with:
name: "LittleFS"
namespace: "joltwallet"
api_token: ${{ secrets.ESP_IDF_COMPONENT_API_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build firmware

on:
push:
pull_request:
branches:
- main

# Based on https://github.com/igrr/libnmea-esp32/blob/main/.github/workflows/build.yml
jobs:
build-component:
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
idf_ver: ["v4.1", "v4.2", "v4.3"]
idf_target: ["esp32"]
include:
- idf_ver: "v4.2"
idf_target: esp32s2
- idf_ver: "v4.3"
idf_target: esp32c3
runs-on: ubuntu-latest
container: espressif/idf:release-${{ matrix.idf_ver }}
steps:
- name: Update git
run: |
apt update
apt install -y software-properties-common
add-apt-repository -y ppa:git-core/ppa
apt update
apt install -y git
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build for ESP32
env:
IDF_TARGET: ${{ matrix.idf_target }}
shell: bash
run: |
. ${IDF_PATH}/export.sh
cd example
idf.py build

build-tests:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: recursive
- name: esp-idf build
uses: BrianPugh/esp-idf-ci-action@main
with:
esp_idf_version: v4.2.3
action: "make defconfig && make -j8 tests-build"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
build/
sdkconfig
sdkconfig.old
**/cmake-build-debug

example/build/
example/sdkconfig
example/sdkconfig.old

*.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "main/littlefs"]
path = src/littlefs
url = https://github.com/littlefs-project/littlefs.git
[submodule "mklittlefs"]
path = mklittlefs
url = https://github.com/BrianPugh/mklittlefs.git
26 changes: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@ cmake_minimum_required(VERSION 3.10)
if (NOT DEFINED PROJECT_NAME)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp_littlefs)
else ()
file(GLOB SOURCES src/littlefs/*.c)
list(APPEND SOURCES src/esp_littlefs.c src/littlefs_api.c)
idf_component_register(
endif (NOT DEFINED PROJECT_NAME)

list(APPEND SOURCES
src/esp_littlefs_flash.c
src/esp_littlefs_ram.c
src/esp_littlefs_sdcard.c
src/esp_littlefs_vfs.c
src/esp_littlefs_abs.c
src/littlefs/lfs.c
src/littlefs/lfs_util.c
)
idf_component_register(
SRCS ${SOURCES}
INCLUDE_DIRS src include
REQUIRES spi_flash)
endif (NOT DEFINED PROJECT_NAME)
PRIV_INCLUDE_DIRS src
REQUIRES spi_flash sdmmc
PRIV_REQUIRES esptool_py)

set_source_files_properties(
${SOURCES}
PROPERTIES COMPILE_FLAGS "-DLFS_CONFIG=lfs_config.h"
)
85 changes: 20 additions & 65 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,91 +1,37 @@
menu "LittleFS"

config LITTLEFS_MAX_PARTITIONS
int "Maximum Number of Partitions"
default 3
range 1 10
help
Define maximum number of partitions that can be mounted.

config LITTLEFS_PAGE_SIZE
int "SPIFFS logical page size"
default 256
range 256 1024
help
Logical page size of LITTLEFS partition, in bytes. Must be multiple
of flash page size (which is usually 256 bytes).
Larger page sizes reduce overhead when storing large files, and
improve filesystem performance when reading large files.
Smaller page sizes reduce overhead when storing small (< page size)
files.

config LITTLEFS_OBJ_NAME_LEN
int "Maximum object name length including NULL terminator."
default 64
range 16 1024
help
Includes NULL-terminator.

config LITTLEFS_READ_SIZE
int "Minimum size of a block read."
default 128
help
Minimum size of a block read. All read operations will be a
multiple of this value.

config LITTLEFS_WRITE_SIZE
int "Minimum size of a block write."
default 128
help
Minimum size of a block program. All write operations will be a
multiple of this value.

config LITTLEFS_LOOKAHEAD_SIZE
int "Look ahead size."
default 128
help
Look ahead size. Must be a multiple of 8.

config LITTLEFS_CACHE_SIZE
int "Cache Size"
default 512
help
Size of block caches. Each cache buffers a portion of a block in RAM.
The littlefs needs a read cache, a program cache, and one additional
cache per file. Larger caches can improve performance by storing more
data and reducing the number of disk accesses. Must be a multiple of
the read and program sizes, and a factor of the block size (4096).

config LITTLEFS_BLOCK_CYCLES
int "LittleFS wear-leveling block cycles"
default 512
range -1 1024
help
Number of erase cycles before littlefs evicts metadata logs and moves
the metadata to another block. Suggested values are in the
range 100-1000, with large values having better performance at the cost
of less consistent wear distribution.
Set to -1 to disable block-level wear-leveling.

config LITTLEFS_USE_MTIME
bool "Save file modification time"
default "y"
help
Saves timestamp on modification. Uses an additional 4bytes.

config LITTLEFS_USE_ONLY_HASH
bool "Don't store filepath in the file descriptor"
default "n"
help
Records the filepath only as a 32-bit hash in the file descriptor instead
of the entire filepath. Saves approximately `sizeof(filepath)` bytes
per file descriptor.
If enabled, functionality (like fstat) that requires the file path
If enabled, functionality (like fstat) that requires the file path
from the file descriptor will not work.
In rare cases, may cause unlinking or renaming issues (unlikely) if
there's a hash collision between an open filepath and a filepath
to be modified.

config LITTLEFS_UNLINK_CAN_RMDIR
bool "Allow unlink to delete empty directories"
default "n"
help
Setting this to true allows the remove function to delete empty directories. https://www.cplusplus.com/reference/cstdio/remove/
This is necessary for the ghc::filesystem to be able to delete folders.

config LITTLEFS_HUMAN_READABLE
bool "Make errno human-readable"
default "n"
Expand All @@ -111,7 +57,7 @@ menu "LittleFS"
Saves nonce on modification; intended for detecting filechanges
on systems without access to a RTC.

A file who's nonce is the same as it was at a previous time has
A file who's nonce is the same as it was at a previous time has
high probability of not having been modified.

Upon file modification, the nonce is incremented by one. Upon file
Expand All @@ -127,11 +73,20 @@ menu "LittleFS"
default "n"
help
Enabling this feature allows for greater drop-in compatability
when replacing SPIFFS. Since SPIFFS doesn't have folders, and
when replacing SPIFFS. Since SPIFFS doesn't have folders, and
folders are just considered as part of a file name, enabling this
will automatically create folders as necessary to create a file
instead of throwing an error. Similarly, upon the deletion of the
last file in a folder, the folder will be deleted. It is recommended
to only enable this flag as a stop-gap solution.

config LITTLEFS_FLUSH_FILE_EVERY_WRITE
bool "Flush file to flash after each write operation"
default "n"
help
Enabling this feature extends SPIFFS capability.
In SPIFFS data is written immediately to the flash storage when fflush() function called.
In LittleFS flush() does not write data to the flash, and fsync() call needed after.
With this feature fflush() will write data to the storage.

endmenu
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ include $(IDF_PATH)/make/project.mk

.PHONY: tests

tests-build:
$(MAKE) \
TEST_COMPONENTS='src'

tests:
$(MAKE) \
TEST_COMPONENTS='src' \
Expand Down
Loading