Skip to content
Snippets Groups Projects
Commit f4c92582 authored by Fabio Estevam's avatar Fabio Estevam Committed by Tom Rini
Browse files

dfu: dfu_sf: Use the erase sector size for erase operations


SPI NOR flashes need to erase the entire sector size and we cannot pass
any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download    [=========================] 100%       478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
state(10) = dfuERROR, status(14) = Something went wrong, but the
device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR
has an erase sector of 64kB.

478208  = 7 entire sectors of 64kiB + 19456 bytes.

Erasing the first seven 64 kB sectors works fine, but when trying
to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Acked-by: default avatarLukasz Majewski <l.majewski@samsung.com>
parent d718ff70
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,8 @@ static int dfu_write_medium_sf(struct dfu_entity *dfu,
{
int ret;
ret = spi_flash_erase(dfu->data.sf.dev, offset, *len);
ret = spi_flash_erase(dfu->data.sf.dev, offset,
dfu->data.sf.dev->sector_size);
if (ret)
return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment