From edcd3552ee382271ec9885a236ca2a4710084adb Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 29 Jul 2024 16:59:57 +0200 Subject: [PATCH 1/2] fix sd mmc free space display --- .../xdrv_50_filesystem.ino | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino index c7eb25f68f3f..9167b73f7664 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino @@ -64,6 +64,9 @@ ftp start stop ftp server: 0 = OFF, 1 = SDC, 2 = FlashFile #define UFS_TFAT 2 #define UFS_TLFS 3 +#define UFS_SDC 0 +#define UFS_SDMMC 1 + /* // In tasmota.ino #ifdef ESP8266 @@ -97,6 +100,8 @@ uint8_t ufs_dir; // 0 = None, 1 = SD, 2 = ffat, 3 = littlefs uint8_t ufs_type; uint8_t ffs_type; +// sd type 0 = SD spi interface, 1 = MMC interface +uint8_t sd_type; struct { char run_file[48]; @@ -206,6 +211,7 @@ void UfsCheckSDCardInit(void) { #endif // ESP32 ufs_type = UFS_TSDC; + sd_type = UFS_SDC; dfsp = ufsp; if (ffsp) {ufs_dir = 1;} // make sd card the global filesystem @@ -239,6 +245,7 @@ void UfsCheckSDCardInit(void) { ufsp = &SD_MMC; ufs_type = UFS_TSDC; + sd_type = UFS_SDMMC; dfsp = ufsp; if (ffsp) {ufs_dir = 1;} // make sd card the global filesystem @@ -274,11 +281,29 @@ uint32_t UfsInfo(uint32_t sel, uint32_t type) { } #endif // ESP8266 #ifdef ESP32 +#ifdef SOC_SDMMC_HOST_SUPPORTED + if (sd_type == UFS_SDC) { + if (sel == 0) { + result = SD.totalBytes(); + } else { + result = (SD.totalBytes() - SD.usedBytes()); + } + } else if (sd_type == UFS_SDMMC) { + if (sel == 0) { + result = SD_MMC.totalBytes(); + } else { + result = (SD_MMC.totalBytes() - SD_MMC.usedBytes()); + } + } else { + result = 0; + } +#else if (sel == 0) { result = SD.totalBytes(); } else { result = (SD.totalBytes() - SD.usedBytes()); } +#endif // SOC_SDMMC_HOST_SUPPORTED #endif // ESP32 #endif // USE_SDCARD break; From 8c51ee97d184a18815eb683afd362ee7a8f6003c Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 29 Jul 2024 19:16:18 +0200 Subject: [PATCH 2/2] Update xdrv_50_filesystem.ino --- tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino index 9167b73f7664..5c27384fe16b 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino @@ -64,8 +64,8 @@ ftp start stop ftp server: 0 = OFF, 1 = SDC, 2 = FlashFile #define UFS_TFAT 2 #define UFS_TLFS 3 -#define UFS_SDC 0 -#define UFS_SDMMC 1 +#define UFS_SDC 0 +#define UFS_SDMMC 1 /* // In tasmota.ino