From 1b994d54be9c86043c1fe63d132a04acca54c3d9 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Mon, 6 Nov 2017 16:20:42 +0200 Subject: [PATCH] Fix wrong size reported for cards above 16GB Fixes: https://github.com/espressif/arduino-esp32/issues/803 --- libraries/SD/src/SD.cpp | 4 ++-- libraries/SD_MMC/src/SD_MMC.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/SD/src/SD.cpp b/libraries/SD/src/SD.cpp index f92532ca..40d16c86 100644 --- a/libraries/SD/src/SD.cpp +++ b/libraries/SD/src/SD.cpp @@ -80,7 +80,7 @@ uint64_t SDFS::totalBytes() FATFS* fsinfo; DWORD fre_clust; if(f_getfree("0:",&fre_clust,&fsinfo)!= 0) return 0; - uint64_t size = (fsinfo->csize)*(fsinfo->n_fatent - 2) + uint64_t size = ((uint64_t)(fsinfo->csize))*(fsinfo->n_fatent - 2) #if _MAX_SS != 512 *(fsinfo->ssize); #else @@ -94,7 +94,7 @@ uint64_t SDFS::usedBytes() FATFS* fsinfo; DWORD fre_clust; if(f_getfree("0:",&fre_clust,&fsinfo)!= 0) return 0; - uint64_t size = (fsinfo->csize)*((fsinfo->n_fatent - 2) - (fsinfo->free_clst)) + uint64_t size = ((uint64_t)(fsinfo->csize))*((fsinfo->n_fatent - 2) - (fsinfo->free_clst)) #if _MAX_SS != 512 *(fsinfo->ssize); #else diff --git a/libraries/SD_MMC/src/SD_MMC.cpp b/libraries/SD_MMC/src/SD_MMC.cpp index d554413b..10476969 100644 --- a/libraries/SD_MMC/src/SD_MMC.cpp +++ b/libraries/SD_MMC/src/SD_MMC.cpp @@ -104,7 +104,7 @@ uint64_t SDMMCFS::totalBytes() FATFS* fsinfo; DWORD fre_clust; if(f_getfree("0:",&fre_clust,&fsinfo)!= 0) return 0; - uint64_t size = (fsinfo->csize)*(fsinfo->n_fatent - 2) + uint64_t size = ((uint64_t)(fsinfo->csize))*(fsinfo->n_fatent - 2) #if _MAX_SS != 512 *(fsinfo->ssize); #else @@ -118,7 +118,7 @@ uint64_t SDMMCFS::usedBytes() FATFS* fsinfo; DWORD fre_clust; if(f_getfree("0:",&fre_clust,&fsinfo)!= 0) return 0; - uint64_t size = (fsinfo->csize)*((fsinfo->n_fatent - 2) - (fsinfo->free_clst)) + uint64_t size = ((uint64_t)(fsinfo->csize))*((fsinfo->n_fatent - 2) - (fsinfo->free_clst)) #if _MAX_SS != 512 *(fsinfo->ssize); #else