Merge pull request #8253 from elpekenin/fix/bad-fix

[Fix] Wrong fix of cache use for STM32
This commit is contained in:
Scott Shawcroft 2023-08-02 14:30:45 -07:00 committed by GitHub
commit 70ce576390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -302,9 +302,9 @@ mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t n
uint32_t sector_start_addr; uint32_t sector_start_addr;
flash_get_sector_info(src, &sector_start_addr, &sector_size); flash_get_sector_info(src, &sector_start_addr, &sector_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 blocks_left_in_sector = (sector_size - (src - sector_start_addr)) / FILESYSTEM_BLOCK_SIZE;
if (count <= num_blocks && _cache_flash_addr == sector_start_addr) { if (num_blocks <= blocks_left_in_sector && _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 {