efinix: programSPI return type void -> bool

This commit is contained in:
Gwenhael Goavec-Merou 2024-07-29 07:48:45 +02:00
parent a7a1a788ff
commit bba3d9f3fb
2 changed files with 7 additions and 4 deletions

View File

@ -260,9 +260,10 @@ bool Efinix::dumpFlash(uint32_t base_addr, uint32_t len)
return false; 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) const int length, const bool unprotect_flash)
{ {
bool ret = true;
_spi->gpio_clear(_rst_pin | _oe_pin); _spi->gpio_clear(_rst_pin | _oe_pin);
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), unprotect_flash, SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), unprotect_flash,
@ -272,13 +273,15 @@ void Efinix::programSPI(unsigned int offset, const uint8_t *data,
printf("%02x\n", flash.read_status_reg()); printf("%02x\n", flash.read_status_reg());
flash.read_id(); flash.read_id();
flash.erase_and_prog(offset, const_cast<uint8_t *>(data), length); if (0 != flash.erase_and_prog(offset, const_cast<uint8_t *>(data), length))
ret = false;
/* verify write if required */ /* verify write if required */
if (_verify) if (_verify)
flash.verify(offset, data, length); ret = flash.verify(offset, data, length);
reset(); reset();
return ret;
} }
#define SAMPLE_PRELOAD 0x02 #define SAMPLE_PRELOAD 0x02

View File

@ -55,7 +55,7 @@ class Efinix: public Device, SPIInterface {
UNKNOWN_FAMILY = 999 UNKNOWN_FAMILY = 999
}; };
void init_common(const Device::prog_type_t &prg_type); 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); const int length, const bool unprotect_flash);
void programJTAG(const uint8_t *data, const int length); void programJTAG(const uint8_t *data, const int length);
bool post_flash_access() override; bool post_flash_access() override;