This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 92b27d131eae9acf31ea16d38a78ea9daf8b5784
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Thu Jul 10 21:01:44 2025 +0200

    fs/fatfs: Enable LNS and ExFAT support
    
    Add syscfg values to enable FATFS long name support
    and ExFAT support.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 fs/fatfs/include/fatfs/ffconf.h |  8 +++-----
 fs/fatfs/src/mynewt_glue.c      | 25 +++++++++++++++++++++++++
 fs/fatfs/syscfg.yml             | 14 ++++++++++++++
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/fs/fatfs/include/fatfs/ffconf.h b/fs/fatfs/include/fatfs/ffconf.h
index ee3f171ae..0681b9e99 100644
--- a/fs/fatfs/include/fatfs/ffconf.h
+++ b/fs/fatfs/include/fatfs/ffconf.h
@@ -99,9 +99,8 @@
 /   950 - Traditional Chinese (DBCS)
 */
 
-
-#define        _USE_LFN        0
-#define        _MAX_LFN        255
+#define _USE_LFN MYNEWT_VAL(FATFS_LONG_FILE_NAMES)
+#define _MAX_LFN 255
 /* The _USE_LFN switches the support of long file name (LFN).
 /
 /   0: Disable support of LFN. _MAX_LFN has no effect.
@@ -210,8 +209,7 @@
 /  Instead of private sector buffer eliminated from the file object, common 
sector
 /  buffer in the file system object (FATFS) is used for the file data 
transfer. */
 
-
-#define _FS_EXFAT      0
+#define _FS_EXFAT MYNEWT_VAL(FATFS_EXFAT_SUPPORT)
 /* This option switches support of exFAT file system. (0:Disable or 1:Enable)
 /  When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1)
 /  Note that enabling exFAT discards C89 compatibility. */
diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
index 6ef26e379..0fbefeb47 100644
--- a/fs/fatfs/src/mynewt_glue.c
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -18,6 +18,7 @@
  */
 
 #include <assert.h>
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -717,6 +718,30 @@ ff_del_syncobj(_SYNC_t sobj)
     return FR_OK;
 }
 
+void *
+ff_memalloc(UINT msize)
+{
+    return os_malloc(msize);
+}
+
+void
+ff_memfree(void *mblock)
+{
+    os_free(mblock);
+}
+
+WCHAR
+ff_convert(WCHAR chr, UINT dir)
+{
+    return chr;
+}
+
+WCHAR
+ff_wtoupper(WCHAR chr)
+{
+    return toupper(chr);
+}
+
 void
 fatfs_pkg_init(void)
 {
diff --git a/fs/fatfs/syscfg.yml b/fs/fatfs/syscfg.yml
index 2f2ba8a24..66035279b 100644
--- a/fs/fatfs/syscfg.yml
+++ b/fs/fatfs/syscfg.yml
@@ -23,6 +23,20 @@ syscfg.defs:
             Sysinit stage for FATFS functionality.
         value: 200
 
+    FATFS_LONG_FILE_NAMES:
+        description: >
+            0 - Disable support of LFN. _MAX_LFN has no effect.
+            1 - Enable LFN with static working buffer on the BSS. Always NOT 
thread-safe.
+            2 - Enable LFN with dynamic working buffer on the STACK.
+            3 - Enable LFN with dynamic working buffer on the HEAP.
+        value: 2
+
+    FATFS_EXFAT_SUPPORT:
+        description: >
+            0 - Disable ExFAT support
+            1 - Enable ExFAT support
+        value: 1
+
     FATFS_REENTRANT:
         description: >
             0 - Disable locking on file system

Reply via email to