anlogic: fix high frequency flash programming issue
This commit is contained in:
parent
c16e6d0f65
commit
4c17327a65
|
|
@ -29,7 +29,7 @@ Anlogic::Anlogic(Jtag *jtag, const std::string &filename,
|
||||||
const std::string &file_type,
|
const std::string &file_type,
|
||||||
Device::prog_type_t prg_type, bool verify, int8_t verbose):
|
Device::prog_type_t prg_type, bool verify, int8_t verbose):
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 0, verify)
|
SPIInterface(filename, verbose, 0, verify), _target_freq(0)
|
||||||
{
|
{
|
||||||
if (prg_type == Device::RD_FLASH) {
|
if (prg_type == Device::RD_FLASH) {
|
||||||
_mode = Device::READ_MODE;
|
_mode = Device::READ_MODE;
|
||||||
|
|
@ -157,6 +157,11 @@ uint32_t Anlogic::idCode()
|
||||||
|
|
||||||
bool Anlogic::prepare_flash_access()
|
bool Anlogic::prepare_flash_access()
|
||||||
{
|
{
|
||||||
|
_target_freq = _jtag->getClkFreq();
|
||||||
|
if (_target_freq > 6000000) {
|
||||||
|
_jtag->setClkFreq(6000000);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
_jtag->shiftIR(BYPASS, IRLENGTH);
|
_jtag->shiftIR(BYPASS, IRLENGTH);
|
||||||
//Verify Device id.
|
//Verify Device id.
|
||||||
|
|
@ -174,6 +179,13 @@ bool Anlogic::prepare_flash_access()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Anlogic::restore_flash_access_frequency()
|
||||||
|
{
|
||||||
|
if (_target_freq > 6000000) {
|
||||||
|
_jtag->setClkFreq(_target_freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* SPI wrapper
|
/* SPI wrapper
|
||||||
* For read operation a delay of one bit is added
|
* For read operation a delay of one bit is added
|
||||||
* So add one bit more and move everything by one
|
* So add one bit more and move everything by one
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,18 @@ class Anlogic: public Device, SPIInterface {
|
||||||
* \brief move device to SPI access
|
* \brief move device to SPI access
|
||||||
*/
|
*/
|
||||||
virtual bool prepare_flash_access() override;
|
virtual bool prepare_flash_access() override;
|
||||||
|
/*!
|
||||||
|
* \brief restore frequency after flash ID read
|
||||||
|
*/
|
||||||
|
virtual void restore_flash_access_frequency() override;
|
||||||
/*!
|
/*!
|
||||||
* \brief end of device to SPI access
|
* \brief end of device to SPI access
|
||||||
*/
|
*/
|
||||||
virtual bool post_flash_access() override {reset(); return true;}
|
virtual bool post_flash_access() override {reset(); return true;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t _target_freq; /*< target JTAG frequency */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SRC_ANLOGIC_HPP_
|
#endif // SRC_ANLOGIC_HPP_
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@ bool SPIInterface::write(uint32_t offset, const uint8_t *data, uint32_t len,
|
||||||
/* test SPI */
|
/* test SPI */
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(this, unprotect_flash, _spif_verbose);
|
SPIFlash flash(this, unprotect_flash, _spif_verbose);
|
||||||
|
restore_flash_access_frequency();
|
||||||
flash.read_status_reg();
|
flash.read_status_reg();
|
||||||
if (flash.erase_and_prog(offset, data, len) == -1)
|
if (flash.erase_and_prog(offset, data, len) == -1)
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,10 @@ class SPIInterface {
|
||||||
* \brief prepare SPI flash access
|
* \brief prepare SPI flash access
|
||||||
*/
|
*/
|
||||||
virtual bool prepare_flash_access() {return false;}
|
virtual bool prepare_flash_access() {return false;}
|
||||||
|
/*!
|
||||||
|
* \brief restore frequency after flash ID read
|
||||||
|
*/
|
||||||
|
virtual void restore_flash_access_frequency() {}
|
||||||
/*!
|
/*!
|
||||||
* \brief end of SPI flash access
|
* \brief end of SPI flash access
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue