Skip to content

Commit 63e2748

Browse files
authored
Merge pull request #212 from huming2207/fix/sdmmc-capacity
Fix wrong limit on SD card block count
2 parents cdf362e + 15846f4 commit 63e2748

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/esp_littlefs.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -933,21 +933,11 @@ static esp_err_t esp_littlefs_init_sdcard(esp_littlefs_t** efs, sdmmc_card_t* sd
933933
(*efs)->cfg.erase = littlefs_sdmmc_erase;
934934
(*efs)->cfg.sync = littlefs_sdmmc_sync;
935935

936-
size_t max_allowed_blk_cnt = 0;
937-
if (((uint64_t)sdcard->csd.capacity * (uint64_t)sdcard->csd.sector_size) > SIZE_MAX) {
938-
max_allowed_blk_cnt = SIZE_MAX / sdcard->csd.sector_size;
939-
ESP_LOGW(ESP_LITTLEFS_TAG, "SD card is too big (sector=%d, count=%d; total=%llu bytes), throttling to maximum possible %u blocks",
940-
sdcard->csd.sector_size, sdcard->csd.capacity,
941-
(((uint64_t)sdcard->csd.capacity * (uint64_t)sdcard->csd.sector_size)), max_allowed_blk_cnt);
942-
} else {
943-
max_allowed_blk_cnt = sdcard->csd.capacity;
944-
}
945-
946936
// block device configuration
947937
(*efs)->cfg.read_size = sdcard->csd.sector_size;
948938
(*efs)->cfg.prog_size = sdcard->csd.sector_size;
949939
(*efs)->cfg.block_size = sdcard->csd.sector_size;
950-
(*efs)->cfg.block_count = max_allowed_blk_cnt;
940+
(*efs)->cfg.block_count = sdcard->csd.capacity;
951941
(*efs)->cfg.cache_size = MAX(CONFIG_LITTLEFS_CACHE_SIZE, sdcard->csd.sector_size); // Must not be smaller than SD sector size
952942
(*efs)->cfg.lookahead_size = CONFIG_LITTLEFS_LOOKAHEAD_SIZE;
953943
(*efs)->cfg.block_cycles = CONFIG_LITTLEFS_BLOCK_CYCLES;

0 commit comments

Comments
 (0)