From cf8aa506b285a497f135ec842606e6af5d8bcb26 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Fri, 15 Apr 2022 13:13:59 -0700 Subject: [PATCH] utils: Always use 4-byte addresses for large SPI flash devices Signed-off-by: Alex Forencich --- utils/flash_spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/flash_spi.c b/utils/flash_spi.c index c5c890d82..43b4b4f4a 100644 --- a/utils/flash_spi.c +++ b/utils/flash_spi.c @@ -382,7 +382,7 @@ int spi_flash_read(struct flash_device *fdev, size_t addr, size_t len, void *des protocol = SPI_PROTO_QUAD_STR; } - if (addr > 0xffffff) + if (fdev->size > 0x1000000) { // four byte address read if (protocol == SPI_PROTO_QUAD_STR) @@ -453,7 +453,7 @@ int spi_flash_write(struct flash_device *fdev, size_t addr, size_t len, const vo return -1; } - if (addr > 0xffffff) + if (fdev->size > 0x1000000) { // four byte address page program if (protocol == SPI_PROTO_QUAD_STR) @@ -539,7 +539,7 @@ int spi_flash_erase(struct flash_device *fdev, size_t addr, size_t len) } // block erase - if (addr > 0xffffff) + if (fdev->size > 0x1000000) { if (erase_block_size == SPI_SECTOR_SIZE) {