Fix logic (i think)
This commit is contained in:
parent
75ba17e84e
commit
1ece85ee1e
@ -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);
|
flash_get_sector_info(src, §or_start_addr, §or_size);
|
||||||
// Count how many blocks are left in the sector
|
// Count how many blocks are left in the sector
|
||||||
uint32_t count = (sector_size - (src - sector_start_addr)) / FILESYSTEM_BLOCK_SIZE;
|
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
|
// Read is contained in the cache, so just read cache
|
||||||
memcpy(dest, (_flash_cache + (src - sector_start_addr)), FILESYSTEM_BLOCK_SIZE * num_blocks);
|
memcpy(dest, (_flash_cache + (src - sector_start_addr)), FILESYSTEM_BLOCK_SIZE * num_blocks);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user