diff options
author | Marek Vasut <marex@denx.de> | 2021-09-14 05:26:51 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-10-25 18:13:12 -0400 |
commit | ca341e98c8273e2ee74c489d6274740824c7b239 (patch) | |
tree | e414daf1db351b5857633b89ceb784a5e2eaf4c3 /drivers/dfu | |
parent | 949eb228f3f807feb338d29e9c94d97c22fa98b6 (diff) | |
download | u-boot-ca341e98c8273e2ee74c489d6274740824c7b239.tar.gz u-boot-ca341e98c8273e2ee74c489d6274740824c7b239.tar.bz2 u-boot-ca341e98c8273e2ee74c489d6274740824c7b239.zip |
dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
Not all SPI flashes and controllers can do continuous transfer longer
than 16 MiB, so perform the DFU read in 16 MiB chunks.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'drivers/dfu')
-rw-r--r-- | drivers/dfu/dfu_sf.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c index 7e64ab772f..b72493ced8 100644 --- a/drivers/dfu/dfu_sf.c +++ b/drivers/dfu/dfu_sf.c @@ -24,8 +24,18 @@ static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size) static int dfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf, long *len) { - return spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start + offset, - *len, buf); + long seglen = *len; + int ret; + + if (seglen > (16 << 20)) + seglen = (16 << 20); + + ret = spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start + offset, + seglen, buf); + if (!ret) + *len = seglen; + + return ret; } static u64 find_sector(struct dfu_entity *dfu, u64 start, u64 offset) |