Removed the svf programming code from devices and added device independent svf programming in main.cpp

Fixed a type error in svf_jtag.cpp
This commit is contained in:
Patrick Dussud 2022-11-10 15:01:21 -08:00
parent e595953546
commit 4a5bd0279b
6 changed files with 22 additions and 20 deletions

View File

@ -31,7 +31,7 @@ Altera::Altera(Jtag *jtag, const std::string &filename,
Device(jtag, filename, file_type, verify, verbose),
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
skip_reset),
_svf(_jtag, _verbose), _device_package(device_package),
_device_package(device_package),
_vir_addr(0x1000), _vir_length(14)
{
if (prg_type == Device::RD_FLASH) {
@ -216,13 +216,9 @@ void Altera::program(unsigned int offset, bool unprotect_flash)
*/
/* mem mode -> svf */
if (_mode == Device::MEM_MODE) {
if (_file_extension == "svf") {
_svf.parse(_filename);
} else {
RawParser _bit(_filename, false);
_bit.parse();
programMem(_bit);
}
RawParser _bit(_filename, false);
_bit.parse();
programMem(_bit);
} else if (_mode == Device::SPI_MODE) {
// reverse only bitstream raw binaries data no
bool reverseOrder = false;

View File

@ -99,7 +99,6 @@ class Altera: public Device, SPIInterface {
void shiftVDR(uint8_t * tx, uint8_t * rx, uint32_t len,
int end_state = Jtag::UPDATE_DR, bool debug = false);
SVF_jtag _svf;
std::string _device_package;
uint32_t _vir_addr; /**< addr affected to virtual jtag */
uint32_t _vir_length; /**< length of virtual jtag IR */

View File

@ -29,7 +29,7 @@ Anlogic::Anlogic(Jtag *jtag, const std::string &filename,
const std::string &file_type,
Device::prog_type_t prg_type, bool verify, int8_t verbose):
Device(jtag, filename, file_type, verify, verbose),
SPIInterface(filename, verbose, 0, verify), _svf(_jtag, _verbose)
SPIInterface(filename, verbose, 0, verify)
{
if (prg_type == Device::RD_FLASH) {
_mode = Device::READ_MODE;
@ -64,11 +64,6 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
if (_mode == Device::NONE_MODE)
return;
if (_file_extension == "svf") {
_svf.parse(_filename);
return;
}
AnlogicBitParser bit(_filename, (_mode == Device::MEM_MODE), _verbose);
printInfo("Parse file ", false);

View File

@ -73,8 +73,6 @@ class Anlogic: public Device, SPIInterface {
*/
virtual bool post_flash_access() override {reset(); return true;}
private:
SVF_jtag _svf;
};
#endif // SRC_ANLOGIC_HPP_

View File

@ -31,6 +31,7 @@
#include "spiFlash.hpp"
#include "rawParser.hpp"
#include "xilinx.hpp"
#include "svf_jtag.hpp"
#ifdef ENABLE_XVC
#include "xvc_server.hpp"
#endif
@ -496,7 +497,20 @@ int main(int argc, char **argv)
jtag->device_select(index);
/* check if selected device is supported
/* detect svf file and program the device */
if (!args.bit_file.empty() &&
((!args.file_type.empty() && args.file_type == "svf") ||
(args.bit_file.substr(args.bit_file.find_last_of(".") + 1) == "svf"))) {
SVF_jtag *svf = new SVF_jtag(jtag, args.verbose);
try {
svf->parse(args.bit_file);
} catch (std::exception &e) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* check if selected device is supported
* mainly used in conjunction with --index-chain
*/
if (fpga_list.find(idcode) == fpga_list.end()) {

View File

@ -42,8 +42,8 @@ static unsigned char *parse_hex(string const &in, size_t byte_length,
{
unsigned char *txbuf = new unsigned char[byte_length];
char c;
size_t last_iter = in.size() - (2 * byte_length);
for (size_t i = (in.size() - 1), pos = 0; i >= last_iter; i--, pos++) {
ssize_t last_iter = in.size() - (2 * byte_length);
for (ssize_t i = (in.size() - 1), pos = 0; i >= last_iter; i--, pos++) {
if (i < 0) {
c = default_value ? 0x0f : 0x00;
} else {