From 1ece85ee1e72bc1e5b8fc44870d5ca462976df5f Mon Sep 17 00:00:00 2001 From: elpekenin Date: Fri, 28 Jul 2023 23:49:45 +0200 Subject: [PATCH] Fix logic (i think) --- ports/stm/supervisor/internal_flash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/stm/supervisor/internal_flash.c b/ports/stm/supervisor/internal_flash.c index f3f9719753..c7b792616c 100644 --- a/ports/stm/supervisor/internal_flash.c +++ b/ports/stm/supervisor/internal_flash.c @@ -303,9 +303,8 @@ mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t n flash_get_sector_info(src, §or_start_addr, §or_size); // Count how many blocks are left in the sector uint32_t count = (sector_size - (src - sector_start_addr)) / FILESYSTEM_BLOCK_SIZE; - count = MIN(num_blocks, count); - if (count < num_blocks && _cache_flash_addr == sector_start_addr) { + if (count <= num_blocks && _cache_flash_addr == sector_start_addr) { // Read is contained in the cache, so just read cache memcpy(dest, (_flash_cache + (src - sector_start_addr)), FILESYSTEM_BLOCK_SIZE * num_blocks); } else {