From fdd239fe21a3721dc7fb55a9cf816544af7e9647 Mon Sep 17 00:00:00 2001 From: Freddie Chopin Date: Fri, 22 Mar 2019 22:35:02 +0100 Subject: [PATCH 1/2] Don't bypass cache in `lfs_cache_prog()` and `lfs_cache_read()` In some cases specific alignment of buffer passed to underlying device is required. For example SDMMC in STM32F7 (when used with DMA) requires the buffers to be aligned to 16 bytes. If you enable data cache in STM32F7, the alignment of buffer passed to any driver which uses DMA should generally be at least 32 bytes. While it is possible to provide sufficiently aligned "read", "prog" and per-file caches to littlefs, the cases where caches are bypassed are hard to control when littlefs is hidden under some additional layers. For example if you couple littlefs with stdio and use it via `FILE*`, then littlefs functions will operate on internal `FIlE*` buffer, usually allocated dynamically, so in these specific cases - with insufficient alignment (8 bytes on ARM Cortex-M). The easy path was taken - remove all cases of cache bypassing. Fixes #158 --- lfs.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lfs.c b/lfs.c index 25c88c6..1e93418 100644 --- a/lfs.c +++ b/lfs.c @@ -80,21 +80,6 @@ static int lfs_bd_read(lfs_t *lfs, diff = lfs_min(diff, rcache->off-off); } - if (size >= hint && off % lfs->cfg->read_size == 0 && - size >= lfs->cfg->read_size) { - // bypass cache? - diff = lfs_aligndown(diff, lfs->cfg->read_size); - int err = lfs->cfg->read(lfs->cfg, block, off, data, diff); - if (err) { - return err; - } - - data += diff; - off += diff; - size -= diff; - continue; - } - // load to cache, first condition can no longer fail LFS_ASSERT(block < lfs->cfg->block_count); rcache->block = block; From f35fb8c14866a4a4677756f6dbeca78f8a9b4001 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 16 Apr 2019 18:29:44 -0500 Subject: [PATCH 2/2] Fixed migration test condition for prefix branches Both the littlefs-fuse and littlefs-migration test jobs depend on the external littlefs-fuse repo. But unfortunately, the automatic patching to update the external repo with the version under test does not work with the prefix branches. In this case we can just skip these tests, they've already been tested multiple times to get to this point. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1a45b96..af7089f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -136,6 +136,7 @@ jobs: env: - STAGE=test - NAME=littlefs-migration + if: branch !~ -prefix$ install: - sudo apt-get install libfuse-dev - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha v2