@@ -211,7 +211,7 @@ void supervisor_flash_init(void) {
211
211
// Delay to give the SPI Flash time to get going.
212
212
// TODO(tannewt): Only do this when we know power was applied vs a reset.
213
213
uint16_t max_start_up_delay_us = 0 ;
214
- for (uint8_t i = 0 ; i < EXTERNAL_FLASH_DEVICE_COUNT ; i ++ ) {
214
+ for (size_t i = 0 ; i < EXTERNAL_FLASH_DEVICE_COUNT ; i ++ ) {
215
215
if (possible_devices [i ].start_up_time_us > max_start_up_delay_us ) {
216
216
max_start_up_delay_us = possible_devices [i ].start_up_time_us ;
217
217
}
@@ -223,7 +223,7 @@ void supervisor_flash_init(void) {
223
223
#ifdef EXTERNAL_FLASH_NO_JEDEC
224
224
// For NVM that don't have JEDEC response
225
225
spi_flash_command (CMD_WAKE );
226
- for (uint8_t i = 0 ; i < EXTERNAL_FLASH_DEVICE_COUNT ; i ++ ) {
226
+ for (size_t i = 0 ; i < EXTERNAL_FLASH_DEVICE_COUNT ; i ++ ) {
227
227
const external_flash_device * possible_device = & possible_devices [i ];
228
228
flash_device = possible_device ;
229
229
break ;
@@ -238,7 +238,7 @@ void supervisor_flash_init(void) {
238
238
while ((count -- > 0 ) && (jedec_id_response [0 ] == 0xff || jedec_id_response [2 ] == 0x00 )) {
239
239
spi_flash_read_command (CMD_READ_JEDEC_ID , jedec_id_response , 3 );
240
240
}
241
- for (uint8_t i = 0 ; i < EXTERNAL_FLASH_DEVICE_COUNT ; i ++ ) {
241
+ for (size_t i = 0 ; i < EXTERNAL_FLASH_DEVICE_COUNT ; i ++ ) {
242
242
const external_flash_device * possible_device = & possible_devices [i ];
243
243
if (jedec_id_response [0 ] == possible_device -> manufacturer_id &&
244
244
jedec_id_response [1 ] == possible_device -> memory_type &&
@@ -327,7 +327,7 @@ static bool flush_scratch_flash(void) {
327
327
// cached.
328
328
bool copy_to_scratch_ok = true;
329
329
uint32_t scratch_sector = flash_device -> total_size - SPI_FLASH_ERASE_SIZE ;
330
- for (uint8_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
330
+ for (size_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
331
331
if ((dirty_mask & (1 << i )) == 0 ) {
332
332
copy_to_scratch_ok = copy_to_scratch_ok &&
333
333
copy_block (current_sector + i * FILESYSTEM_BLOCK_SIZE ,
@@ -342,7 +342,7 @@ static bool flush_scratch_flash(void) {
342
342
// Second, erase the current sector.
343
343
erase_sector (current_sector );
344
344
// Finally, copy the new version into it.
345
- for (uint8_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
345
+ for (size_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
346
346
copy_block (scratch_sector + i * FILESYSTEM_BLOCK_SIZE ,
347
347
current_sector + i * FILESYSTEM_BLOCK_SIZE );
348
348
}
@@ -416,9 +416,9 @@ static bool flush_ram_cache(bool keep_cache) {
416
416
// we've cached. If we don't do this we'll erase the data during the sector
417
417
// erase below.
418
418
bool copy_to_ram_ok = true;
419
- for (uint8_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
419
+ for (size_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
420
420
if ((dirty_mask & (1 << i )) == 0 ) {
421
- for (uint8_t j = 0 ; j < PAGES_PER_BLOCK ; j ++ ) {
421
+ for (size_t j = 0 ; j < PAGES_PER_BLOCK ; j ++ ) {
422
422
copy_to_ram_ok = read_flash (
423
423
current_sector + (i * PAGES_PER_BLOCK + j ) * SPI_FLASH_PAGE_SIZE ,
424
424
flash_cache_table [i * PAGES_PER_BLOCK + j ],
@@ -439,8 +439,8 @@ static bool flush_ram_cache(bool keep_cache) {
439
439
// Second, erase the current sector.
440
440
erase_sector (current_sector );
441
441
// Lastly, write all the data in ram that we've cached.
442
- for (uint8_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
443
- for (uint8_t j = 0 ; j < PAGES_PER_BLOCK ; j ++ ) {
442
+ for (size_t i = 0 ; i < BLOCKS_PER_SECTOR ; i ++ ) {
443
+ for (size_t j = 0 ; j < PAGES_PER_BLOCK ; j ++ ) {
444
444
write_flash (current_sector + (i * PAGES_PER_BLOCK + j ) * SPI_FLASH_PAGE_SIZE ,
445
445
flash_cache_table [i * PAGES_PER_BLOCK + j ],
446
446
SPI_FLASH_PAGE_SIZE );
@@ -497,8 +497,8 @@ static bool external_flash_read_block(uint8_t *dest, uint32_t block) {
497
497
498
498
// Mask out the lower bits that designate the address within the sector.
499
499
uint32_t this_sector = address & (~(SPI_FLASH_ERASE_SIZE - 1 ));
500
- uint8_t block_index = (address / FILESYSTEM_BLOCK_SIZE ) % BLOCKS_PER_SECTOR ;
501
- uint8_t mask = 1 << (block_index );
500
+ size_t block_index = (address / FILESYSTEM_BLOCK_SIZE ) % BLOCKS_PER_SECTOR ;
501
+ uint32_t mask = 1 << (block_index );
502
502
// We're reading from the currently cached sector.
503
503
if (current_sector == this_sector && (mask & dirty_mask ) > 0 ) {
504
504
if (flash_cache_table != NULL ) {
@@ -527,8 +527,8 @@ static bool external_flash_write_block(const uint8_t *data, uint32_t block) {
527
527
wait_for_flash_ready ();
528
528
// Mask out the lower bits that designate the address within the sector.
529
529
uint32_t this_sector = address & (~(SPI_FLASH_ERASE_SIZE - 1 ));
530
- uint8_t block_index = (address / FILESYSTEM_BLOCK_SIZE ) % BLOCKS_PER_SECTOR ;
531
- uint8_t mask = 1 << (block_index );
530
+ size_t block_index = (address / FILESYSTEM_BLOCK_SIZE ) % BLOCKS_PER_SECTOR ;
531
+ uint32_t mask = 1 << (block_index );
532
532
// Flush the cache if we're moving onto a sector or we're writing the
533
533
// same block again.
534
534
if (current_sector != this_sector || (mask & dirty_mask ) > 0 ) {
0 commit comments