diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index dda089e917..daf8a219db 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -743,6 +743,7 @@ void lb_spi_flash(struct lb_header *header) return; flash = (struct lb_spi_flash *)lb_new_record(header); + memset(flash, 0, sizeof(*flash)); flash->tag = LB_TAG_SPI_FLASH; flash->size = sizeof(*flash); @@ -761,9 +762,7 @@ void lb_spi_flash(struct lb_header *header) flash->erase_cmd = CMD_BLOCK_ERASE; } - if (!CONFIG(BOOT_DEVICE_MEMORY_MAPPED)) { - flash->mmap_count = 0; - } else { + if (CONFIG(BOOT_DEVICE_MEMORY_MAPPED)) { struct flash_mmap_window *table = (struct flash_mmap_window *)(flash + 1); flash->mmap_count = spi_flash_get_mmap_windows(table); flash->size += flash->mmap_count * sizeof(*table); @@ -771,7 +770,7 @@ void lb_spi_flash(struct lb_header *header) /* Pass 4-byte address mode information to payload */ if (CONFIG(SPI_FLASH_FORCE_4_BYTE_ADDR_MODE)) - flash->flags = LB_SPI_FLASH_FLAG_IN_4BYTE_ADDR_MODE; + flash->flags |= LB_SPI_FLASH_FLAG_IN_4BYTE_ADDR_MODE; } int spi_flash_ctrlr_protect_region(const struct spi_flash *flash,