Skip to content

Commit 40e833c

Browse files
committed
[Fix] Wrong fix of cache use for STM32
1 parent 9cc4b4c commit 40e833c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/stm/supervisor/internal_flash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t n
302302
uint32_t sector_start_addr;
303303
flash_get_sector_info(src, &sector_start_addr, &sector_size);
304304
// Count how many blocks are left in the sector
305-
uint32_t count = (sector_size - (src - sector_start_addr)) / FILESYSTEM_BLOCK_SIZE;
305+
uint32_t blocks_left_in_sector = (sector_size - (src - sector_start_addr)) / FILESYSTEM_BLOCK_SIZE;
306306

307-
if (count <= num_blocks && _cache_flash_addr == sector_start_addr) {
307+
if (num_blocks <= blocks_left_in_sector && _cache_flash_addr == sector_start_addr) {
308308
// Read is contained in the cache, so just read cache
309309
memcpy(dest, (_flash_cache + (src - sector_start_addr)), FILESYSTEM_BLOCK_SIZE * num_blocks);
310310
} else {

0 commit comments

Comments
 (0)