diff --git a/pkg/spiffs/Makefile b/pkg/spiffs/Makefile index d40ea98d32..ee77abd5eb 100644 --- a/pkg/spiffs/Makefile +++ b/pkg/spiffs/Makefile @@ -1,6 +1,6 @@ PKG_NAME=spiffs PKG_URL=https://github.com/pellepl/spiffs.git -PKG_VERSION=39937743fbbec4b82308ee08332bf9180408d23b +PKG_VERSION=287148c46587089c4543a21eef2d6e9e14b88364 PKG_BUILDDIR ?= $(PKGDIRBASE)/$(PKG_NAME) CFLAGS += -std=c11 diff --git a/pkg/spiffs/include/spiffs_config.h b/pkg/spiffs/include/spiffs_config.h index 892b271df2..c9a86109f9 100644 --- a/pkg/spiffs/include/spiffs_config.h +++ b/pkg/spiffs/include/spiffs_config.h @@ -53,19 +53,57 @@ extern "C" { // Set generic spiffs debug output call. #ifndef SPIFFS_DBG -#define SPIFFS_DBG(...) //DEBUG(__VA_ARGS__) +#define SPIFFS_DBG(...) //printf(_f, ## __VA_ARGS__) #endif // Set spiffs debug output call for garbage collecting. #ifndef SPIFFS_GC_DBG -#define SPIFFS_GC_DBG(...) //DEBUG(__VA_ARGS__) +#define SPIFFS_GC_DBG(...) //printf(_f, ## __VA_ARGS__) #endif // Set spiffs debug output call for caching. #ifndef SPIFFS_CACHE_DBG -#define SPIFFS_CACHE_DBG(...) //DEBUG(__VA_ARGS__) +#define SPIFFS_CACHE_DBG(...) //printf(_f, ## __VA_ARGS__) #endif // Set spiffs debug output call for system consistency checks. #ifndef SPIFFS_CHECK_DBG -#define SPIFFS_CHECK_DBG(...) //DEBUG(__VA_ARGS__) +#define SPIFFS_CHECK_DBG(...) //printf(_f, ## __VA_ARGS__) +#endif +// Set spiffs debug output call for all api invocations. +#ifndef SPIFFS_API_DBG +#define SPIFFS_API_DBG(...) //printf(_f, ## __VA_ARGS__) +#endif + +// Defines spiffs debug print formatters +// some general signed number +#ifndef _SPIPRIi +#define _SPIPRIi "%d" +#endif +// address +#ifndef _SPIPRIad +#define _SPIPRIad "%08x" +#endif +// block +#ifndef _SPIPRIbl +#define _SPIPRIbl "%04x" +#endif +// page +#ifndef _SPIPRIpg +#define _SPIPRIpg "%04x" +#endif +// span index +#ifndef _SPIPRIsp +#define _SPIPRIsp "%04x" +#endif +// file descriptor +#ifndef _SPIPRIfd +#define _SPIPRIfd "%d" +#endif +// file object id +#ifndef _SPIPRIid +#define _SPIPRIid "%04x" +#endif +// file flags +#ifndef _SPIPRIfl +#define _SPIPRIfl "%02x" #endif // Enable/disable API functions to determine exact number of bytes @@ -137,6 +175,20 @@ extern "C" { #define SPIFFS_OBJ_NAME_LEN (32) #endif +// Maximum length of the metadata associated with an object. +// Setting to non-zero value enables metadata-related API but also +// changes the on-disk format, so the change is not backward-compatible. +// +// Do note: the meta length must never exceed +// logical_page_size - (SPIFFS_OBJ_NAME_LEN + 64) +// +// This is derived from following: +// logical_page_size - (SPIFFS_OBJ_NAME_LEN + sizeof(spiffs_page_header) + +// spiffs_object_ix_header fields + at least some LUT entries) +#ifndef SPIFFS_OBJ_META_LEN +#define SPIFFS_OBJ_META_LEN (0) +#endif + // Size of buffer allocated on stack used when copying data. // Lower value generates more read/writes. No meaning having it bigger // than logical page size. diff --git a/pkg/spiffs/patches/0001-Constify-pointer-for-write-operations.patch b/pkg/spiffs/patches/0001-Constify-pointer-for-write-operations.patch new file mode 100644 index 0000000000..3b6002de10 --- /dev/null +++ b/pkg/spiffs/patches/0001-Constify-pointer-for-write-operations.patch @@ -0,0 +1,203 @@ +From 8721846f8b03ca7aa1d592abd00a0c9a721e11c6 Mon Sep 17 00:00:00 2001 +From: Vincent Dupont +Date: Mon, 17 Jul 2017 12:42:12 +0200 +Subject: [PATCH] Constify pointer for write operations + +--- + src/spiffs.h | 6 +++--- + src/spiffs_cache.c | 2 +- + src/spiffs_hydrogen.c | 10 +++++----- + src/spiffs_nucleus.c | 6 +++--- + src/spiffs_nucleus.h | 18 ++++++++---------- + src/test/test_spiffs.c | 2 +- + 6 files changed, 21 insertions(+), 23 deletions(-) + +diff --git a/src/spiffs.h b/src/spiffs.h +index 534c3df..991aabf 100644 +--- a/src/spiffs.h ++++ b/src/spiffs.h +@@ -84,7 +84,7 @@ struct spiffs_t; + /* spi read call function type */ + typedef s32_t (*spiffs_read)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *dst); + /* spi write call function type */ +-typedef s32_t (*spiffs_write)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src); ++typedef s32_t (*spiffs_write)(struct spiffs_t *fs, u32_t addr, u32_t size, const u8_t *src); + /* spi erase call function type */ + typedef s32_t (*spiffs_erase)(struct spiffs_t *fs, u32_t addr, u32_t size); + +@@ -93,7 +93,7 @@ typedef s32_t (*spiffs_erase)(struct spiffs_t *fs, u32_t addr, u32_t size); + /* spi read call function type */ + typedef s32_t (*spiffs_read)(u32_t addr, u32_t size, u8_t *dst); + /* spi write call function type */ +-typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, u8_t *src); ++typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, const u8_t *src); + /* spi erase call function type */ + typedef s32_t (*spiffs_erase)(u32_t addr, u32_t size); + #endif // SPIFFS_HAL_CALLBACK_EXTRA +@@ -468,7 +468,7 @@ s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, s32_t len); + * @param len how much to write + * @returns number of bytes written, or -1 if error + */ +-s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len); ++s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len); + + /** + * Moves the read/write file offset. Resulting offset is returned or negative if error. +diff --git a/src/spiffs_cache.c b/src/spiffs_cache.c +index 37c9d64..e28911d 100644 +--- a/src/spiffs_cache.c ++++ b/src/spiffs_cache.c +@@ -185,7 +185,7 @@ s32_t spiffs_phys_wr( + spiffs_file fh, + u32_t addr, + u32_t len, +- u8_t *src) { ++ const u8_t *src) { + (void)fh; + spiffs_page_ix pix = SPIFFS_PADDR_TO_PAGE(fs, addr); + spiffs_cache *cache = spiffs_get_cache(fs); +diff --git a/src/spiffs_hydrogen.c b/src/spiffs_hydrogen.c +index 69e0c22..1114f51 100644 +--- a/src/spiffs_hydrogen.c ++++ b/src/spiffs_hydrogen.c +@@ -430,22 +430,22 @@ s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, s32_t len) { + + + #if !SPIFFS_READ_ONLY +-static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offset, s32_t len) { ++static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, const void *buf, u32_t offset, s32_t len) { + (void)fs; + s32_t res = SPIFFS_OK; + s32_t remaining = len; + if (fd->size != SPIFFS_UNDEFINED_LEN && offset < fd->size) { + s32_t m_len = MIN((s32_t)(fd->size - offset), len); +- res = spiffs_object_modify(fd, offset, (u8_t *)buf, m_len); ++ res = spiffs_object_modify(fd, offset, buf, m_len); + SPIFFS_CHECK_RES(res); + remaining -= m_len; +- u8_t *buf_8 = (u8_t *)buf; ++ const u8_t *buf_8 = buf; + buf_8 += m_len; + buf = buf_8; + offset += m_len; + } + if (remaining > 0) { +- res = spiffs_object_append(fd, offset, (u8_t *)buf, remaining); ++ res = spiffs_object_append(fd, offset, buf, remaining); + SPIFFS_CHECK_RES(res); + } + return len; +@@ -453,7 +453,7 @@ static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offs + } + #endif // !SPIFFS_READ_ONLY + +-s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) { ++s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len) { + SPIFFS_API_DBG("%s "_SPIPRIfd " "_SPIPRIi "\n", __func__, fh, len); + #if SPIFFS_READ_ONLY + (void)fs; (void)fh; (void)buf; (void)len; +diff --git a/src/spiffs_nucleus.c b/src/spiffs_nucleus.c +index 12c9de8..301f179 100644 +--- a/src/spiffs_nucleus.c ++++ b/src/spiffs_nucleus.c +@@ -754,7 +754,7 @@ s32_t spiffs_page_allocate_data( + spiffs *fs, + spiffs_obj_id obj_id, + spiffs_page_header *ph, +- u8_t *data, ++ const u8_t *data, + u32_t len, + u32_t page_offs, + u8_t finalize, +@@ -1195,7 +1195,7 @@ s32_t spiffs_object_open_by_page( + #if !SPIFFS_READ_ONLY + // Append to object + // keep current object index (header) page in fs->work buffer +-s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { ++s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, const u8_t *data, u32_t len) { + spiffs *fs = fd->fs; + s32_t res = SPIFFS_OK; + u32_t written = 0; +@@ -1442,7 +1442,7 @@ s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { + #if !SPIFFS_READ_ONLY + // Modify object + // keep current object index (header) page in fs->work buffer +-s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { ++s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, const u8_t *data, u32_t len) { + spiffs *fs = fd->fs; + s32_t res = SPIFFS_OK; + u32_t written = 0; +diff --git a/src/spiffs_nucleus.h b/src/spiffs_nucleus.h +index 3d77d50..7b89f01 100644 +--- a/src/spiffs_nucleus.h ++++ b/src/spiffs_nucleus.h +@@ -545,7 +545,7 @@ s32_t spiffs_phys_wr( + #endif + u32_t addr, + u32_t len, +- u8_t *src); ++ const u8_t *src); + + s32_t spiffs_phys_cpy( + spiffs *fs, +@@ -619,11 +619,10 @@ s32_t spiffs_obj_lu_find_id_and_span_by_phdr( + + // --------------- + +-s32_t spiffs_page_allocate_data( +- spiffs *fs, ++s32_t spiffs_page_allocate_data(spiffs *fs, + spiffs_obj_id obj_id, + spiffs_page_header *ph, +- u8_t *data, ++ const u8_t *data, + u32_t len, + u32_t page_offs, + u8_t finalize, +@@ -696,16 +695,15 @@ s32_t spiffs_object_open_by_page( + spiffs_flags flags, + spiffs_mode mode); + +-s32_t spiffs_object_append( +- spiffs_fd *fd, ++s32_t spiffs_object_append(spiffs_fd *fd, + u32_t offset, +- u8_t *data, ++ const u8_t *data, + u32_t len); + + s32_t spiffs_object_modify( + spiffs_fd *fd, + u32_t offset, +- u8_t *data, ++ const u8_t *data, + u32_t len); + + s32_t spiffs_object_read( +@@ -807,8 +805,8 @@ s32_t spiffs_object_index_consistency_check( + // checked in test builds, otherwise plain memcpy (unless already defined) + #ifdef _SPIFFS_TEST + #define _SPIFFS_MEMCPY(__d, __s, __l) do { \ +- intptr_t __a1 = (intptr_t)((u8_t*)(__s)); \ +- intptr_t __a2 = (intptr_t)((u8_t*)(__s)+(__l)); \ ++ intptr_t __a1 = (intptr_t)((const u8_t*)(__s)); \ ++ intptr_t __a2 = (intptr_t)((const u8_t*)(__s)+(__l)); \ + intptr_t __b1 = (intptr_t)((u8_t*)(__d)); \ + intptr_t __b2 = (intptr_t)((u8_t*)(__d)+(__l)); \ + if (__a1 <= __b2 && __b1 <= __a2) { \ +diff --git a/src/test/test_spiffs.c b/src/test/test_spiffs.c +index 374028a..e96d4de 100644 +--- a/src/test/test_spiffs.c ++++ b/src/test/test_spiffs.c +@@ -174,7 +174,7 @@ static s32_t _write( + #if SPIFFS_HAL_CALLBACK_EXTRA + spiffs *fs, + #endif +- u32_t addr, u32_t size, u8_t *src) { ++ u32_t addr, u32_t size, const u8_t *src) { + int i; + //printf("wr %08x %i\n", addr, size); + if (log_flash_ops) { +-- +2.11.0 + diff --git a/pkg/spiffs/patches/0001-Use-const-pointer-in-write-functions.patch b/pkg/spiffs/patches/0001-Use-const-pointer-in-write-functions.patch deleted file mode 100644 index 565faf9d6f..0000000000 --- a/pkg/spiffs/patches/0001-Use-const-pointer-in-write-functions.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 95c4806835cf9b049c5af1a42fd49ed7de82947b Mon Sep 17 00:00:00 2001 -From: Vincent Dupont -Date: Mon, 11 Jul 2016 19:57:31 +0200 -Subject: [PATCH 1/2] Use const pointer in write functions - ---- - src/spiffs.h | 2 +- - src/spiffs_hydrogen.c | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/spiffs.h b/src/spiffs.h -index bea90b3..dfe967d 100644 ---- a/src/spiffs.h -+++ b/src/spiffs.h -@@ -459,7 +459,7 @@ s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, s32_t len); - * @param len how much to write - * @returns number of bytes written, or -1 if error - */ --s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len); -+s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len); - - /** - * Moves the read/write file offset. Resulting offset is returned or negative if error. -diff --git a/src/spiffs_hydrogen.c b/src/spiffs_hydrogen.c -index 1cf64ff..8eb3919 100644 ---- a/src/spiffs_hydrogen.c -+++ b/src/spiffs_hydrogen.c -@@ -411,7 +411,7 @@ s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, s32_t len) { - } - - #if !SPIFFS_READ_ONLY --static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offset, s32_t len) { -+static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, const void *buf, u32_t offset, s32_t len) { - (void)fs; - s32_t res = SPIFFS_OK; - s32_t remaining = len; -@@ -434,7 +434,7 @@ static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offs - } - #endif // !SPIFFS_READ_ONLY - --s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) { -+s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len) { - #if SPIFFS_READ_ONLY - (void)fs; (void)fh; (void)buf; (void)len; - return SPIFFS_ERR_RO_NOT_IMPL; --- -2.9.3 - diff --git a/pkg/spiffs/patches/0002-Use-const-pointer-through-all-write-functions.patch b/pkg/spiffs/patches/0002-Use-const-pointer-through-all-write-functions.patch deleted file mode 100644 index d5bc913e5e..0000000000 --- a/pkg/spiffs/patches/0002-Use-const-pointer-through-all-write-functions.patch +++ /dev/null @@ -1,236 +0,0 @@ -From 3c753304a7366514c86abfba436103b2f37edf15 Mon Sep 17 00:00:00 2001 -From: Vincent Dupont -Date: Thu, 8 Sep 2016 14:38:18 +0200 -Subject: [PATCH 2/2] Use const pointer through all write functions - -HAL API has been updated to use const pointer when writing ---- - src/spiffs.h | 4 ++-- - src/spiffs_cache.c | 2 +- - src/spiffs_hydrogen.c | 18 ++++++++++-------- - src/spiffs_nucleus.c | 12 ++++++------ - src/spiffs_nucleus.h | 8 ++++---- - 5 files changed, 23 insertions(+), 21 deletions(-) - -diff --git a/src/spiffs.h b/src/spiffs.h -index dfe967d..8a42868 100644 ---- a/src/spiffs.h -+++ b/src/spiffs.h -@@ -81,7 +81,7 @@ struct spiffs_t; - /* spi read call function type */ - typedef s32_t (*spiffs_read)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *dst); - /* spi write call function type */ --typedef s32_t (*spiffs_write)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src); -+typedef s32_t (*spiffs_write)(struct spiffs_t *fs, u32_t addr, u32_t size, const u8_t *src); - /* spi erase call function type */ - typedef s32_t (*spiffs_erase)(struct spiffs_t *fs, u32_t addr, u32_t size); - -@@ -90,7 +90,7 @@ typedef s32_t (*spiffs_erase)(struct spiffs_t *fs, u32_t addr, u32_t size); - /* spi read call function type */ - typedef s32_t (*spiffs_read)(u32_t addr, u32_t size, u8_t *dst); - /* spi write call function type */ --typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, u8_t *src); -+typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, const u8_t *src); - /* spi erase call function type */ - typedef s32_t (*spiffs_erase)(u32_t addr, u32_t size); - #endif // SPIFFS_HAL_CALLBACK_EXTRA -diff --git a/src/spiffs_cache.c b/src/spiffs_cache.c -index b508ad5..65f8cd2 100644 ---- a/src/spiffs_cache.c -+++ b/src/spiffs_cache.c -@@ -183,7 +183,7 @@ s32_t spiffs_phys_wr( - spiffs_file fh, - u32_t addr, - u32_t len, -- u8_t *src) { -+ const u8_t *src) { - (void)fh; - spiffs_page_ix pix = SPIFFS_PADDR_TO_PAGE(fs, addr); - spiffs_cache *cache = spiffs_get_cache(fs); -diff --git a/src/spiffs_hydrogen.c b/src/spiffs_hydrogen.c -index 8eb3919..b2c3d92 100644 ---- a/src/spiffs_hydrogen.c -+++ b/src/spiffs_hydrogen.c -@@ -417,7 +417,7 @@ static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, const void *buf, u32_ - s32_t remaining = len; - if (fd->size != SPIFFS_UNDEFINED_LEN && offset < fd->size) { - s32_t m_len = MIN((s32_t)(fd->size - offset), len); -- res = spiffs_object_modify(fd, offset, (u8_t *)buf, m_len); -+ res = spiffs_object_modify(fd, offset, buf, m_len); - SPIFFS_CHECK_RES(res); - remaining -= m_len; - u8_t *buf_8 = (u8_t *)buf; -@@ -426,7 +426,7 @@ static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, const void *buf, u32_ - offset += m_len; - } - if (remaining > 0) { -- res = spiffs_object_append(fd, offset, (u8_t *)buf, remaining); -+ res = spiffs_object_append(fd, offset, buf, remaining); - SPIFFS_CHECK_RES(res); - } - return len; -@@ -499,7 +499,7 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len) { - spiffs_get_cache_page(fs, spiffs_get_cache(fs), fd->cache_page->ix), - fd->cache_page->offset, fd->cache_page->size); - spiffs_cache_fd_release(fs, fd->cache_page); -- SPIFFS_API_CHECK_RES_UNLOCK(fs, res); -+ SPIFFS_API_CHECK_RES(fs, res); - } else { - // writing within cache - alloc_cpage = 0; -@@ -530,7 +530,7 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len) { - return len; - } else { - res = spiffs_hydro_write(fs, fd, buf, offset, len); -- SPIFFS_API_CHECK_RES_UNLOCK(fs, res); -+ SPIFFS_API_CHECK_RES(fs, res); - fd->fdoffset += len; - SPIFFS_UNLOCK(fs); - return res; -@@ -553,7 +553,7 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, const void *buf, s32_t len) { - #endif - - res = spiffs_hydro_write(fs, fd, buf, offset, len); -- SPIFFS_API_CHECK_RES_UNLOCK(fs, res); -+ SPIFFS_API_CHECK_RES(fs, res); - fd->fdoffset += len; - - SPIFFS_UNLOCK(fs); -@@ -571,7 +571,7 @@ s32_t SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int whence) { - s32_t res; - fh = SPIFFS_FH_UNOFFS(fs, fh); - res = spiffs_fd_get(fs, fh, &fd); -- SPIFFS_API_CHECK_RES_UNLOCK(fs, res); -+ SPIFFS_API_CHECK_RES(fs, res); - - #if SPIFFS_CACHE_WR - spiffs_fflush_cache(fs, fh); -@@ -917,7 +917,7 @@ static s32_t spiffs_read_dir_v( - if (res != SPIFFS_OK) return res; - if ((obj_id & SPIFFS_OBJ_ID_IX_FLAG) && - objix_hdr.p_hdr.span_ix == 0 && -- (objix_hdr.p_hdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE)) == -+ (objix_hdr.p_hdr.flags& (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE)) == - (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE)) { - struct spiffs_dirent *e = (struct spiffs_dirent*)user_var_p; - e->obj_id = obj_id; -@@ -927,6 +927,7 @@ static s32_t spiffs_read_dir_v( - e->pix = pix; - return SPIFFS_OK; - } -+ - return SPIFFS_VIS_COUNTINUE; - } - -@@ -1305,10 +1306,11 @@ s32_t SPIFFS_vis(spiffs *fs) { - spiffs_printf("free_blocks: %i\n", fs->free_blocks); - spiffs_printf("page_alloc: %i\n", fs->stats_p_allocated); - spiffs_printf("page_delet: %i\n", fs->stats_p_deleted); -- SPIFFS_UNLOCK(fs); - u32_t total, used; - SPIFFS_info(fs, &total, &used); - spiffs_printf("used: %i of %i\n", used, total); -+ -+ SPIFFS_UNLOCK(fs); - return res; - } - #endif -diff --git a/src/spiffs_nucleus.c b/src/spiffs_nucleus.c -index 35fe0d4..625d036 100644 ---- a/src/spiffs_nucleus.c -+++ b/src/spiffs_nucleus.c -@@ -73,7 +73,7 @@ s32_t spiffs_phys_wr( - spiffs *fs, - u32_t addr, - u32_t len, -- u8_t *src) { -+ const u8_t *src) { - return SPIFFS_HAL_WRITE(fs, addr, len, src); - } - -@@ -142,7 +142,7 @@ s32_t spiffs_obj_lu_find_entry_visitor( - int entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(spiffs_obj_id)); - - // wrap initial -- if (cur_entry > (int)SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs) - 1) { -+ if (cur_entry >= (int)SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs) - 1) { - cur_entry = 0; - cur_block++; - cur_block_addr = cur_block * SPIFFS_CFG_LOG_BLOCK_SZ(fs); -@@ -467,7 +467,7 @@ s32_t spiffs_obj_lu_find_free( - SPIFFS_OBJ_ID_FREE, block_ix, lu_entry); - if (res == SPIFFS_OK) { - fs->free_cursor_block_ix = *block_ix; -- fs->free_cursor_obj_lu_entry = (*lu_entry) + 1; -+ fs->free_cursor_obj_lu_entry = *lu_entry; - if (*lu_entry == 0) { - fs->free_blocks--; - } -@@ -754,7 +754,7 @@ s32_t spiffs_page_allocate_data( - spiffs *fs, - spiffs_obj_id obj_id, - spiffs_page_header *ph, -- u8_t *data, -+ const u8_t *data, - u32_t len, - u32_t page_offs, - u8_t finalize, -@@ -1155,7 +1155,7 @@ s32_t spiffs_object_open_by_page( - #if !SPIFFS_READ_ONLY - // Append to object - // keep current object index (header) page in fs->work buffer --s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { -+s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, const u8_t *data, u32_t len) { - spiffs *fs = fd->fs; - s32_t res = SPIFFS_OK; - u32_t written = 0; -@@ -1402,7 +1402,7 @@ s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { - #if !SPIFFS_READ_ONLY - // Modify object - // keep current object index (header) page in fs->work buffer --s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { -+s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, const u8_t *data, u32_t len) { - spiffs *fs = fd->fs; - s32_t res = SPIFFS_OK; - u32_t written = 0; -diff --git a/src/spiffs_nucleus.h b/src/spiffs_nucleus.h -index 0fa1cb3..2e6afa1 100644 ---- a/src/spiffs_nucleus.h -+++ b/src/spiffs_nucleus.h -@@ -532,7 +532,7 @@ s32_t spiffs_phys_wr( - #endif - u32_t addr, - u32_t len, -- u8_t *src); -+ const u8_t *src); - - s32_t spiffs_phys_cpy( - spiffs *fs, -@@ -610,7 +610,7 @@ s32_t spiffs_page_allocate_data( - spiffs *fs, - spiffs_obj_id obj_id, - spiffs_page_header *ph, -- u8_t *data, -+ const u8_t *data, - u32_t len, - u32_t page_offs, - u8_t finalize, -@@ -684,13 +684,13 @@ s32_t spiffs_object_open_by_page( - s32_t spiffs_object_append( - spiffs_fd *fd, - u32_t offset, -- u8_t *data, -+ const u8_t *data, - u32_t len); - - s32_t spiffs_object_modify( - spiffs_fd *fd, - u32_t offset, -- u8_t *data, -+ const u8_t *data, - u32_t len); - - s32_t spiffs_object_read( --- -2.9.3 -