Add an extra delay after erasing a flash memory page
Erasing a flash memory page is a relative slow operation and takes a significant amount of time. Therefore, the ready byte is delayed, and the standard timeout is no longer sufficient. Estimate the required delay and wait. Reported-by: Ralph Lembcke <mail@ralph-lembcke.de>
This commit is contained in:
parent
d1b865d192
commit
7b9b6b4005
@ -1219,12 +1219,16 @@ hw_ostc3_firmware_erase (hw_ostc3_device_t *device, unsigned int addr, unsigned
|
||||
// Convert size to number of pages, rounded up.
|
||||
unsigned char blocks = ((size + SZ_FIRMWARE_BLOCK - 1) / SZ_FIRMWARE_BLOCK);
|
||||
|
||||
// Estimate the required delay. Erasing a 4K flash memory page
|
||||
// takes around 25 milliseconds.
|
||||
unsigned int delay = blocks * 25;
|
||||
|
||||
// Erase just the needed pages.
|
||||
unsigned char buffer[4];
|
||||
array_uint24_be_set (buffer, addr);
|
||||
buffer[3] = blocks;
|
||||
|
||||
return hw_ostc3_transfer (device, NULL, S_ERASE, buffer, sizeof (buffer), NULL, 0, NODELAY);
|
||||
return hw_ostc3_transfer (device, NULL, S_ERASE, buffer, sizeof (buffer), NULL, 0, delay);
|
||||
}
|
||||
|
||||
static dc_status_t
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user