diff --git a/src/efinix.cpp b/src/efinix.cpp index aad7123641..83258a53f3 100644 --- a/src/efinix.cpp +++ b/src/efinix.cpp @@ -260,9 +260,10 @@ bool Efinix::dumpFlash(uint32_t base_addr, uint32_t len) return false; } -void Efinix::programSPI(unsigned int offset, const uint8_t *data, +bool Efinix::programSPI(unsigned int offset, const uint8_t *data, const int length, const bool unprotect_flash) { + bool ret = true; _spi->gpio_clear(_rst_pin | _oe_pin); SPIFlash flash(reinterpret_cast(_spi), unprotect_flash, @@ -272,13 +273,15 @@ void Efinix::programSPI(unsigned int offset, const uint8_t *data, printf("%02x\n", flash.read_status_reg()); flash.read_id(); - flash.erase_and_prog(offset, const_cast(data), length); + if (0 != flash.erase_and_prog(offset, const_cast(data), length)) + ret = false; /* verify write if required */ if (_verify) - flash.verify(offset, data, length); + ret = flash.verify(offset, data, length); reset(); + return ret; } #define SAMPLE_PRELOAD 0x02 diff --git a/src/efinix.hpp b/src/efinix.hpp index 3bd2afe1c6..cdc65b6c5a 100644 --- a/src/efinix.hpp +++ b/src/efinix.hpp @@ -55,7 +55,7 @@ class Efinix: public Device, SPIInterface { UNKNOWN_FAMILY = 999 }; void init_common(const Device::prog_type_t &prg_type); - void programSPI(unsigned int offset, const uint8_t *data, + bool programSPI(unsigned int offset, const uint8_t *data, const int length, const bool unprotect_flash); void programJTAG(const uint8_t *data, const int length); bool post_flash_access() override;