altera: add verify and dump

This commit is contained in:
Gwenhael Goavec-Merou 2021-07-11 11:32:35 +02:00
parent b77c5a22df
commit f5254294eb
2 changed files with 38 additions and 1 deletions

View File

@ -226,10 +226,37 @@ void Altera::program(unsigned int offset)
}
if (_verify)
printWarn("writing verification not supported");
epcq.verify(offset, data, length, 256);
reset();
}
}
bool Altera::dumpFlash(const std::string filename, uint32_t base_addr,
uint32_t len)
{
int ret = true;
/* try to load spiOverJtag bridge
* to have an access to SPI flash
*/
if (!load_bridge()) {
printError("Fail to load bridge");
return false;
}
EPCQ epcq(this, 0);
try {
epcq.reset();
ret = epcq.dump(filename, base_addr, len, 256);
} catch (std::exception &e) {
printError(e.what());
ret = false;
}
reset();
return ret;
}
int Altera::idCode()
{
unsigned char tx_data[4] = {IDCODE};

View File

@ -25,6 +25,16 @@ class Altera: public Device, SPIInterface {
void programMem(RawParser &_bit);
void program(unsigned int offset = 0) override;
/*!
* \brief read len Byte starting at base_addr and store
* into filename
* \param[in] filename: file name
* \param[in] base_addr: starting address in flash memory
* \param[in] len: length (in Byte)
* \return false if read fails or filename can't be open, true otherwise
*/
bool dumpFlash(const std::string filename, uint32_t base_addr,
uint32_t len);
int idCode() override;
void reset() override;