Forráskód Böngészése

FAT: Number of volumes can now be configured through menuconfig

Closes https://github.com/espressif/esp-idf/issues/7513
Omar Chebib 4 éve
szülő
commit
63b96d7612

+ 7 - 0
components/fatfs/Kconfig

@@ -1,5 +1,12 @@
 menu "FAT Filesystem support"
 
+    config FATFS_VOLUME_COUNT
+        int "Number of volumes"
+        default 2
+        range 1 10
+        help
+            Number of volumes (logical drives) to use.
+
     choice FATFS_CHOOSE_CODEPAGE
         prompt "OEM Code Page"
         default FATFS_CODEPAGE_437

+ 6 - 15
components/fatfs/diskio/diskio_wl.c

@@ -1,16 +1,8 @@
-// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 
 #include <string.h>
 #include "diskio_impl.h"
@@ -24,8 +16,7 @@
 static const char* TAG = "ff_diskio_spiflash";
 
 wl_handle_t ff_wl_handles[FF_VOLUMES] = {
-        WL_INVALID_HANDLE,
-        WL_INVALID_HANDLE,
+        [0 ... FF_VOLUMES - 1] = WL_INVALID_HANDLE
 };
 
 DSTATUS ff_wl_initialize (BYTE pdrv)

+ 1 - 1
components/fatfs/src/ffconf.h

@@ -181,7 +181,7 @@
 / Drive/Volume Configurations
 /---------------------------------------------------------------------------*/
 
-#define FF_VOLUMES		2
+#define FF_VOLUMES		CONFIG_FATFS_VOLUME_COUNT
 /* Number of volumes (logical drives) to be used. (1-10) */
 
 

+ 2 - 0
components/fatfs/test_fatfs_host/sdkconfig/sdkconfig.h

@@ -11,3 +11,5 @@
 #define CONFIG_ESPTOOLPY_FLASHSIZE "8MB"
 //currently use the legacy implementation, since the stubs for new HAL are not done yet
 #define CONFIG_SPI_FLASH_USE_LEGACY_IMPL 1
+
+#define CONFIG_FATFS_VOLUME_COUNT 2

+ 6 - 14
components/fatfs/vfs/vfs_fat.c

@@ -1,16 +1,8 @@
-// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 
 #include <string.h>
 #include <stdlib.h>
@@ -92,7 +84,7 @@ static int vfs_fat_truncate(void* ctx, const char *path, off_t length);
 static int vfs_fat_utime(void* ctx, const char *path, const struct utimbuf *times);
 #endif // CONFIG_VFS_SUPPORT_DIR
 
-static vfs_fat_ctx_t* s_fat_ctxs[FF_VOLUMES] = { NULL, NULL };
+static vfs_fat_ctx_t* s_fat_ctxs[FF_VOLUMES] = { NULL };
 //backwards-compatibility with esp_vfs_fat_unregister()
 static vfs_fat_ctx_t* s_fat_ctx = NULL;
 

+ 0 - 2
tools/ci/check_copyright_ignore.txt

@@ -1252,7 +1252,6 @@ components/fatfs/diskio/diskio_rawflash.c
 components/fatfs/diskio/diskio_rawflash.h
 components/fatfs/diskio/diskio_sdmmc.c
 components/fatfs/diskio/diskio_sdmmc.h
-components/fatfs/diskio/diskio_wl.c
 components/fatfs/diskio/diskio_wl.h
 components/fatfs/port/freertos/ffsystem.c
 components/fatfs/port/linux/ffsystem.c
@@ -1272,7 +1271,6 @@ components/fatfs/test_fatfs_host/main.cpp
 components/fatfs/test_fatfs_host/sdkconfig/sdkconfig.h
 components/fatfs/test_fatfs_host/test_fatfs.cpp
 components/fatfs/vfs/esp_vfs_fat.h
-components/fatfs/vfs/vfs_fat.c
 components/fatfs/vfs/vfs_fat_internal.h
 components/fatfs/vfs/vfs_fat_sdmmc.c
 components/fatfs/vfs/vfs_fat_spiflash.c