mirror of
https://github.com/trabucayre/openFPGALoader.git
synced 2026-08-30 18:02:38 +02:00
unlock block if locked before erase/flash
This commit is contained in:
@@ -131,6 +131,14 @@ int SPIFlash::write_page(int addr, uint8_t *data, int len)
|
||||
|
||||
int SPIFlash::erase_and_prog(int base_addr, uint8_t *data, int len)
|
||||
{
|
||||
/* check Block Protect Bits */
|
||||
uint8_t status = read_status_reg();
|
||||
if ((status & 0x1c) !=0) {
|
||||
if (write_enable() != 0)
|
||||
return -1;
|
||||
if (disable_protection() != 0)
|
||||
return -1;
|
||||
}
|
||||
ProgressBar progress("Writing", len, 50);
|
||||
if (sectors_erase(0, len) == -1)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user