Skip to content

Commit

Permalink
efinix: programSPI return type void -> bool
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed Jul 29, 2024
1 parent a7a1a78 commit bba3d9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/efinix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SPIInterface *>(_spi), unprotect_flash,
Expand All @@ -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<uint8_t *>(data), length);
if (0 != flash.erase_and_prog(offset, const_cast<uint8_t *>(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
Expand Down
2 changes: 1 addition & 1 deletion src/efinix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bba3d9f

Please sign in to comment.