According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:
sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fixes: #40559
Moving CMakeLists.txt gluecode into Zephyr repo minimizes the patching
needed in LittleFS repo.
It provides a dedicate Zephyr LFS config header which will define the
equivalent LittleFS settings based upon Kconfig settings.
This further reduces the patching needed in LittleFS.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add a new API call to replace nvs_init: nvs_mount. The new API does the
same as nvs_init except that it assumes to be provided with a valid
flash device via `struct nvs_fs` `flash_device` field. Previously, it
was not possible to avoid the runtime overhead of device_get_binding()
even if the flash device was known at compile time.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The commit adds FS_FATFS_MAX_ROOT_ENTRIES Kconfig option that allows
to select number of root node entries that will be allocated while
creating FAT file system on a device.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This is to support Sypnosys Designware SDMMC controller read and write
operation where the buffer address is needed to be 16bytes and 512bytes
aligned. Adding macro FS_FATFS_WINDOW_ALIGNMENT to align the "win"
variable address in FATFS struct.
Signed-off-by: Boon Khai Ng <boon.khai.ng@intel.com>
Up till now the littlefs only has been supporting the flash medium in
Zephyr.
This change provides code to also use littlefs stored on the block
devices - like SD card (accessed via SPI).
When FS_LITTLEFS_BLK_DEV Kconfig option is defined, the support for
using littlefs on block devices is enabled.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The struct flash_area *area pointer has been renamed to void *backend
pointer.
This change is enabling further rework of the littlefs subsystem to work
with other backend devices (like block ones - i.e. SD card).
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Atempting to mount LittleFS with the flag will cause the fs_mount
to return -ENOSUP and log error message.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Mounting FAT FS will set FS_MOUNT_FLAG_USE_DISK_ACCESS to the flags
of an object serving the mount point.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit changes messages of VFS API LOG_ERR calls to distinguish
between file and directory operations.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The fs_open copies open flags into fs_file_t structure for use with
other VFS API calls; the commit moves the operation into success path.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The fs_statvfs is supposed to return, as all VFS functions, -ENOTSUP
error when underlying file-system driver does not implement the
API call.
The fs_statvfs was returning 0 for success and when API call is not
implemented, which means it is indistinguishable whether stat
structure has been filled by diver with any data or not touched at all.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
As the already existing macro K_MEM_SLAB_DEFINE results in
two variable definitions, the preceding static modifier leads to
a seemingly working solution, though linkage conflicts will occur
when the same memory slab name is used across multiple modules.
The new K_MEM_SLAB_DEFINE_STATIC macro duplicates the functionality of
K_MEM_SLAB_DEFINE with the difference that the static keywords are
internally prepended before both variable definitions.
The implementation has been tested on my Zephyr project (the build
issue faded out). The documentation has been updated altogether
with all incorrect occurences of static K_MEM_SLAB_DEFINE.
Signed-off-by: Pavel Hübner <pavel.hubner@hardwario.com>
The size of overhead for each heap allocation can change after
heap implementation change and such change impacts automatic
calculation of heap size for littleFS.
This patch allows per-alloaction overhead to be configurable and then
automatic heap size calculation can be adjusted without code change.
This is a temporary fix until per-alloaction overhead value will be
available from kernel internals.
Fixes#36962
Signed-off-by: Artur Lipowski <Artur.Lipowski@hidglobal.com>
Fix compilation error for devices where ssize_t can not
be formatted with %d, due to ssize_t not being equal int.
Fixes#39629
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This include is not used at all by fs.c. Zephyr includes a minimal
sys/stat.h, but only for the minimal libc.
Signed-off-by: Chris Reed <chris.reed@arm.com>
Add __printf_like modifier to validate strings used by shell.
Fixing warnings triggered by this change.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
In order to be able to make a "choice" from any other
Kconfig.defconfig (-ish) file, the choice needs to be named.
This commit names a few choices.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
The fs_statvfs function assumes FatFs is configured for a fixed sector
size and therefore may return wrong sector sizes when it is configured
for variable sector sizes instead. Fix that by returning the ssize
variable given in the file system object structure.
Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
The commit applies changes that are required by update of ELM Chan's
FAT FS driver update to version 0.14b.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
There are multiple reasons to want to find out if file or
directory exists, for example to create it. Stating and
finding out it doesn't exist should not cause an LOG_ERR call as
this gives information to the user in a normal call case.
Fixes#35718
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Newline character is automatically appended in log backends such as
UART, so there is no need to add it explicitly.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
There is '%u' and '%d' in format message, while there is only one
argument (besides format string). Remove ununsed '%u' to stop printing
garbage.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
The following options, marked to be deprecated in release 2.5, have
been finally removed from Kconfig:
FS_LITTLEFS_FC_MEM_POOL_MIN_SIZE
FS_LITTLEFS_FC_MEM_POOL_MAX_SIZE
FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The LittleFS file cache has been completely switched from k_mem_slab
to heap allocated. The *_MEM_POOL_* kconfig variables no longer
affect the code.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Using %s, without logstr_dup causes error when
CONFIG_LOG_DETECT_MISSED_STRDUP is enable.
Removing %s argument. LOG_FUNC_NAME_PREFIX_ERR can be used if prefix
is wanted.
Signed-off-by: Fredrik Gihl <fredrik.gihl@flir.se>
A badly written sector close ate that has correct crc8 could allow
jumps outside the assigned flash area. This behavior is fixed.
A possibility existed that a badly erased sector or a incomplete write
of a large item created a empty closed sector. This has been fixed by:
a. Erase verification.
b. Clearing such a sector at startup.
Fixes#34382
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Co-Authered-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Document the fact than NVS image of different wbs
are compatible each other if psychical ATE size
is kept.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
When existing records stored in the NVS are not properly
aligned according to the current flash driver requirements,
fs->data_wra may be initialized with an unaligned address.
Fix the initialization code, so that fs->data_wra is rounded
up to the nearest multiple of the current flash driver block
size.
The situation may occur during a firmware upgrade which
introduces a new flash driver or changes its parameters.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Removed two unneeded `if` statements. These statements had not
effect in function results.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
flash_write_protection_set() was deprecated.
This patch removes usage of it and the test case which was
testing deprecated API behaviors.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The cmd_write and cmd_ctunc have been opening/creating file for
read/write operation.
The commit changes cmd_write to open/create file for write only,
and cmd_trunc to only open file for write.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The cmd_read function uses fs_open with FS_O_CREATE | FS_O_RDWR flags
to open file it will only read; the flags has been changed
to FS_O_READ.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
llvm 11 doesn't like having preprocessor directives in the expansion
of a macro used as a preprocessor conditional expression.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fixes problem when fs_opendir invoked on fs_dir_t object,
which is already holding information on opened directory,
overwrites references to other memory objects within
the fs_dir_t object causing resource leak.
If fs_opendir is invoked on already used fs_dir_t object,
it will return
-EBUSY.
Note: The change requires that all fs_dir_t objects should be
initialized to 0.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The commit adds initializations of fs_dir_t variables in preparation
for fs_opendir function change that will require fs_dir_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The mem_pool Kconfig API is deprecated as allocation now uses a k_heap.
Update to allocate a heap with the same amount of memory as was
defaulted with mem_pool customization.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Originally the file cache used a mem_pool, but that data structure has
been deprecated and replaced by a heap that includes metadata in the
heap area. As a result attempts to allocate all blocks will fail
because some of the reservation intended for cache data is now holding
metadata instead.
It's not immediately clear how to adjust the required heap size to
support this metadata as it depends on heap chunk units and data
structures that are not visible to the application. Experimentally a
value of 24 bytes works, while smaller values do not.
Further the previous Kconfig API to configure the allocation pool is
completely inappropriate with the new heap data structure which has
such different behavior.
So: Deprecate the old Kconfig API. Add a new Kconfig option to
directly control the cache size. Infer a default cache size that
works with the old mem_pool parameters assuming a per-block overhead.
But to avoid wasted memory use the heap allocation only when the
application customizes the size, and use a slab in other cases.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fixes problem when fs_open invoked on fs_file_t object, which is already
holding information on opened file, overwrites references to other
memory objects within the fs_file_t object causing resource leak.
If fs_open is invoked on already used fs_file_t object, it will return
-EBUSY.
Note: The change requires that all fs_file_t objects should be
initialized to 0.
Fixes: #29478
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Make sector size used by flash disk configurable and expose new disk and
fatfs configurations to Kconfig.
Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
Use the devicetree filesystem bindings to populate an fs_mount_t
object that is preconfigured for a particular set of file system
properties on a specified partition.
At this time the mount point data is accessed by reference using the
partition's devicetree node identifier.
Note: While a file system can register itself before its devices
are available, it cannot do the automount. In this commit the
initialization priority is increased to compensate, but that's not
a long-term solution.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the core k_heap API pervasively within our tree instead of the
z_mem_pool wrapper that provided compatibility with the older mempool
implementation.
Almost all of this is straightforward swapping of one alloc/free call
for another. In a few cases where code was holding onto an old-style
"mem_block" a local compatibility struct with a single field has been
swapped in to keep the invasiveness of the changes down.
Note that not all the relevant changes in this patch have in-tree test
coverage, though I validated that it all builds.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>