xilinx: support writing .bit file to flash

This commit is contained in:
Gwenhael Goavec-Merou 2020-09-25 18:58:31 +02:00
parent e8acec9873
commit d9bbcdf68b
3 changed files with 21 additions and 6 deletions

View File

@ -176,7 +176,8 @@ int main(int argc, char **argv)
Device *fpga;
if (fab == "xilinx") {
fpga = new Xilinx(jtag, args.bit_file, args.verbose);
fpga = new Xilinx(jtag, args.bit_file, args.write_flash, args.write_sram,
args.verbose);
} else if (fab == "altera") {
fpga = new Altera(jtag, args.bit_file, args.verbose);
} else if (fab == "anlogic") {

View File

@ -13,14 +13,25 @@
#include "part.hpp"
#include "progressBar.hpp"
Xilinx::Xilinx(Jtag *jtag, const std::string &filename, bool verbose):
Xilinx::Xilinx(Jtag *jtag, const std::string &filename,
bool flash_wr, bool sram_wr, bool verbose):
Device(jtag, filename, verbose)
{
if (_filename != ""){
if (_file_extension == "bit")
_mode = Device::MEM_MODE;
else
if (flash_wr && sram_wr) {
printError("both write-flash and write-sram can't be set");
throw std::exception();
}
if (_file_extension == "mcs") {
_mode = Device::SPI_MODE;
} else if (_file_extension == "bit") {
if (sram_wr)
_mode = Device::MEM_MODE;
else
_mode = Device::SPI_MODE;
} else {
_mode = Device::SPI_MODE;
}
}
}
Xilinx::~Xilinx() {}
@ -97,6 +108,8 @@ void Xilinx::program_spi(unsigned int offset)
ConfigBitstreamParser *_bit;
if (_file_extension == "mcs")
_bit = new McsParser(_filename, false, _verbose);
else if (_file_extension == "bit")
_bit = new BitParser(_filename, false, _verbose);
else {
if (offset == 0) {
printError("Error: can't write raw data at the beginning of the flash");

View File

@ -10,7 +10,8 @@
class Xilinx: public Device, SPIInterface {
public:
Xilinx(Jtag *jtag, const std::string &filename, bool verbose);
Xilinx(Jtag *jtag, const std::string &filename,
bool flash_wr, bool sram_wr, bool verbose);
~Xilinx();
void program(unsigned int offset = 0) override;