File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,8 +53,10 @@ static uint8_t *cache_get_addr_for_read(uint32_t flash_addr) {
5353 uint32_t flash_sector_start ;
5454 uint32_t flash_sector_size ;
5555 uint32_t flash_sector_id = flash_get_sector_info (flash_addr , & flash_sector_start , & flash_sector_size );
56- if (cache_flash_sector_id == flash_sector_id )
56+ if (cache_flash_sector_id == flash_sector_id ) {
57+ // in cache, copy from there
5758 return (uint8_t * )CACHE_MEM_START_ADDR + flash_addr - flash_sector_start ;
59+ }
5860 // not in cache, copy straight from flash
5961 return (uint8_t * )flash_addr ;
6062}
@@ -141,6 +143,7 @@ bool storage_read_block(uint8_t *dest, uint32_t block) {
141143 return true;
142144
143145 } else if (FLASH_PART1_START_BLOCK <= block && block < FLASH_PART1_START_BLOCK + FLASH_PART1_NUM_BLOCKS ) {
146+ // non-MBR block, get data from flash memory, possibly via cache
144147 uint32_t flash_addr = FLASH_MEM_START_ADDR + (block - FLASH_PART1_START_BLOCK ) * BLOCK_SIZE ;
145148 uint8_t * src = cache_get_addr_for_read (flash_addr );
146149 memcpy (dest , src , BLOCK_SIZE );
You can’t perform that action at this time.
0 commit comments