SPIInterface -> FlashInterface
This commit is contained in:
parent
09838fa825
commit
1ff73f3650
|
|
@ -337,7 +337,7 @@ endif()
|
||||||
list(APPEND OPENFPGALOADER_SOURCE
|
list(APPEND OPENFPGALOADER_SOURCE
|
||||||
src/bpiFlash.cpp
|
src/bpiFlash.cpp
|
||||||
src/spiFlash.cpp
|
src/spiFlash.cpp
|
||||||
src/spiInterface.cpp
|
src/flashInterface.cpp
|
||||||
src/epcq.cpp
|
src/epcq.cpp
|
||||||
src/jtag.cpp
|
src/jtag.cpp
|
||||||
)
|
)
|
||||||
|
|
@ -349,7 +349,7 @@ list(APPEND OPENFPGALOADER_HEADERS
|
||||||
src/spiFlash.hpp
|
src/spiFlash.hpp
|
||||||
src/spiFlashdb.hpp
|
src/spiFlashdb.hpp
|
||||||
src/epcq.hpp
|
src/epcq.hpp
|
||||||
src/spiInterface.hpp
|
src/flashInterface.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# FTDI Based cables
|
# FTDI Based cables
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ Altera::Altera(Jtag *jtag, const std::string &filename,
|
||||||
const std::string &flash_sectors,
|
const std::string &flash_sectors,
|
||||||
bool skip_load_bridge, bool skip_reset):
|
bool skip_load_bridge, bool skip_reset):
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
|
FlashInterface(filename, verbose, 256, verify, skip_load_bridge,
|
||||||
skip_reset),
|
skip_reset),
|
||||||
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
|
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
|
||||||
_vir_addr(0x1000), _vir_length(14), _clk_period(1),
|
_vir_addr(0x1000), _vir_length(14), _clk_period(1),
|
||||||
|
|
@ -274,7 +274,7 @@ void Altera::program(unsigned int offset, bool unprotect_flash)
|
||||||
throw std::runtime_error(e.what());
|
throw std::runtime_error(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SPIInterface::write(offset, data, length, unprotect_flash))
|
if (!FlashInterface::write(offset, data, length, unprotect_flash))
|
||||||
throw std::runtime_error("Fail to write data");
|
throw std::runtime_error("Fail to write data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "rawParser.hpp"
|
#include "rawParser.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "svf_jtag.hpp"
|
#include "svf_jtag.hpp"
|
||||||
|
|
||||||
class Altera: public Device, SPIInterface {
|
class Altera: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Altera(Jtag *jtag, const std::string &filename,
|
Altera(Jtag *jtag, const std::string &filename,
|
||||||
const std::string &file_type,
|
const std::string &file_type,
|
||||||
|
|
@ -39,7 +39,7 @@ class Altera: public Device, SPIInterface {
|
||||||
bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
||||||
if (_fpga_family == MAX10_FAMILY)
|
if (_fpga_family == MAX10_FAMILY)
|
||||||
return max10_dump();
|
return max10_dump();
|
||||||
return SPIInterface::dump(base_addr, len);
|
return FlashInterface::dump(base_addr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t idCode() override;
|
uint32_t idCode() override;
|
||||||
|
|
@ -53,25 +53,25 @@ class Altera: public Device, SPIInterface {
|
||||||
* \brief display SPI flash ID and status register
|
* \brief display SPI flash ID and status register
|
||||||
*/
|
*/
|
||||||
bool detect_flash() override {
|
bool detect_flash() override {
|
||||||
return SPIInterface::detect_flash();
|
return FlashInterface::detect_flash();
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief protect SPI flash blocks
|
* \brief protect SPI flash blocks
|
||||||
*/
|
*/
|
||||||
bool protect_flash(uint32_t len) override {
|
bool protect_flash(uint32_t len) override {
|
||||||
return SPIInterface::protect_flash(len);
|
return FlashInterface::protect_flash(len);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief unprotect SPI flash blocks
|
* \brief unprotect SPI flash blocks
|
||||||
*/
|
*/
|
||||||
bool unprotect_flash() override {
|
bool unprotect_flash() override {
|
||||||
return SPIInterface::unprotect_flash();
|
return FlashInterface::unprotect_flash();
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief bulk erase SPI flash
|
* \brief bulk erase SPI flash
|
||||||
*/
|
*/
|
||||||
bool bulk_erase_flash() override {
|
bool bulk_erase_flash() override {
|
||||||
return SPIInterface::bulk_erase_flash();
|
return FlashInterface::bulk_erase_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
|
|
|
||||||
|
|
@ -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), _target_freq(0)
|
FlashInterface(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;
|
||||||
|
|
@ -81,7 +81,7 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
|
||||||
int len = bit.getLength() / 8;
|
int len = bit.getLength() / 8;
|
||||||
|
|
||||||
if (_mode == Device::SPI_MODE) {
|
if (_mode == Device::SPI_MODE) {
|
||||||
SPIInterface::write(offset, data, len, unprotect_flash);
|
FlashInterface::write(offset, data, len, unprotect_flash);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@
|
||||||
#include "bitparser.hpp"
|
#include "bitparser.hpp"
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "svf_jtag.hpp"
|
#include "svf_jtag.hpp"
|
||||||
|
|
||||||
class Anlogic: public Device, SPIInterface {
|
class Anlogic: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Anlogic(Jtag *jtag, const std::string &filename,
|
Anlogic(Jtag *jtag, const std::string &filename,
|
||||||
const std::string &file_type,
|
const std::string &file_type,
|
||||||
|
|
@ -30,21 +30,21 @@ class Anlogic: public Device, SPIInterface {
|
||||||
* \brief protect SPI flash blocks
|
* \brief protect SPI flash blocks
|
||||||
*/
|
*/
|
||||||
bool protect_flash(uint32_t len) override {
|
bool protect_flash(uint32_t len) override {
|
||||||
return SPIInterface::protect_flash(len);
|
return FlashInterface::protect_flash(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief protect SPI flash blocks
|
* \brief protect SPI flash blocks
|
||||||
*/
|
*/
|
||||||
bool unprotect_flash() override {
|
bool unprotect_flash() override {
|
||||||
return SPIInterface::unprotect_flash();
|
return FlashInterface::unprotect_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief bulk erase SPI flash
|
* \brief bulk erase SPI flash
|
||||||
*/
|
*/
|
||||||
bool bulk_erase_flash() override {
|
bool bulk_erase_flash() override {
|
||||||
return SPIInterface::bulk_erase_flash();
|
return FlashInterface::bulk_erase_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -54,7 +54,7 @@ class Anlogic: public Device, SPIInterface {
|
||||||
* \return false if something wrong
|
* \return false if something wrong
|
||||||
*/
|
*/
|
||||||
virtual bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
virtual bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
||||||
return SPIInterface::dump(base_addr, len);
|
return FlashInterface::dump(base_addr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ bool CologneChip::detect_flash()
|
||||||
printInfo("Read Flash ", false);
|
printInfo("Read Flash ", false);
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<SPIFlash> flash(_spi ?
|
std::unique_ptr<SPIFlash> flash(_spi ?
|
||||||
new SPIFlash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose):
|
new SPIFlash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose):
|
||||||
new SPIFlash(this, false, _verbose));
|
new SPIFlash(this, false, _verbose));
|
||||||
flash->read_id();
|
flash->read_id();
|
||||||
flash->display_status_reg();
|
flash->display_status_reg();
|
||||||
|
|
@ -210,7 +210,7 @@ bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
printInfo("Read Flash ", false);
|
printInfo("Read Flash ", false);
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<SPIFlash> flash(_spi ?
|
std::unique_ptr<SPIFlash> flash(_spi ?
|
||||||
new SPIFlash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose):
|
new SPIFlash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose):
|
||||||
new SPIFlash(this, false, _verbose));
|
new SPIFlash(this, false, _verbose));
|
||||||
flash->dump(_filename, base_addr, len);
|
flash->dump(_filename, base_addr, len);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
|
|
@ -227,7 +227,7 @@ bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
*/
|
*/
|
||||||
bool CologneChip::set_quad_bit(bool set_quad)
|
bool CologneChip::set_quad_bit(bool set_quad)
|
||||||
{
|
{
|
||||||
if (!SPIInterface::set_quad_bit(set_quad)) {
|
if (!FlashInterface::set_quad_bit(set_quad)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ bool CologneChip::set_quad_bit(bool set_quad)
|
||||||
*/
|
*/
|
||||||
bool CologneChip::bulk_erase_flash()
|
bool CologneChip::bulk_erase_flash()
|
||||||
{
|
{
|
||||||
if (!SPIInterface::bulk_erase_flash()) {
|
if (!FlashInterface::bulk_erase_flash()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,7 +323,7 @@ void CologneChip::programSPI_flash(unsigned int offset, const uint8_t *data,
|
||||||
_spi->gpio_clear(_rstn_pin | _oen_pin);
|
_spi->gpio_clear(_rstn_pin | _oen_pin);
|
||||||
usleep(SLEEP_US);
|
usleep(SLEEP_US);
|
||||||
|
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), unprotect_flash,
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), unprotect_flash,
|
||||||
_verbose);
|
_verbose);
|
||||||
flash.erase_and_prog(offset, data, length);
|
flash.erase_and_prog(offset, data, length);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
#include "progressBar.hpp"
|
#include "progressBar.hpp"
|
||||||
|
|
||||||
class CologneChip: public Device, SPIInterface {
|
class CologneChip: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
CologneChip(FtdiSpi *spi, const std::string &filename,
|
CologneChip(FtdiSpi *spi, const std::string &filename,
|
||||||
const std::string &file_type, Device::prog_type_t prg_type,
|
const std::string &file_type, Device::prog_type_t prg_type,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ Efinix::Efinix(Jtag* jtag, const std::string &filename,
|
||||||
const std::string &board_name, const std::string &device_package,
|
const std::string &board_name, const std::string &device_package,
|
||||||
const std::string &spiOverJtagPath, bool verify, int8_t verbose):
|
const std::string &spiOverJtagPath, bool verify, int8_t verbose):
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 256, false, false, false),
|
FlashInterface(filename, verbose, 256, false, false, false),
|
||||||
_spi(NULL), _rst_pin(0), _done_pin(0), _cs_pin(0),
|
_spi(NULL), _rst_pin(0), _done_pin(0), _cs_pin(0),
|
||||||
_oe_pin(0), _fpga_family(UNKNOWN_FAMILY), _irlen(0),
|
_oe_pin(0), _fpga_family(UNKNOWN_FAMILY), _irlen(0),
|
||||||
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath)
|
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath)
|
||||||
|
|
@ -238,7 +238,7 @@ void Efinix::program(unsigned int offset, bool unprotect_flash)
|
||||||
break;
|
break;
|
||||||
case FLASH_MODE:
|
case FLASH_MODE:
|
||||||
if (_jtag)
|
if (_jtag)
|
||||||
ret = SPIInterface::write(offset, const_cast<uint8_t *>(data),
|
ret = FlashInterface::write(offset, const_cast<uint8_t *>(data),
|
||||||
length, unprotect_flash);
|
length, unprotect_flash);
|
||||||
else
|
else
|
||||||
ret = programSPI(offset, data, length, unprotect_flash);
|
ret = programSPI(offset, data, length, unprotect_flash);
|
||||||
|
|
@ -257,7 +257,7 @@ void Efinix::program(unsigned int offset, bool unprotect_flash)
|
||||||
bool Efinix::detect_flash()
|
bool Efinix::detect_flash()
|
||||||
{
|
{
|
||||||
if (_jtag) {
|
if (_jtag) {
|
||||||
return SPIInterface::detect_flash();
|
return FlashInterface::detect_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -265,7 +265,7 @@ bool Efinix::detect_flash()
|
||||||
* uncomment it and submit a PR! */
|
* uncomment it and submit a PR! */
|
||||||
_spi->gpio_clear(_rst_pin);
|
_spi->gpio_clear(_rst_pin);
|
||||||
|
|
||||||
bool rv = reinterpret_cast<SPIInterface *>(_spi)->detect_flash();
|
bool rv = reinterpret_cast<FlashInterface *>(_spi)->detect_flash();
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
|
@ -279,8 +279,8 @@ bool Efinix::detect_flash()
|
||||||
bool Efinix::dumpFlash(uint32_t base_addr, uint32_t len)
|
bool Efinix::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
{
|
{
|
||||||
if (_jtag) {
|
if (_jtag) {
|
||||||
SPIInterface::set_filename(_filename);
|
FlashInterface::set_filename(_filename);
|
||||||
return SPIInterface::dump(base_addr, len);
|
return FlashInterface::dump(base_addr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t timeout = 1000;
|
uint32_t timeout = 1000;
|
||||||
|
|
@ -289,7 +289,7 @@ bool Efinix::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
/* prepare SPI access */
|
/* prepare SPI access */
|
||||||
printInfo("Read Flash ", false);
|
printInfo("Read Flash ", false);
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose);
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose);
|
||||||
flash.reset();
|
flash.reset();
|
||||||
flash.power_up();
|
flash.power_up();
|
||||||
flash.dump(_filename, base_addr, len);
|
flash.dump(_filename, base_addr, len);
|
||||||
|
|
@ -322,7 +322,7 @@ bool Efinix::programSPI(unsigned int offset, const uint8_t *data,
|
||||||
bool ret = true;
|
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<FlashInterface *>(_spi), unprotect_flash,
|
||||||
_verbose);
|
_verbose);
|
||||||
flash.reset();
|
flash.reset();
|
||||||
flash.power_up();
|
flash.power_up();
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
#include "ftdiJtagMPSSE.hpp"
|
#include "ftdiJtagMPSSE.hpp"
|
||||||
#include "ftdispi.hpp"
|
#include "ftdispi.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
class Efinix: public Device, SPIInterface {
|
class Efinix: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Efinix(FtdiSpi *spi, const std::string &filename,
|
Efinix(FtdiSpi *spi, const std::string &filename,
|
||||||
const std::string &file_type,
|
const std::string &file_type,
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ void EPCQ::reset()
|
||||||
_spi->spi_put(0x99, NULL, NULL, 0);
|
_spi->spi_put(0x99, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
EPCQ::EPCQ(SPIInterface *spi, bool unprotect_flash, int8_t verbose):
|
EPCQ::EPCQ(FlashInterface *spi, bool unprotect_flash, int8_t verbose):
|
||||||
SPIFlash(spi, unprotect_flash, verbose), _device_id(0), _silicon_id(0)
|
SPIFlash(spi, unprotect_flash, verbose), _device_id(0), _silicon_id(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
|
|
||||||
class EPCQ: public SPIFlash {
|
class EPCQ: public SPIFlash {
|
||||||
public:
|
public:
|
||||||
EPCQ(SPIInterface *spi, bool unprotect_flash, int8_t verbose);
|
EPCQ(FlashInterface *spi, bool unprotect_flash, int8_t verbose);
|
||||||
~EPCQ();
|
~EPCQ();
|
||||||
|
|
||||||
void read_id() override;
|
void read_id() override;
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ void EPCQ::read_id()
|
||||||
printf("silicon id 0x%x expected 0x14\n", _silicon_id);
|
printf("silicon id 0x%x expected 0x14\n", _silicon_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
EPCQ::EPCQ(SPIInterface *spi, int8_t verbose):SPIFlash(spi, verbose)
|
EPCQ::EPCQ(FlashInterface *spi, int8_t verbose):SPIFlash(spi, verbose)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
EPCQ::~EPCQ()
|
EPCQ::~EPCQ()
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
|
|
||||||
class EPCQ: public SPIFlash {
|
class EPCQ: public SPIFlash {
|
||||||
public:
|
public:
|
||||||
EPCQ(SPIInterface *spi, int8_t verbose);
|
EPCQ(FlashInterface *spi, int8_t verbose);
|
||||||
~EPCQ();
|
~EPCQ();
|
||||||
|
|
||||||
void read_id() override;
|
void read_id() override;
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
|
|
||||||
SPIInterface::SPIInterface():_spif_verbose(0), _spif_rd_burst(0),
|
FlashInterface::FlashInterface():_spif_verbose(0), _spif_rd_burst(0),
|
||||||
_spif_verify(false), _skip_load_bridge(false)
|
_spif_verify(false), _skip_load_bridge(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SPIInterface::SPIInterface(const std::string &filename, int8_t verbose,
|
FlashInterface::FlashInterface(const std::string &filename, int8_t verbose,
|
||||||
uint32_t rd_burst, bool verify, bool skip_load_bridge,
|
uint32_t rd_burst, bool verify, bool skip_load_bridge,
|
||||||
bool skip_reset):
|
bool skip_reset):
|
||||||
_spif_verbose(verbose), _spif_rd_burst(rd_burst),
|
_spif_verbose(verbose), _spif_rd_burst(rd_burst),
|
||||||
|
|
@ -23,7 +23,7 @@ SPIInterface::SPIInterface(const std::string &filename, int8_t verbose,
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* spiFlash generic acces */
|
/* spiFlash generic acces */
|
||||||
bool SPIInterface::detect_flash()
|
bool FlashInterface::detect_flash()
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ bool SPIInterface::detect_flash()
|
||||||
return post_flash_access() && ret;
|
return post_flash_access() && ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::protect_flash(uint32_t len)
|
bool FlashInterface::protect_flash(uint32_t len)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
printInfo("protect_flash:");
|
printInfo("protect_flash:");
|
||||||
|
|
@ -84,7 +84,7 @@ bool SPIInterface::protect_flash(uint32_t len)
|
||||||
return post_flash_access() && ret;
|
return post_flash_access() && ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::unprotect_flash()
|
bool FlashInterface::unprotect_flash()
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
|
|
@ -115,7 +115,7 @@ bool SPIInterface::unprotect_flash()
|
||||||
return post_flash_access() && ret;
|
return post_flash_access() && ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::set_quad_bit(bool set_quad)
|
bool FlashInterface::set_quad_bit(bool set_quad)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
|
|
@ -146,7 +146,7 @@ bool SPIInterface::set_quad_bit(bool set_quad)
|
||||||
return post_flash_access() && ret;
|
return post_flash_access() && ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::bulk_erase_flash()
|
bool FlashInterface::bulk_erase_flash()
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
printInfo("bulk_erase:");
|
printInfo("bulk_erase:");
|
||||||
|
|
@ -177,7 +177,7 @@ bool SPIInterface::bulk_erase_flash()
|
||||||
return post_flash_access() && ret;
|
return post_flash_access() && ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::write(const std::vector<FlashDataSection>§ions,
|
bool FlashInterface::write(const std::vector<FlashDataSection>§ions,
|
||||||
bool unprotect_flash, bool full_erase)
|
bool unprotect_flash, bool full_erase)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
@ -202,7 +202,7 @@ bool SPIInterface::write(const std::vector<FlashDataSection>§ions,
|
||||||
return ret && ret2;
|
return ret && ret2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::write(uint32_t offset, const uint8_t *data, uint32_t len,
|
bool FlashInterface::write(uint32_t offset, const uint8_t *data, uint32_t len,
|
||||||
bool unprotect_flash)
|
bool unprotect_flash)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
@ -227,7 +227,7 @@ bool SPIInterface::write(uint32_t offset, const uint8_t *data, uint32_t len,
|
||||||
return ret && ret2;
|
return ret && ret2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::read(uint8_t *data, uint32_t base_addr, uint32_t len)
|
bool FlashInterface::read(uint8_t *data, uint32_t base_addr, uint32_t len)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
/* enable SPI flash access */
|
/* enable SPI flash access */
|
||||||
|
|
@ -246,7 +246,7 @@ bool SPIInterface::read(uint8_t *data, uint32_t base_addr, uint32_t len)
|
||||||
return post_flash_access() && ret == 0;
|
return post_flash_access() && ret == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::dump(uint32_t base_addr, uint32_t len)
|
bool FlashInterface::dump(uint32_t base_addr, uint32_t len)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
/* enable SPI flash access */
|
/* enable SPI flash access */
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* Copyright (C) 2020 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
* Copyright (C) 2020 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SRC_SPIINTERFACE_HPP_
|
#ifndef SRC_FLASHINTERFACE_HPP_
|
||||||
#define SRC_SPIINTERFACE_HPP_
|
#define SRC_FLASHINTERFACE_HPP_
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -12,21 +12,21 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \file SPIInterface.hpp
|
* \file FlashInterface.hpp
|
||||||
* \class SPIInterface
|
* \class FlashInterface
|
||||||
* \brief abstract class between spi implementation and converters
|
* \brief abstract class between spi implementation and converters
|
||||||
* \author Gwenhael Goavec-Merou
|
* \author Gwenhael Goavec-Merou
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FlashDataSection;
|
class FlashDataSection;
|
||||||
|
|
||||||
class SPIInterface {
|
class FlashInterface {
|
||||||
public:
|
public:
|
||||||
SPIInterface();
|
FlashInterface();
|
||||||
SPIInterface(const std::string &filename, int8_t verbose,
|
FlashInterface(const std::string &filename, int8_t verbose,
|
||||||
uint32_t rd_burst, bool verify, bool skip_load_bridge = false,
|
uint32_t rd_burst, bool verify, bool skip_load_bridge = false,
|
||||||
bool skip_reset = false);
|
bool skip_reset = false);
|
||||||
virtual ~SPIInterface() {}
|
virtual ~FlashInterface() {}
|
||||||
|
|
||||||
bool detect_flash();
|
bool detect_flash();
|
||||||
bool protect_flash(uint32_t len);
|
bool protect_flash(uint32_t len);
|
||||||
|
|
@ -131,4 +131,4 @@ class SPIInterface {
|
||||||
private:
|
private:
|
||||||
std::string _spif_filename;
|
std::string _spif_filename;
|
||||||
};
|
};
|
||||||
#endif // SRC_SPIINTERFACE_HPP_
|
#endif // SRC_FLASHINTERFACE_HPP_
|
||||||
|
|
@ -243,7 +243,7 @@ int FtdiSpi::ft2232_spi_wr_and_rd(//struct ftdi_spi *spi,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* method spiInterface::spi_put */
|
/* method flashInterface::spi_put */
|
||||||
int FtdiSpi::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
int FtdiSpi::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t xfer_len = len + 1;
|
uint32_t xfer_len = len + 1;
|
||||||
|
|
@ -266,13 +266,13 @@ int FtdiSpi::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* method spiInterface::spi_put */
|
/* method flashInterface::spi_put */
|
||||||
int FtdiSpi::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
int FtdiSpi::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
return ft2232_spi_wr_and_rd(len, tx, rx);
|
return ft2232_spi_wr_and_rd(len, tx, rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* method spiInterface::spi_wait
|
/* method flashInterface::spi_wait
|
||||||
*/
|
*/
|
||||||
int FtdiSpi::spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int FtdiSpi::spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose)
|
uint32_t timeout, bool verbose)
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
#include "cable.hpp"
|
#include "cable.hpp"
|
||||||
#include "ftdipp_mpsse.hpp"
|
#include "ftdipp_mpsse.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
class FtdiSpi : public FTDIpp_MPSSE, SPIInterface {
|
class FtdiSpi : public FTDIpp_MPSSE, FlashInterface {
|
||||||
public:
|
public:
|
||||||
enum SPI_endianness {
|
enum SPI_endianness {
|
||||||
SPI_MSB_FIRST = 0,
|
SPI_MSB_FIRST = 0,
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ Gowin::Gowin(Jtag *jtag, const std::string filename, const std::string &file_typ
|
||||||
Device::prog_type_t prg_type, bool external_flash,
|
Device::prog_type_t prg_type, bool external_flash,
|
||||||
bool verify, int8_t verbose, const std::string& user_flash)
|
bool verify, int8_t verbose, const std::string& user_flash)
|
||||||
: Device(jtag, filename, file_type, verify, verbose),
|
: Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 0, verify, false, false),
|
FlashInterface(filename, verbose, 0, verify, false, false),
|
||||||
_idcode(0), is_gw1n1(false), is_gw1n4(false), is_gw1n9(false),
|
_idcode(0), is_gw1n1(false), is_gw1n4(false), is_gw1n9(false),
|
||||||
is_gw2a(false), is_gw5a(false),
|
is_gw2a(false), is_gw5a(false),
|
||||||
_external_flash(external_flash),
|
_external_flash(external_flash),
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "jtagInterface.hpp"
|
#include "jtagInterface.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
class Gowin: public Device, SPIInterface {
|
class Gowin: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Gowin(Jtag *jtag, std::string filename, const std::string &file_type,
|
Gowin(Jtag *jtag, std::string filename, const std::string &file_type,
|
||||||
std::string mcufw, Device::prog_type_t prg_type,
|
std::string mcufw, Device::prog_type_t prg_type,
|
||||||
|
|
@ -32,18 +32,18 @@ class Gowin: public Device, SPIInterface {
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
bool detect_flash() override {
|
bool detect_flash() override {
|
||||||
if (is_gw5a || is_gw2a)
|
if (is_gw5a || is_gw2a)
|
||||||
return SPIInterface::detect_flash();
|
return FlashInterface::detect_flash();
|
||||||
printError("detect flash not supported"); return false;}
|
printError("detect flash not supported"); return false;}
|
||||||
bool protect_flash(uint32_t len) override {
|
bool protect_flash(uint32_t len) override {
|
||||||
(void) len;
|
(void) len;
|
||||||
printError("protect flash not supported"); return false;}
|
printError("protect flash not supported"); return false;}
|
||||||
bool unprotect_flash() override {
|
bool unprotect_flash() override {
|
||||||
if (is_gw5a)
|
if (is_gw5a)
|
||||||
return SPIInterface::unprotect_flash();
|
return FlashInterface::unprotect_flash();
|
||||||
printError("unprotect flash not supported"); return false;}
|
printError("unprotect flash not supported"); return false;}
|
||||||
bool bulk_erase_flash() override {
|
bool bulk_erase_flash() override {
|
||||||
if (is_gw5a || is_gw2a)
|
if (is_gw5a || is_gw2a)
|
||||||
return SPIInterface::bulk_erase_flash();
|
return FlashInterface::bulk_erase_flash();
|
||||||
printError("bulk erase flash not supported"); return false;}
|
printError("bulk erase flash not supported"); return false;}
|
||||||
bool dumpFlash(uint32_t base_addr, uint32_t len) override;
|
bool dumpFlash(uint32_t base_addr, uint32_t len) override;
|
||||||
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ void Ice40::program(unsigned int offset, bool unprotect_flash)
|
||||||
|
|
||||||
_spi->gpio_clear(_rst_pin);
|
_spi->gpio_clear(_rst_pin);
|
||||||
|
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), unprotect_flash,
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), unprotect_flash,
|
||||||
_verbose_level);
|
_verbose_level);
|
||||||
|
|
||||||
flash.erase_and_prog(offset, data, length);
|
flash.erase_and_prog(offset, data, length);
|
||||||
|
|
@ -154,7 +154,7 @@ bool Ice40::detect_flash()
|
||||||
prepare_flash_access();
|
prepare_flash_access();
|
||||||
printInfo("Read Flash ", false);
|
printInfo("Read Flash ", false);
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose_level);
|
||||||
flash.read_id();
|
flash.read_id();
|
||||||
flash.display_status_reg();
|
flash.display_status_reg();
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
|
|
@ -173,7 +173,7 @@ bool Ice40::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
prepare_flash_access();
|
prepare_flash_access();
|
||||||
printInfo("Read Flash ", false);
|
printInfo("Read Flash ", false);
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose_level);
|
||||||
flash.reset();
|
flash.reset();
|
||||||
flash.power_up();
|
flash.power_up();
|
||||||
flash.dump(_filename, base_addr, len);
|
flash.dump(_filename, base_addr, len);
|
||||||
|
|
@ -193,7 +193,7 @@ bool Ice40::protect_flash(uint32_t len)
|
||||||
prepare_flash_access();
|
prepare_flash_access();
|
||||||
/* acess */
|
/* acess */
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose_level);
|
||||||
/* configure flash protection */
|
/* configure flash protection */
|
||||||
if (flash.enable_protection(len) == -1)
|
if (flash.enable_protection(len) == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -213,7 +213,7 @@ bool Ice40::unprotect_flash()
|
||||||
prepare_flash_access();
|
prepare_flash_access();
|
||||||
/* acess */
|
/* acess */
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose_level);
|
||||||
/* configure flash protection */
|
/* configure flash protection */
|
||||||
if (flash.disable_protection() == -1)
|
if (flash.disable_protection() == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -233,7 +233,7 @@ bool Ice40::bulk_erase_flash()
|
||||||
prepare_flash_access();
|
prepare_flash_access();
|
||||||
/* acess */
|
/* acess */
|
||||||
try {
|
try {
|
||||||
SPIFlash flash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose_level);
|
SPIFlash flash(reinterpret_cast<FlashInterface *>(_spi), false, _verbose_level);
|
||||||
/* bulk erase flash */
|
/* bulk erase flash */
|
||||||
if (flash.bulk_erase() == -1)
|
if (flash.bulk_erase() == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "ftdispi.hpp"
|
#include "ftdispi.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
class Ice40: public Device, SPIInterface {
|
class Ice40: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Ice40(FtdiSpi *spi, const std::string &filename,
|
Ice40(FtdiSpi *spi, const std::string &filename,
|
||||||
const std::string &file_type,
|
const std::string &file_type,
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
Lattice::Lattice(Jtag *jtag, const std::string filename, const std::string &file_type,
|
Lattice::Lattice(Jtag *jtag, const std::string filename, const std::string &file_type,
|
||||||
Device::prog_type_t prg_type, std::string flash_sector, bool verify, int8_t verbose, bool skip_load_bridge, bool skip_reset):
|
Device::prog_type_t prg_type, std::string flash_sector, bool verify, int8_t verbose, bool skip_load_bridge, bool skip_reset):
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 0, verify, skip_load_bridge, skip_reset),
|
FlashInterface(filename, verbose, 0, verify, skip_load_bridge, skip_reset),
|
||||||
_fpga_family(UNKNOWN_FAMILY), _flash_sector(LATTICE_FLASH_UNDEFINED)
|
_fpga_family(UNKNOWN_FAMILY), _flash_sector(LATTICE_FLASH_UNDEFINED)
|
||||||
{
|
{
|
||||||
if (prg_type == Device::RD_FLASH) {
|
if (prg_type == Device::RD_FLASH) {
|
||||||
|
|
@ -838,7 +838,7 @@ bool Lattice::post_flash_access()
|
||||||
_skip_reset = true; // avoid infinite loop
|
_skip_reset = true; // avoid infinite loop
|
||||||
/* read flash 0 -> 255 */
|
/* read flash 0 -> 255 */
|
||||||
uint8_t buffer[256];
|
uint8_t buffer[256];
|
||||||
ret = SPIInterface::read(buffer, 0, 256);
|
ret = FlashInterface::read(buffer, 0, 256);
|
||||||
loadConfiguration(); // reset again
|
loadConfiguration(); // reset again
|
||||||
|
|
||||||
/* read ok? check if everything == 0xff */
|
/* read ok? check if everything == 0xff */
|
||||||
|
|
@ -987,9 +987,9 @@ bool Lattice::program_extFlash(unsigned int offset, bool unprotect_flash)
|
||||||
|
|
||||||
if (_file_extension == "mcs") {
|
if (_file_extension == "mcs") {
|
||||||
McsParser *parser = (McsParser *)_bit;
|
McsParser *parser = (McsParser *)_bit;
|
||||||
ret = SPIInterface::write(parser->getRecords(), unprotect_flash, true);
|
ret = FlashInterface::write(parser->getRecords(), unprotect_flash, true);
|
||||||
} else {
|
} else {
|
||||||
ret = SPIInterface::write(offset, _bit->getData(), _bit->getLength() / 8,
|
ret = FlashInterface::write(offset, _bit->getData(), _bit->getLength() / 8,
|
||||||
unprotect_flash);
|
unprotect_flash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
#include "jedParser.hpp"
|
#include "jedParser.hpp"
|
||||||
#include "feaparser.hpp"
|
#include "feaparser.hpp"
|
||||||
#include "latticeBitParser.hpp"
|
#include "latticeBitParser.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
class Lattice: public Device, SPIInterface {
|
class Lattice: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Lattice(Jtag *jtag, std::string filename, const std::string &file_type,
|
Lattice(Jtag *jtag, std::string filename, const std::string &file_type,
|
||||||
Device::prog_type_t prg_type, std::string flash_sector, bool verify,
|
Device::prog_type_t prg_type, std::string flash_sector, bool verify,
|
||||||
|
|
@ -34,32 +34,32 @@ class Lattice: public Device, SPIInterface {
|
||||||
bool Verify(std::vector<std::string> data, bool unlock = false,
|
bool Verify(std::vector<std::string> data, bool unlock = false,
|
||||||
uint32_t flash_area = 0);
|
uint32_t flash_area = 0);
|
||||||
bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
bool dumpFlash(uint32_t base_addr, uint32_t len) override {
|
||||||
return SPIInterface::dump(base_addr, len);
|
return FlashInterface::dump(base_addr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief display SPI flash ID and status register
|
* \brief display SPI flash ID and status register
|
||||||
*/
|
*/
|
||||||
bool detect_flash() override {
|
bool detect_flash() override {
|
||||||
return SPIInterface::detect_flash();
|
return FlashInterface::detect_flash();
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief protect SPI flash blocks
|
* \brief protect SPI flash blocks
|
||||||
*/
|
*/
|
||||||
bool protect_flash(uint32_t len) override {
|
bool protect_flash(uint32_t len) override {
|
||||||
return SPIInterface::protect_flash(len);
|
return FlashInterface::protect_flash(len);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief protect SPI flash blocks
|
* \brief protect SPI flash blocks
|
||||||
*/
|
*/
|
||||||
bool unprotect_flash() override {
|
bool unprotect_flash() override {
|
||||||
return SPIInterface::unprotect_flash();
|
return FlashInterface::unprotect_flash();
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief bulk erase SPI flash
|
* \brief bulk erase SPI flash
|
||||||
*/
|
*/
|
||||||
bool bulk_erase_flash() override {
|
bool bulk_erase_flash() override {
|
||||||
return SPIInterface::bulk_erase_flash();
|
return FlashInterface::bulk_erase_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
|
|
|
||||||
|
|
@ -792,7 +792,7 @@ int spi_comm(struct arguments args, const cable_t &cable,
|
||||||
spi->gpio_clear(board->reset_pin, true);
|
spi->gpio_clear(board->reset_pin, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPIFlash flash((SPIInterface *)spi, args.unprotect_flash, args.verbose);
|
SPIFlash flash((FlashInterface *)spi, args.unprotect_flash, args.verbose);
|
||||||
flash.display_status_reg();
|
flash.display_status_reg();
|
||||||
|
|
||||||
if (args.prg_type != Device::RD_FLASH &&
|
if (args.prg_type != Device::RD_FLASH &&
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
#include "spiFlashdb.hpp"
|
#include "spiFlashdb.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
/* read/write status register : 0B addr + 0 dummy */
|
/* read/write status register : 0B addr + 0 dummy */
|
||||||
#define FLASH_WRSR 0x01
|
#define FLASH_WRSR 0x01
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
/* Global Block Protection unlock */
|
/* Global Block Protection unlock */
|
||||||
#define FLASH_ULBPR 0x98
|
#define FLASH_ULBPR 0x98
|
||||||
|
|
||||||
SPIFlash::SPIFlash(SPIInterface *spi, bool unprotect, int8_t verbose):
|
SPIFlash::SPIFlash(FlashInterface *spi, bool unprotect, int8_t verbose):
|
||||||
_spi(spi), _verbose(verbose), _jedec_id(0),
|
_spi(spi), _verbose(verbose), _jedec_id(0),
|
||||||
_flash_model(NULL), _unprotect(unprotect), _must_relock(false),
|
_flash_model(NULL), _unprotect(unprotect), _must_relock(false),
|
||||||
_status(0)
|
_status(0)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "spiFlashdb.hpp"
|
#include "spiFlashdb.hpp"
|
||||||
|
|
||||||
/* Flash memory section record
|
/* Flash memory section record
|
||||||
|
|
@ -40,7 +40,7 @@ class FlashDataSection {
|
||||||
|
|
||||||
class SPIFlash {
|
class SPIFlash {
|
||||||
public:
|
public:
|
||||||
SPIFlash(SPIInterface *spi, bool unprotect, int8_t verbose);
|
SPIFlash(FlashInterface *spi, bool unprotect, int8_t verbose);
|
||||||
/* power */
|
/* power */
|
||||||
virtual void power_up();
|
virtual void power_up();
|
||||||
virtual void power_down();
|
virtual void power_down();
|
||||||
|
|
@ -173,7 +173,7 @@ class SPIFlash {
|
||||||
*/
|
*/
|
||||||
uint8_t len_to_bp(uint32_t len);
|
uint8_t len_to_bp(uint32_t len);
|
||||||
|
|
||||||
SPIInterface *_spi;
|
FlashInterface *_spi;
|
||||||
int8_t _verbose;
|
int8_t _verbose;
|
||||||
uint32_t _jedec_id; /**< CHIP ID */
|
uint32_t _jedec_id; /**< CHIP ID */
|
||||||
flash_t *_flash_model; /**< detect flash model */
|
flash_t *_flash_model; /**< detect flash model */
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "rawParser.hpp"
|
#include "rawParser.hpp"
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
#include "xilinx.hpp"
|
#include "xilinx.hpp"
|
||||||
#include "xilinxMapParser.hpp"
|
#include "xilinxMapParser.hpp"
|
||||||
|
|
||||||
|
|
@ -279,7 +279,7 @@ Xilinx::Xilinx(Jtag *jtag, const std::string &filename,
|
||||||
bool verify, int8_t verbose,
|
bool verify, int8_t verbose,
|
||||||
bool skip_load_bridge, bool skip_reset, bool read_dna, bool read_xadc):
|
bool skip_load_bridge, bool skip_reset, bool read_dna, bool read_xadc):
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
|
FlashInterface(filename, verbose, 256, verify, skip_load_bridge,
|
||||||
skip_reset),
|
skip_reset),
|
||||||
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
|
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
|
||||||
_irlen(6), _secondary_filename(secondary_filename), _soj_is_v2(false),
|
_irlen(6), _secondary_filename(secondary_filename), _soj_is_v2(false),
|
||||||
|
|
@ -842,11 +842,11 @@ void Xilinx::program_spi(ConfigBitstreamParser * bit, std::string extention,
|
||||||
throw std::runtime_error("called with null bitstream");
|
throw std::runtime_error("called with null bitstream");
|
||||||
if (extention == "mcs") {
|
if (extention == "mcs") {
|
||||||
McsParser *parser = (McsParser *)bit;
|
McsParser *parser = (McsParser *)bit;
|
||||||
SPIInterface::write(parser->getRecords(), unprotect_flash, true);
|
FlashInterface::write(parser->getRecords(), unprotect_flash, true);
|
||||||
} else {
|
} else {
|
||||||
const uint8_t *data = bit->getData();
|
const uint8_t *data = bit->getData();
|
||||||
int length = bit->getLength() / 8;
|
int length = bit->getLength() / 8;
|
||||||
SPIInterface::write(offset, data, length, unprotect_flash);
|
FlashInterface::write(offset, data, length, unprotect_flash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1261,14 +1261,14 @@ bool Xilinx::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
|
|
||||||
if (_flash_chips & PRIMARY_FLASH) {
|
if (_flash_chips & PRIMARY_FLASH) {
|
||||||
select_flash_chip(PRIMARY_FLASH);
|
select_flash_chip(PRIMARY_FLASH);
|
||||||
SPIInterface::set_filename(_filename);
|
FlashInterface::set_filename(_filename);
|
||||||
if (!SPIInterface::dump(base_addr, len))
|
if (!FlashInterface::dump(base_addr, len))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_flash_chips & SECONDARY_FLASH) {
|
if (_flash_chips & SECONDARY_FLASH) {
|
||||||
select_flash_chip(SECONDARY_FLASH);
|
select_flash_chip(SECONDARY_FLASH);
|
||||||
SPIInterface::set_filename(_secondary_filename);
|
FlashInterface::set_filename(_secondary_filename);
|
||||||
if (!SPIInterface::dump(base_addr, len))
|
if (!FlashInterface::dump(base_addr, len))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1279,12 +1279,12 @@ bool Xilinx::detect_flash()
|
||||||
{
|
{
|
||||||
if (_flash_chips & PRIMARY_FLASH) {
|
if (_flash_chips & PRIMARY_FLASH) {
|
||||||
select_flash_chip(PRIMARY_FLASH);
|
select_flash_chip(PRIMARY_FLASH);
|
||||||
if (!SPIInterface::detect_flash())
|
if (!FlashInterface::detect_flash())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_flash_chips & SECONDARY_FLASH) {
|
if (_flash_chips & SECONDARY_FLASH) {
|
||||||
select_flash_chip(SECONDARY_FLASH);
|
select_flash_chip(SECONDARY_FLASH);
|
||||||
if (!SPIInterface::detect_flash())
|
if (!FlashInterface::detect_flash())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1294,12 +1294,12 @@ bool Xilinx::protect_flash(uint32_t len)
|
||||||
{
|
{
|
||||||
if (_flash_chips & PRIMARY_FLASH) {
|
if (_flash_chips & PRIMARY_FLASH) {
|
||||||
select_flash_chip(PRIMARY_FLASH);
|
select_flash_chip(PRIMARY_FLASH);
|
||||||
if (!SPIInterface::protect_flash(len))
|
if (!FlashInterface::protect_flash(len))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_flash_chips & SECONDARY_FLASH) {
|
if (_flash_chips & SECONDARY_FLASH) {
|
||||||
select_flash_chip(SECONDARY_FLASH);
|
select_flash_chip(SECONDARY_FLASH);
|
||||||
if (!SPIInterface::protect_flash(len))
|
if (!FlashInterface::protect_flash(len))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1309,12 +1309,12 @@ bool Xilinx::unprotect_flash()
|
||||||
{
|
{
|
||||||
if (_flash_chips & PRIMARY_FLASH) {
|
if (_flash_chips & PRIMARY_FLASH) {
|
||||||
select_flash_chip(PRIMARY_FLASH);
|
select_flash_chip(PRIMARY_FLASH);
|
||||||
if (!SPIInterface::unprotect_flash())
|
if (!FlashInterface::unprotect_flash())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_flash_chips & SECONDARY_FLASH) {
|
if (_flash_chips & SECONDARY_FLASH) {
|
||||||
select_flash_chip(SECONDARY_FLASH);
|
select_flash_chip(SECONDARY_FLASH);
|
||||||
if (!SPIInterface::unprotect_flash())
|
if (!FlashInterface::unprotect_flash())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1324,12 +1324,12 @@ bool Xilinx::set_quad_bit(bool set_quad)
|
||||||
{
|
{
|
||||||
if (_flash_chips & PRIMARY_FLASH) {
|
if (_flash_chips & PRIMARY_FLASH) {
|
||||||
select_flash_chip(PRIMARY_FLASH);
|
select_flash_chip(PRIMARY_FLASH);
|
||||||
if (!SPIInterface::set_quad_bit(set_quad))
|
if (!FlashInterface::set_quad_bit(set_quad))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_flash_chips & SECONDARY_FLASH) {
|
if (_flash_chips & SECONDARY_FLASH) {
|
||||||
select_flash_chip(SECONDARY_FLASH);
|
select_flash_chip(SECONDARY_FLASH);
|
||||||
if (!SPIInterface::set_quad_bit(set_quad))
|
if (!FlashInterface::set_quad_bit(set_quad))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1339,12 +1339,12 @@ bool Xilinx::bulk_erase_flash()
|
||||||
{
|
{
|
||||||
if (_flash_chips & PRIMARY_FLASH) {
|
if (_flash_chips & PRIMARY_FLASH) {
|
||||||
select_flash_chip(PRIMARY_FLASH);
|
select_flash_chip(PRIMARY_FLASH);
|
||||||
if (!SPIInterface::bulk_erase_flash())
|
if (!FlashInterface::bulk_erase_flash())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_flash_chips & SECONDARY_FLASH) {
|
if (_flash_chips & SECONDARY_FLASH) {
|
||||||
select_flash_chip(SECONDARY_FLASH);
|
select_flash_chip(SECONDARY_FLASH);
|
||||||
if (!SPIInterface::bulk_erase_flash())
|
if (!FlashInterface::bulk_erase_flash())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "jedParser.hpp"
|
#include "jedParser.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "spiInterface.hpp"
|
#include "flashInterface.hpp"
|
||||||
|
|
||||||
class Xilinx: public Device, SPIInterface {
|
class Xilinx: public Device, FlashInterface {
|
||||||
public:
|
public:
|
||||||
Xilinx(Jtag *jtag, const std::string &filename,
|
Xilinx(Jtag *jtag, const std::string &filename,
|
||||||
const std::string &secondary_filename,
|
const std::string &secondary_filename,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue