all/everything/world: removed using namespace std to be able to compile in c++17 with windows
This commit is contained in:
parent
40491463bf
commit
9b1c568659
|
|
@ -42,7 +42,7 @@ Altera::Altera(Jtag *jtag, const std::string &filename,
|
|||
{
|
||||
/* check device family */
|
||||
_idcode = _jtag->get_target_device_id();
|
||||
string family = fpga_list[_idcode].family;
|
||||
std::string family = fpga_list[_idcode].family;
|
||||
if (family == "MAX 10") {
|
||||
_fpga_family = MAX10_FAMILY;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@
|
|||
#include "anlogicBitParser.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
AnlogicBitParser::AnlogicBitParser(const string &filename, bool reverseOrder,
|
||||
AnlogicBitParser::AnlogicBitParser(const std::string &filename, bool reverseOrder,
|
||||
bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||
_reverseOrder(reverseOrder)
|
||||
|
|
@ -37,8 +36,8 @@ int AnlogicBitParser::parseHeader()
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
string buffer;
|
||||
istringstream lineStream(_raw_data);
|
||||
std::string buffer;
|
||||
std::istringstream lineStream(_raw_data);
|
||||
|
||||
while (std::getline(lineStream, buffer, '\n')) {
|
||||
ret += buffer.size() + 1;
|
||||
|
|
@ -53,13 +52,13 @@ int AnlogicBitParser::parseHeader()
|
|||
return -1;
|
||||
}
|
||||
|
||||
string content = buffer.substr(2); // drop '# '
|
||||
std::string content = buffer.substr(2); // drop '# '
|
||||
size_t pos = content.find(':');
|
||||
if (pos == string::npos) {
|
||||
if (pos == std::string::npos) {
|
||||
_hdr["tool"] = content;
|
||||
} else {
|
||||
string entry = content.substr(0, pos);
|
||||
string val = content.substr(pos+2);
|
||||
std::string entry = content.substr(0, pos);
|
||||
std::string val = content.substr(pos+2);
|
||||
_hdr[entry] = val;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#include "anlogicCable.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define ANLOGICCABLE_VIDv1 0x0547
|
||||
#define ANLOGICCABLE_VIDv2 0x336C
|
||||
|
|
@ -59,8 +58,7 @@ AnlogicCable::AnlogicCable(uint32_t clkHZ):
|
|||
int ret;
|
||||
|
||||
if (libusb_init(&usb_ctx) < 0) {
|
||||
cerr << "libusb init failed" << endl;
|
||||
throw std::exception();
|
||||
throw std::runtime_error("libusb init failed");
|
||||
}
|
||||
|
||||
/* First: Try with original (old) VID */
|
||||
|
|
@ -72,23 +70,20 @@ AnlogicCable::AnlogicCable(uint32_t clkHZ):
|
|||
ANLOGICCABLE_VIDv2, ANLOGICCABLE_PID);
|
||||
|
||||
if (!dev_handle) {
|
||||
cerr << "fails to open device" << endl;
|
||||
libusb_exit(usb_ctx);
|
||||
throw std::exception();
|
||||
throw std::runtime_error("fails to open device");
|
||||
}
|
||||
}
|
||||
|
||||
ret = libusb_claim_interface(dev_handle, 0);
|
||||
if (ret) {
|
||||
cerr << "libusb error while claiming DirtyJTAG interface #0" << endl;
|
||||
libusb_close(dev_handle);
|
||||
libusb_exit(usb_ctx);
|
||||
throw std::exception();
|
||||
throw std::runtime_error("libusb error while claiming AnlogicCable interface #0");
|
||||
}
|
||||
|
||||
if (setClkFreq(clkHZ) < 0) {
|
||||
cerr << "Fail to set frequency" << endl;
|
||||
throw std::exception();
|
||||
throw std::runtime_error("Fail to set frequency");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +135,7 @@ int AnlogicCable::setClkFreq(uint32_t clkHZ)
|
|||
ret = libusb_bulk_transfer(dev_handle, ANLOGICCABLE_CONF_EP,
|
||||
buf, 2, &actual_length, 1000);
|
||||
if (ret < 0) {
|
||||
cerr << "setClkFreq: usb bulk write failed " << ret << endl;
|
||||
printError("setClkFreq: usb bulk write failed " + std::to_string(ret));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -293,14 +288,14 @@ int AnlogicCable::write(uint8_t *in_buf, uint8_t *out_buf, int len, int rd_len)
|
|||
int ret = libusb_bulk_transfer(dev_handle, ANLOGICCABLE_WRITE_EP,
|
||||
in_buf, len, &actual_length, 1000);
|
||||
if (ret < 0) {
|
||||
cerr << "write: usb bulk write failed " << ret << endl;
|
||||
printError("write: usb bulk write failed " + std::to_string(ret));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
/* all write must be followed by a read */
|
||||
ret = libusb_bulk_transfer(dev_handle, ANLOGICCABLE_READ_EP,
|
||||
in_buf, len, &actual_length, 1000);
|
||||
if (ret < 0) {
|
||||
cerr << "write: usb bulk read failed " << ret << endl;
|
||||
printError("write: usb bulk read failed " + std::to_string(ret));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@
|
|||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define display(...) \
|
||||
do { if (_verbose) fprintf(stdout, __VA_ARGS__);} while(0)
|
||||
|
||||
BitParser::BitParser(const string &filename, bool reverseOrder, bool verbose):
|
||||
BitParser::BitParser(const std::string &filename, bool reverseOrder, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE,
|
||||
verbose), _reverseOrder(reverseOrder)
|
||||
{
|
||||
|
|
@ -38,7 +37,7 @@ int BitParser::parseHeader()
|
|||
int pos_data = 0;
|
||||
int ret = 1;
|
||||
short length;
|
||||
string tmp;
|
||||
std::string tmp;
|
||||
int pos, prev_pos;
|
||||
|
||||
/* Field 1 : misc header */
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "ch347jtag.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define CH347JTAG_VID 0x1a86
|
||||
#define CH347T_JTAG_PID 0x55dd //ch347T
|
||||
|
|
@ -64,12 +63,12 @@ int CH347Jtag::usb_xfer(unsigned wlen, unsigned rlen, unsigned *ract, bool defer
|
|||
}
|
||||
|
||||
if (obuf - _obuf > MAX_BUFFER) {
|
||||
throw runtime_error("buffer overflow");
|
||||
throw std::runtime_error("buffer overflow");
|
||||
}
|
||||
|
||||
wlen += obuf - _obuf;
|
||||
if (wlen > MAX_BUFFER) {
|
||||
throw runtime_error("buffer overflow");
|
||||
throw std::runtime_error("buffer overflow");
|
||||
}
|
||||
obuf = _obuf;
|
||||
|
||||
|
|
@ -293,8 +292,8 @@ int CH347Jtag::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer,
|
|||
obuf[2] = (wlen - 3) >> 8;
|
||||
int ret = usb_xfer(wlen, 0, 0, !flush_buffer);
|
||||
if (ret < 0) {
|
||||
cerr << "writeTMS: usb bulk write failed: " <<
|
||||
libusb_strerror(static_cast<libusb_error>(ret)) << endl;
|
||||
printError(std::string("writeTMS: usb bulk write failed: ")
|
||||
+ std::string(libusb_strerror(static_cast<libusb_error>(ret))));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
ptr = obuf;
|
||||
|
|
@ -332,8 +331,8 @@ int CH347Jtag::toggleClk(__attribute__((unused)) uint8_t tms,
|
|||
obuf[2] = (wlen - 3) >> 8;
|
||||
int ret = usb_xfer(wlen, 0, 0, true);
|
||||
if (ret < 0) {
|
||||
cerr << "writeCLK: usb bulk write failed: " <<
|
||||
libusb_strerror(static_cast<libusb_error>(ret)) << endl;
|
||||
printError(std::string("writeCLK: usb bulk write failed: ")
|
||||
+ std::string(libusb_strerror(static_cast<libusb_error>(ret))));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
ptr = obuf;
|
||||
|
|
@ -371,15 +370,15 @@ int CH347Jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
unsigned actual_length = 0;
|
||||
int ret = usb_xfer(chunk + 3, (rx) ? chunk + 3 : 0, &actual_length, rx == 0 && get_obuf_length());
|
||||
if (ret < 0) {
|
||||
cerr << "writeTDI: usb bulk read failed: " <<
|
||||
libusb_strerror(static_cast<libusb_error>(ret)) << endl;
|
||||
printError(std::string("writeTDI: usb bulk read failed: ")
|
||||
+ std::string(libusb_strerror(static_cast<libusb_error>(ret))));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
if (!rx)
|
||||
continue;
|
||||
unsigned size = ibuf[1] + ibuf[2] * 0x100;
|
||||
if (ibuf[0] != CMD_BYTES_WR || actual_length - 3 != size) {
|
||||
cerr << "writeTDI: invalid read data: " << ret << endl;
|
||||
printError("writeTDI: invalid read data: " + std::to_string(ret));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
memcpy(rptr, &ibuf[3], size);
|
||||
|
|
@ -414,8 +413,8 @@ int CH347Jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
int ret = usb_xfer(wlen, (rx) ? (bits + 3) : 0, &actual_length, rx == nullptr);
|
||||
|
||||
if (ret < 0) {
|
||||
cerr << "writeTDI: usb bulk read failed: " <<
|
||||
libusb_strerror(static_cast<libusb_error>(ret)) << endl;
|
||||
printError(std::string("writeTDI: usb bulk read failed: ")
|
||||
+ std::string(libusb_strerror(static_cast<libusb_error>(ret))));
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
if (!rx)
|
||||
|
|
@ -424,7 +423,7 @@ int CH347Jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
unsigned size = ibuf[1] + ibuf[2] * 0x100;
|
||||
|
||||
if (ibuf[0] != CMD_BITS_WR || actual_length - 3 != size) {
|
||||
cerr << "writeTDI: invalid read data: " << endl;
|
||||
printError("writeTDI: invalid read data: ");
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
for (unsigned i = 0; i < size; ++i) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include "ch552_jtag.hpp"
|
||||
#include "ftdipp_mpsse.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ using namespace std;
|
|||
#endif
|
||||
|
||||
CH552_jtag::CH552_jtag(const cable_t &cable,
|
||||
const string &dev, const string &serial, uint32_t clkHZ,
|
||||
const std::string &dev, const std::string &serial, uint32_t clkHZ,
|
||||
int8_t verbose):
|
||||
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _to_read(0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "cmsisDAP.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DAP_JTAG_SEQ_TDO_CAPTURE (1 << 7)
|
||||
#define DAP_JTAG_SEQ_TMS_SHIFT(x) ((x & 0x01) << 6)
|
||||
|
|
@ -49,7 +48,7 @@ enum cmsisdap_info_id {
|
|||
INFO_ID_PID = 0x02, // Get the Product ID (string).
|
||||
INFO_ID_SERNUM = 0x03, // Get the Serial Number (string).
|
||||
INFO_ID_FWVERS = 0x04, // Get the CMSIS-DAP Firmware
|
||||
// Version (string).
|
||||
// Version (string).
|
||||
INFO_ID_TARGET_DEV_VENDOR = 0x05, // Get the Target Device Vendor (string).
|
||||
INFO_ID_TARGET_DEV_NAME = 0x06, // Get the Target Device Name (string).
|
||||
INFO_ID_HWCAP = 0xF0, // Get information about the
|
||||
|
|
@ -60,7 +59,7 @@ enum cmsisdap_info_id {
|
|||
INFO_ID_MAX_PKT_SZ = 0xFF // Get the maximum Packet Size (SHORT).
|
||||
};
|
||||
|
||||
static map<uint8_t, string> cmsisdap_info_id_str = {
|
||||
static std::map<uint8_t, std::string> cmsisdap_info_id_str = {
|
||||
{INFO_ID_VID, "VID"},
|
||||
{INFO_ID_PID, "PID"},
|
||||
{INFO_ID_SERNUM, "serial number"},
|
||||
|
|
@ -159,7 +158,7 @@ CmsisDAP::CmsisDAP(const cable_t &cable, int index, int8_t verbose):_verbose(ver
|
|||
_vid = dev_found[_device_idx]->vendor_id;
|
||||
_pid = dev_found[_device_idx]->product_id;
|
||||
if (dev_found[_device_idx]->serial_number != NULL)
|
||||
_serial_number = wstring(dev_found[_device_idx]->serial_number);
|
||||
_serial_number = std::wstring(dev_found[_device_idx]->serial_number);
|
||||
/* open the device */
|
||||
_dev = hid_open_path(dev_found[_device_idx]->path);
|
||||
if (!_dev) {
|
||||
|
|
|
|||
|
|
@ -26,9 +26,8 @@
|
|||
|
||||
#include "configBitstreamParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ConfigBitstreamParser::ConfigBitstreamParser(const string &filename, int mode,
|
||||
ConfigBitstreamParser::ConfigBitstreamParser(const std::string &filename, int mode,
|
||||
bool verbose): _filename(filename), _bit_length(0),
|
||||
_file_size(0), _verbose(verbose),
|
||||
_bit_data(), _raw_data(), _hdr()
|
||||
|
|
@ -40,7 +39,7 @@ ConfigBitstreamParser::ConfigBitstreamParser(const string &filename, int mode,
|
|||
FILE *_fd = fopen(filename.c_str(), "rb");
|
||||
if (!_fd) {
|
||||
/* if file not found it's maybe a gz -> try without gz */
|
||||
if (offset != string::npos) {
|
||||
if (offset != std::string::npos) {
|
||||
_filename = filename.substr(0, offset);
|
||||
_fd = fopen(_filename.c_str(), "rb");
|
||||
}
|
||||
|
|
@ -61,10 +60,10 @@ ConfigBitstreamParser::ConfigBitstreamParser(const string &filename, int mode,
|
|||
if (ret != _file_size)
|
||||
throw std::runtime_error("Error: fail to read " + _filename);
|
||||
|
||||
if (offset != string::npos) {
|
||||
string extension = _filename.substr(_filename.find_last_of(".") +1);
|
||||
if (offset != std::string::npos) {
|
||||
std::string extension = _filename.substr(_filename.find_last_of(".") +1);
|
||||
if (extension == "gz" || extension == "gzip") {
|
||||
string tmp;
|
||||
std::string tmp;
|
||||
tmp.reserve(_file_size);
|
||||
if (!decompress_bitstream(_raw_data, &tmp))
|
||||
throw std::runtime_error("Error: decompress failed");
|
||||
|
|
@ -77,7 +76,7 @@ ConfigBitstreamParser::ConfigBitstreamParser(const string &filename, int mode,
|
|||
|
||||
} else if (!isatty(fileno(stdin))) {
|
||||
_file_size = 0;
|
||||
string tmp;
|
||||
std::string tmp;
|
||||
tmp.resize(4096);
|
||||
size_t size;
|
||||
|
||||
|
|
@ -95,7 +94,7 @@ ConfigBitstreamParser::~ConfigBitstreamParser()
|
|||
{
|
||||
}
|
||||
|
||||
string ConfigBitstreamParser::getHeaderVal(string key)
|
||||
std::string ConfigBitstreamParser::getHeaderVal(std::string key)
|
||||
{
|
||||
auto val = _hdr.find(key);
|
||||
if (val == _hdr.end())
|
||||
|
|
@ -107,7 +106,7 @@ void ConfigBitstreamParser::displayHeader()
|
|||
{
|
||||
if (_hdr.empty())
|
||||
return;
|
||||
cout << "bitstream header infos" << endl;
|
||||
printInfo("bitstream header infos");
|
||||
for (auto it = _hdr.begin(); it != _hdr.end(); it++) {
|
||||
printInfo((*it).first + ": ", false);
|
||||
printSuccess((*it).second);
|
||||
|
|
@ -165,7 +164,7 @@ uint32_t ConfigBitstreamParser::reverse_32(const uint32_t src)
|
|||
(revertByteArr[(src >> 24) & 0xff] << 0);
|
||||
}
|
||||
|
||||
bool ConfigBitstreamParser::decompress_bitstream(string source, string *dest)
|
||||
bool ConfigBitstreamParser::decompress_bitstream(std::string source, std::string *dest)
|
||||
{
|
||||
#ifndef HAS_ZLIB
|
||||
(void)source;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@
|
|||
|
||||
#include "device.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Device::Device(Jtag *jtag, string filename, const string &file_type,
|
||||
Device::Device(Jtag *jtag, std::string filename, const std::string &file_type,
|
||||
bool verify, int8_t verbose):
|
||||
_filename(filename),
|
||||
_file_extension(filename.substr(filename.find_last_of(".") +1)),
|
||||
|
|
@ -24,13 +23,13 @@ Device::Device(Jtag *jtag, string filename, const string &file_type,
|
|||
} else if (!filename.empty()) {
|
||||
size_t offset = filename.find_last_of(".");
|
||||
/* no extension => consider raw */
|
||||
if (offset == string::npos) {
|
||||
if (offset == std::string::npos) {
|
||||
_file_extension = "raw";
|
||||
/* compressed file ? */
|
||||
} else if (_file_extension.substr(0, 2) == "gz") {
|
||||
size_t offset2 = filename.find_last_of(".", offset - 1);
|
||||
/* no more extension -> error */
|
||||
if (offset2 == string::npos) {
|
||||
if (offset2 == std::string::npos) {
|
||||
char mess[256];
|
||||
snprintf(mess, sizeof(mess), "\nfile %s is compressed\n"
|
||||
"but can't determine real type\n"
|
||||
|
|
@ -46,7 +45,7 @@ Device::Device(Jtag *jtag, string filename, const string &file_type,
|
|||
|
||||
_jtag = jtag;
|
||||
if (verbose > 0)
|
||||
cout << "File type : " << _file_extension << endl;
|
||||
std::cout << "File type : " << _file_extension << std::endl;
|
||||
}
|
||||
|
||||
Device::~Device() {}
|
||||
|
|
|
|||
19
src/dfu.cpp
19
src/dfu.cpp
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "dfu.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* USB request write */
|
||||
static const uint8_t DFU_REQUEST_OUT = LIBUSB_ENDPOINT_OUT |
|
||||
|
|
@ -46,7 +45,7 @@ enum dfu_cmd {
|
|||
* - index as jtag chain (fix issue when more than one device connected)
|
||||
*/
|
||||
|
||||
DFU::DFU(const string &filename, bool bypass_bitstream,
|
||||
DFU::DFU(const std::string &filename, bool bypass_bitstream,
|
||||
uint16_t vid, uint16_t pid, int16_t altsetting,
|
||||
int verbose_lvl):_verbose(verbose_lvl > 0), _debug(verbose_lvl > 1),
|
||||
_quiet(verbose_lvl < 0), dev_idx(0), _vid(0), _pid(0),
|
||||
|
|
@ -68,7 +67,7 @@ DFU::DFU(const string &filename, bool bypass_bitstream,
|
|||
printSuccess("DONE");
|
||||
} catch (std::exception &e) {
|
||||
printError("FAIL");
|
||||
throw runtime_error("Error: Fail to open file");
|
||||
throw std::runtime_error("Error: Fail to open file");
|
||||
}
|
||||
|
||||
printInfo("Parse file ", false);
|
||||
|
|
@ -78,7 +77,7 @@ DFU::DFU(const string &filename, bool bypass_bitstream,
|
|||
} catch (std::exception &e) {
|
||||
printError("FAIL");
|
||||
delete _bit;
|
||||
throw runtime_error("Error: Fail to parse file");
|
||||
throw std::runtime_error("Error: Fail to parse file");
|
||||
}
|
||||
|
||||
if (_verbose > 0)
|
||||
|
|
@ -301,7 +300,7 @@ int DFU::searchDFUDevices()
|
|||
/* iteration */
|
||||
ssize_t list_size = libusb_get_device_list(usb_ctx, &dev_list);
|
||||
if (_verbose)
|
||||
printInfo("found " + to_string(list_size) + " USB device");
|
||||
printInfo("found " + std::to_string(list_size) + " USB device");
|
||||
|
||||
while ((usb_dev = dev_list[i++]) != NULL) {
|
||||
struct libusb_device_descriptor desc;
|
||||
|
|
@ -352,7 +351,7 @@ int DFU::searchIfDFU(struct libusb_device_handle *handle,
|
|||
struct libusb_config_descriptor *cfg;
|
||||
int ret = libusb_get_config_descriptor(dev, i, &cfg);
|
||||
if (ret != 0) {
|
||||
printError("Fail to retrieve config_descriptor " + to_string(i));
|
||||
printError("Fail to retrieve config_descriptor " + std::to_string(i));
|
||||
return 1;
|
||||
}
|
||||
/* configuration interface iteration */
|
||||
|
|
@ -499,7 +498,7 @@ int DFU::set_state(char newState)
|
|||
return -1;
|
||||
if (status.bState != STATE_appDETACH ||
|
||||
status.bStatus != STATUS_OK) {
|
||||
cerr << dfu_dev_status_val[status.bStatus] << endl;
|
||||
std::cerr << dfu_dev_status_val[status.bStatus] << std::endl;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
|
@ -571,7 +570,7 @@ int DFU::set_state(char newState)
|
|||
return ret;
|
||||
if (status.bState != newState ||
|
||||
status.bStatus != STATUS_OK) {
|
||||
cerr << dfu_dev_status_val[status.bStatus] << endl;
|
||||
std::cerr << dfu_dev_status_val[status.bStatus] << std::endl;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
|
@ -635,7 +634,7 @@ int DFU::poll_state(uint8_t state) {
|
|||
do {
|
||||
ret = get_status(&status);
|
||||
if (ret <= 0) {
|
||||
printError("Error: poll state " + string(libusb_error_name(ret)));
|
||||
printError("Error: poll state " + std::string(libusb_error_name(ret)));
|
||||
break;
|
||||
}
|
||||
/* millisecond */
|
||||
|
|
@ -800,7 +799,7 @@ int DFU::download()
|
|||
//ret = set_state(STATE_dfuMANIFEST_SYNC);
|
||||
ret = send(true, DFU_DNLOAD, transaction, NULL, 0);
|
||||
if (ret < 0) {
|
||||
printError("Error: fail to change state " + to_string(ret));
|
||||
printError("Error: fail to change state " + std::to_string(ret));
|
||||
return -6;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#include "display.hpp"
|
||||
#include "dfuFileParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* USB Device firmware Upgrade Specification, Revision 1.1 B.1 */
|
||||
/* p. 42 */
|
||||
|
|
@ -71,7 +70,7 @@ static const uint32_t crc32tbl[] = {
|
|||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
|
||||
|
||||
DFUFileParser::DFUFileParser(const string &filename, bool verbose):
|
||||
DFUFileParser::DFUFileParser(const std::string &filename, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||
_bcdDFU(0), _idVendor(0), _idProduct(0), _bcdDevice(0),
|
||||
_dwCRC(0), _bLength(0)
|
||||
|
|
@ -81,7 +80,7 @@ DFUFileParser::DFUFileParser(const string &filename, bool verbose):
|
|||
/* p.40-47 */
|
||||
int DFUFileParser::parseHeader()
|
||||
{
|
||||
string ucDfuSignature;
|
||||
std::string ucDfuSignature;
|
||||
/* check size: If file size <= 16
|
||||
* no space for suffix and/or bitstream
|
||||
* */
|
||||
|
|
@ -114,30 +113,30 @@ int DFUFileParser::parseHeader()
|
|||
(_raw_data[_file_size - 15] << 8);
|
||||
|
||||
/* yes it's silly but it's simpliest way */
|
||||
_hdr = {{"dwCRC", string(11, ' ')}, {"bLength", ""},
|
||||
{"ucDfuSignature", string(4, ' ')}, {"bcdDFU", string(7, ' ')},
|
||||
{"idVendor", string(7, ' ')}, {"idProduct", string(7, ' ')},
|
||||
{"bcdDevice", string(7, ' ')}};
|
||||
_hdr = {{"dwCRC", std::string(11, ' ')}, {"bLength", ""},
|
||||
{"ucDfuSignature", std::string(4, ' ')}, {"bcdDFU", std::string(7, ' ')},
|
||||
{"idVendor", std::string(7, ' ')}, {"idProduct", std::string(7, ' ')},
|
||||
{"bcdDevice", std::string(7, ' ')}};
|
||||
|
||||
|
||||
char __buf[16];
|
||||
int __buf_valid_bytes;
|
||||
__buf_valid_bytes = snprintf(__buf, 11, "0x%08x", _dwCRC);
|
||||
_hdr["dwCRC"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["dwCRC"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["dwCRC"].resize(11, ' ');
|
||||
_hdr["bLength"] = to_string(_bLength);
|
||||
_hdr["bLength"] = std::to_string(_bLength);
|
||||
_hdr["ucDfuSignature"] = ucDfuSignature;
|
||||
__buf_valid_bytes = snprintf(__buf, 7, "0x%04x", _bcdDFU);
|
||||
_hdr["bcdDFU"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["bcdDFU"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["bcdDFU"].resize(7, ' ');
|
||||
__buf_valid_bytes = snprintf(__buf, 7, "0x%04x", _idVendor);
|
||||
_hdr["idVendor"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["idVendor"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["idVendor"].resize(7, ' ');
|
||||
__buf_valid_bytes = snprintf(__buf, 7, "0x%04x", _idProduct);
|
||||
_hdr["idProduct"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["idProduct"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["idProduct"].resize(7, ' ');
|
||||
__buf_valid_bytes = snprintf(__buf, 7, "0x%04x", _bcdDevice);
|
||||
_hdr["bcdDevice"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["bcdDevice"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["bcdDevice"].resize(7, ' ');
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include "dirtyJtag.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DIRTYJTAG_VID 0x1209
|
||||
#define DIRTYJTAG_PID 0xC0CA
|
||||
|
|
@ -124,14 +123,14 @@ bool DirtyJtag::getVersion()
|
|||
ret = libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP,
|
||||
buf, 2, &actual_length, DIRTYJTAG_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
cerr << "getVersion: usb bulk write failed " << ret << endl;
|
||||
std::cerr << "getVersion: usb bulk write failed " << ret << std::endl;
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
ret = libusb_bulk_transfer(dev_handle, DIRTYJTAG_READ_EP,
|
||||
rx_buf, 64, &actual_length, DIRTYJTAG_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
cerr << "getVersion: read: usb bulk read failed " << ret << endl;
|
||||
std::cerr << "getVersion: read: usb bulk read failed " << ret << std::endl;
|
||||
return false;
|
||||
}
|
||||
} while (actual_length == 0);
|
||||
|
|
@ -142,7 +141,7 @@ bool DirtyJtag::getVersion()
|
|||
} else if (!strncmp("DJTAG3\n", (char*)rx_buf, 7)) {
|
||||
_version = 3;
|
||||
} else {
|
||||
cerr << "dirtyJtag version unknown" << endl;
|
||||
std::cerr << "dirtyJtag version unknown" << std::endl;
|
||||
_version = 0;
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +170,7 @@ int DirtyJtag::setClkFreq(uint32_t clkHz)
|
|||
ret = libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP,
|
||||
buf, 4, &actual_length, DIRTYJTAG_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
cerr << "setClkFreq: usb bulk write failed " << ret << endl;
|
||||
std::cerr << "setClkFreq: usb bulk write failed " << ret << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +213,7 @@ int DirtyJtag::writeTMS(const uint8_t *tms, uint32_t len,
|
|||
buf, buffer_idx, &actual_length,
|
||||
DIRTYJTAG_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
cerr << "writeTMS: usb bulk write failed " << ret << endl;
|
||||
std::cerr << "writeTMS: usb bulk write failed " << ret << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
buffer_idx = 0;
|
||||
|
|
@ -237,7 +236,7 @@ int DirtyJtag::toggleClk(__attribute__((unused)) uint8_t tms,
|
|||
int ret = libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP,
|
||||
buf, 4, &actual_length, DIRTYJTAG_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
cerr << "toggleClk: usb bulk write failed " << ret << endl;
|
||||
std::cerr << "toggleClk: usb bulk write failed " << ret << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
clk_len -= buf[2];
|
||||
|
|
@ -303,11 +302,11 @@ int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
(unsigned char *)tx_buf, xfer_len,
|
||||
&actual_length, DIRTYJTAG_TIMEOUT);
|
||||
if ((ret < 0) || (actual_length != xfer_len)) {
|
||||
cerr << "writeTDI: fill: usb bulk write failed " << ret <<
|
||||
"actual length: " << actual_length << endl;
|
||||
std::cerr << "writeTDI: fill: usb bulk write failed " << ret <<
|
||||
"actual length: " << actual_length << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// cerr << actual_length << ", " << bit_to_send << endl;
|
||||
// std::cerr << actual_length << ", " << bit_to_send << std::endl;
|
||||
|
||||
if (rx || (_version <= 1)) {
|
||||
const int transfer_length = (bit_to_send > 255) ? byte_to_send : 32;
|
||||
|
|
@ -315,7 +314,7 @@ int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
ret = libusb_bulk_transfer(dev_handle, DIRTYJTAG_READ_EP,
|
||||
rx_buf, transfer_length, &actual_length, DIRTYJTAG_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
cerr << "writeTDI: read: usb bulk read failed " << ret << endl;
|
||||
std::cerr << "writeTDI: read: usb bulk read failed " << ret << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} while (actual_length == 0);
|
||||
|
|
@ -369,7 +368,7 @@ int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
if (libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP,
|
||||
buf, 8, &actual_length,
|
||||
DIRTYJTAG_TIMEOUT) < 0) {
|
||||
cerr << "writeTDI: last bit error: usb bulk write failed 1" << endl;
|
||||
std::cerr << "writeTDI: last bit error: usb bulk write failed 1" << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +376,7 @@ int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
if (libusb_bulk_transfer(dev_handle, DIRTYJTAG_READ_EP,
|
||||
&sig, 1, &actual_length,
|
||||
DIRTYJTAG_TIMEOUT) < 0) {
|
||||
cerr << "writeTDI: last bit error: usb bulk read failed" << endl;
|
||||
std::cerr << "writeTDI: last bit error: usb bulk read failed" << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
} while (actual_length == 0);
|
||||
|
|
@ -390,13 +389,13 @@ int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
if (libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP,
|
||||
buf, 4, &actual_length,
|
||||
DIRTYJTAG_TIMEOUT) < 0) {
|
||||
cerr << "writeTDI: last bit error: usb bulk write failed 2" << endl;
|
||||
std::cerr << "writeTDI: last bit error: usb bulk write failed 2" << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (toggleClk(_tms, _tdi, 1)) {
|
||||
cerr << "writeTDI: last bit error" << endl;
|
||||
std::cerr << "writeTDI: last bit error" << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,19 +10,18 @@
|
|||
#include "display.hpp"
|
||||
#include "efinixHexParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
EfinixHexParser::EfinixHexParser(const string &filename):
|
||||
EfinixHexParser::EfinixHexParser(const std::string &filename):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE,
|
||||
false)
|
||||
{}
|
||||
|
||||
int EfinixHexParser::parseHeader()
|
||||
{
|
||||
string buffer;
|
||||
istringstream lineStream(_raw_data);
|
||||
std::string buffer;
|
||||
std::istringstream lineStream(_raw_data);
|
||||
int bytesRead = 0;
|
||||
string headerText;
|
||||
std::string headerText;
|
||||
bool foundPaddedBits = false;
|
||||
|
||||
while (std::getline(lineStream, buffer, '\n')) {
|
||||
|
|
@ -40,20 +39,20 @@ int EfinixHexParser::parseHeader()
|
|||
break;
|
||||
}
|
||||
|
||||
if (headerText.find("PADDED_BITS") != string::npos)
|
||||
if (headerText.find("PADDED_BITS") != std::string::npos)
|
||||
foundPaddedBits = true;
|
||||
}
|
||||
|
||||
size_t pos;
|
||||
if ((pos = headerText.find("Mode: ")) != string::npos) {
|
||||
if ((pos = headerText.find("Mode: ")) != std::string::npos) {
|
||||
size_t end = headerText.find('\n', pos);
|
||||
_hdr["mode"] = headerText.substr(pos + 6, end - pos - 6);
|
||||
}
|
||||
if ((pos = headerText.find("Width: ")) != string::npos) {
|
||||
if ((pos = headerText.find("Width: ")) != std::string::npos) {
|
||||
size_t end = headerText.find('\n', pos);
|
||||
_hdr["width"] = headerText.substr(pos + 7, end - pos - 7);
|
||||
}
|
||||
if ((pos = headerText.find("Device: ")) != string::npos) {
|
||||
if ((pos = headerText.find("Device: ")) != std::string::npos) {
|
||||
size_t end = headerText.find('\n', pos);
|
||||
_hdr["device"] = headerText.substr(pos + 8, end - pos - 8);
|
||||
}
|
||||
|
|
@ -63,10 +62,10 @@ int EfinixHexParser::parseHeader()
|
|||
|
||||
int EfinixHexParser::parse()
|
||||
{
|
||||
string buffer;
|
||||
std::string buffer;
|
||||
parseHeader();
|
||||
|
||||
istringstream lineStream(_raw_data);
|
||||
std::istringstream lineStream(_raw_data);
|
||||
|
||||
while (std::getline(lineStream, buffer, '\n')) {
|
||||
_bit_data.push_back(std::stol(buffer, nullptr, 16));
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
#include "spiInterface.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class EPCQ: public SPIFlash {
|
||||
public:
|
||||
EPCQ(SPIInterface *spi, bool unprotect_flash, int8_t verbose);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ int EPCQ::erase_sector(char start_sector, char nb_sectors)
|
|||
printf("%d %d %x %x %x %x ", nb_sectors, base_addr, buffer[0], buffer[1], buffer[2], buffer[3]);
|
||||
|
||||
if (_spi.ft2232_spi_wr_and_rd(4, buffer, NULL) < 0) {
|
||||
cout << "Write error in erase_sector\n" << endl;
|
||||
std::cout << "Write error in erase_sector\n" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ int EPCQ::erase_sector(char start_sector, char nb_sectors)
|
|||
*/
|
||||
|
||||
#if 0
|
||||
void EPCQ::program(unsigned int start_offset, string filename, bool reverse)
|
||||
void EPCQ::program(unsigned int start_offset, std::string filename, bool reverse)
|
||||
{
|
||||
FILE *fd;
|
||||
int file_size, nb_sect, i, ii;
|
||||
|
|
@ -151,7 +151,7 @@ void EPCQ::program(unsigned int start_offset, string filename, bool reverse)
|
|||
*/
|
||||
fd = fopen(filename.c_str(), "r");
|
||||
if (!fd) {
|
||||
cout << "Error opening " << filename << endl;
|
||||
std::cout << "Error opening " << filename << std::endl;
|
||||
return;
|
||||
}
|
||||
fseek(fd, 0, SEEK_END);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
#include "spiInterface.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class EPCQ: public SPIFlash {
|
||||
public:
|
||||
EPCQ(SPIInterface *spi, int8_t verbose);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ this description is a copy from openocd/src/jtag/drivers/esp_usb_jtag.c
|
|||
#include "esp_usb_jtag.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define ESPUSBJTAG_VID 0x303A
|
||||
#define ESPUSBJTAG_PID 0x1001
|
||||
|
|
@ -257,7 +256,7 @@ esp_usb_jtag::esp_usb_jtag(uint32_t clkHZ, int8_t verbose, int vid = ESPUSBJTAG_
|
|||
char mess[256];
|
||||
|
||||
if (libusb_init(&usb_ctx) < 0) {
|
||||
cerr << "libusb init failed" << endl;
|
||||
std::cerr << "libusb init failed" << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +281,7 @@ esp_usb_jtag::esp_usb_jtag(uint32_t clkHZ, int8_t verbose, int vid = ESPUSBJTAG_
|
|||
|
||||
ret = libusb_claim_interface(dev_handle, ESPUSBJTAG_INTF);
|
||||
if (ret) {
|
||||
cerr << "libusb error while claiming esp_usb_jtag interface of device vid:pid 0x" << std::hex << vid << ":0x" << std::hex << pid << endl;
|
||||
std::cerr << "libusb error while claiming esp_usb_jtag interface of device vid:pid 0x" << std::hex << vid << ":0x" << std::hex << pid << std::endl;
|
||||
libusb_close(dev_handle);
|
||||
libusb_exit(usb_ctx);
|
||||
throw std::exception();
|
||||
|
|
@ -293,7 +292,7 @@ esp_usb_jtag::esp_usb_jtag(uint32_t clkHZ, int8_t verbose, int vid = ESPUSBJTAG_
|
|||
throw std::runtime_error("Fail to get version");
|
||||
|
||||
if (setClkFreq(clkHZ) < 0) {
|
||||
cerr << "Fail to set frequency" << endl;
|
||||
std::cerr << "Fail to set frequency" << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
|
|
@ -331,8 +330,8 @@ bool esp_usb_jtag::getVersion()
|
|||
}
|
||||
|
||||
for(int i = 0; i < jtag_caps_read_len; i++)
|
||||
cerr << " 0x" << std::hex << (int)(jtag_caps_desc[i]);
|
||||
cerr << endl;
|
||||
std::cerr << " 0x" << std::hex << (int)(jtag_caps_desc[i]);
|
||||
std::cerr << std::endl;
|
||||
|
||||
_base_speed_khz = UINT32_MAX;
|
||||
_div_min = 1;
|
||||
|
|
@ -342,20 +341,20 @@ bool esp_usb_jtag::getVersion()
|
|||
VEND_DESCR_BUILTIN_JTAG_CAPS ? JTAG_BUILTIN_DESCR_START_OFF : JTAG_EUB_DESCR_START_OFF;
|
||||
|
||||
if (p + sizeof(struct jtag_proto_caps_hdr) > (unsigned int)jtag_caps_read_len) {
|
||||
cerr << "esp_usb_jtag: not enough data to get header" << endl;
|
||||
std::cerr << "esp_usb_jtag: not enough data to get header" << std::endl;
|
||||
// goto out;
|
||||
}
|
||||
|
||||
struct jtag_proto_caps_hdr *hdr = (struct jtag_proto_caps_hdr *)&jtag_caps_desc[p];
|
||||
if (hdr->proto_ver != JTAG_PROTO_CAPS_VER) {
|
||||
cerr << "esp_usb_jtag: unknown jtag_caps descriptor version 0x" << std::hex
|
||||
<< hdr->proto_ver << endl;
|
||||
std::cerr << "esp_usb_jtag: unknown jtag_caps descriptor version 0x" << std::hex
|
||||
<< hdr->proto_ver << std::endl;
|
||||
// goto out;
|
||||
}
|
||||
if (hdr->length > jtag_caps_read_len) {
|
||||
cerr << "esp_usb_jtag: header length (" << hdr->length
|
||||
std::cerr << "esp_usb_jtag: header length (" << hdr->length
|
||||
<< ") bigger then max read bytes (" << jtag_caps_read_len
|
||||
<< ")" << endl;
|
||||
<< ")" << std::endl;
|
||||
// goto out;
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +366,7 @@ bool esp_usb_jtag::getVersion()
|
|||
struct jtag_gen_hdr *dhdr = (struct jtag_gen_hdr *)&jtag_caps_desc[p];
|
||||
if (dhdr->type == JTAG_PROTO_CAPS_SPEED_APB_TYPE) {
|
||||
if (p + sizeof(struct jtag_proto_caps_speed_apb) < hdr->length) {
|
||||
cerr << "esp_usb_jtag: not enough data to get caps speed" << endl;
|
||||
std::cerr << "esp_usb_jtag: not enough data to get caps speed" << std::endl;
|
||||
return false;
|
||||
}
|
||||
struct jtag_proto_caps_speed_apb *spcap = (struct jtag_proto_caps_speed_apb *)dhdr;
|
||||
|
|
@ -378,15 +377,15 @@ bool esp_usb_jtag::getVersion()
|
|||
/* TODO: mark in priv that this is apb-derived and as such may change if apb
|
||||
* ever changes? */
|
||||
} else {
|
||||
cerr << "esp_usb_jtag: unknown caps type 0x" << dhdr->type << endl;;
|
||||
std::cerr << "esp_usb_jtag: unknown caps type 0x" << dhdr->type << std::endl;;
|
||||
}
|
||||
p += dhdr->length;
|
||||
}
|
||||
if (priv->base_speed_khz == UINT32_MAX) {
|
||||
cerr << "esp_usb_jtag: No speed caps found... using sane-ish defaults." << endl;
|
||||
std::cerr << "esp_usb_jtag: No speed caps found... using sane-ish defaults." << std::endl;
|
||||
_base_speed_khz = 1000;
|
||||
}
|
||||
cerr << "esp_usb_jtag: Device found. Base speed " << std::dec << _base_speed_khz << " KHz, div range " << (int)_div_min << " to " << (int)_div_max << endl;
|
||||
std::cerr << "esp_usb_jtag: Device found. Base speed " << std::dec << _base_speed_khz << " KHz, div range " << (int)_div_min << " to " << (int)_div_max << std::endl;
|
||||
|
||||
_version = 1; // currently only protocol version 1 exists
|
||||
|
||||
|
|
@ -434,7 +433,7 @@ int esp_usb_jtag::setClkFreq(uint32_t clkHZ)
|
|||
/*timeout ms*/ ESPUSBJTAG_TIMEOUT_MS);
|
||||
|
||||
if (ret != 0) {
|
||||
cerr << "setClkFreq: usb bulk write failed " << ret << endl;
|
||||
std::cerr << "setClkFreq: usb bulk write failed " << ret << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -503,7 +502,7 @@ int esp_usb_jtag::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer,
|
|||
return -EXIT_FAILURE;
|
||||
}
|
||||
if (_verbose)
|
||||
cerr << "tms" << endl;
|
||||
std::cerr << "tms" << std::endl;
|
||||
}
|
||||
|
||||
return len;
|
||||
|
|
@ -579,11 +578,11 @@ int esp_usb_jtag::setio(int srst, int tms, int tdi, int tck)
|
|||
/*timeout ms*/ ESPUSBJTAG_TIMEOUT_MS);
|
||||
|
||||
if (ret != 0) {
|
||||
cerr << "setio: control write failed " << ret << endl;
|
||||
std::cerr << "setio: control write failed " << ret << std::endl;
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
if (_verbose)
|
||||
cerr << "setio 0x" << std::hex << wvalue << endl;
|
||||
std::cerr << "setio 0x" << std::hex << wvalue << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -708,12 +707,12 @@ int esp_usb_jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool en
|
|||
// last byte in buf will have data in both nibbles, no flush
|
||||
// exec order: high-nibble-first, low-nibble-second
|
||||
if (_verbose) {
|
||||
cerr << "is high nibble=" << (int)is_high_nibble << endl;
|
||||
std::cerr << "is high nibble=" << (int)is_high_nibble << std::endl;
|
||||
//int bits_in_tx_buf = 0;
|
||||
for(uint32_t i = 0; i < (len + 7) >> 3; i++)
|
||||
cerr << " " << std::hex << (int)tdi[i];
|
||||
cerr << endl;
|
||||
cerr << "tdi_bits ";
|
||||
std::cerr << " " << std::hex << (int)tdi[i];
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "tdi_bits ";
|
||||
}
|
||||
|
||||
for (uint32_t pos = 0; pos < len; pos += xfer_len) {
|
||||
|
|
@ -739,7 +738,7 @@ int esp_usb_jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool en
|
|||
uint32_t curr_pos = pos + i;
|
||||
_tdi = (tdi[curr_pos >> 3] >> (curr_pos & 7)) & 1; // get i'th bit from rx
|
||||
if (_verbose)
|
||||
cerr << (int)_tdi;
|
||||
std::cerr << (int)_tdi;
|
||||
if (end && curr_pos == len - 1)
|
||||
_tms = 1;
|
||||
const uint8_t cmd = CMD_CLK(tdo, _tdi, _tms); // with TDO capture
|
||||
|
|
@ -768,7 +767,7 @@ int esp_usb_jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool en
|
|||
return -EXIT_FAILURE;
|
||||
}
|
||||
if (_verbose)
|
||||
cerr << "writeTDI write 0x" << tx_buffer_idx << " bytes" << endl;
|
||||
std::cerr << "writeTDI write 0x" << tx_buffer_idx << " bytes" << std::endl;
|
||||
if (rx) {
|
||||
flush(); // must flush before reading
|
||||
// TODO support odd len for TDO
|
||||
|
|
@ -788,7 +787,7 @@ int esp_usb_jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool en
|
|||
nb_try++;
|
||||
} while (nb_try < 3 && ret == 0);
|
||||
if (_verbose)
|
||||
cerr << "writeTDI read " << std::to_string(ret) << endl;
|
||||
std::cerr << "writeTDI read " << std::to_string(ret) << std::endl;
|
||||
if (read_byte_len != ret) {
|
||||
snprintf(mess, 256, "writeTDI: usb bulk read expected=%d received=%d", read_byte_len, ret);
|
||||
printError(mess);
|
||||
|
|
|
|||
|
|
@ -63,9 +63,8 @@
|
|||
# define FEATURE_CORE_CLK_SEL (0x03 << 30) /* Core Clock Sel */
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
FeaParser::FeaParser(const string &filename, bool verbose):
|
||||
FeaParser::FeaParser(const std::string &filename, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||
_feabits(0), _has_feabits(false)
|
||||
{
|
||||
|
|
@ -76,14 +75,14 @@ FeaParser::FeaParser(const string &filename, bool verbose):
|
|||
/* fill a vector with consecutive lines, beginning with 0 or 1, until EOF
|
||||
* \brief read a line with '\r''\n' or '\n' termination
|
||||
* check if last char is '\r'
|
||||
* \return a vector of lines without [\r]\n
|
||||
* \return a std::vector of lines without [\r]\n
|
||||
*/
|
||||
vector<string> FeaParser::readFeaFile()
|
||||
std::vector<std::string> FeaParser::readFeaFile()
|
||||
{
|
||||
vector<string> lines;
|
||||
std::vector<std::string> lines;
|
||||
|
||||
while (true) {
|
||||
string buffer;
|
||||
std::string buffer;
|
||||
std::getline(_ss, buffer, '\n');
|
||||
if (buffer.empty())
|
||||
break;
|
||||
|
|
@ -230,16 +229,16 @@ void FeaParser::displayHeader()
|
|||
* 1: xxxx\n : feature Row (96 bits)
|
||||
* 2: yyyy*\n : feabits (32 bits)
|
||||
*/
|
||||
void FeaParser::parseFeatureRowAndFeabits(const vector<string> &content)
|
||||
void FeaParser::parseFeatureRowAndFeabits(const std::vector<std::string> &content)
|
||||
{
|
||||
printf("Parsing Feature Row & FEAbits...\n");
|
||||
|
||||
string featuresRow = content[0];
|
||||
std::string featuresRow = content[0];
|
||||
//printf("Features: [%s]\n", featuresRow.c_str());
|
||||
for (size_t i = 0; i < featuresRow.size(); i++)
|
||||
_featuresRow[3 - (i/32) - 1] |= ((featuresRow[i] - '0') << (32 - (i%32) - 1));
|
||||
|
||||
string feabits = content[1];
|
||||
std::string feabits = content[1];
|
||||
//printf("Feabits: [%s]\n", feabits.c_str());
|
||||
_feabits = 0;
|
||||
for (size_t i = 0; i < feabits.size(); i++) {
|
||||
|
|
@ -249,7 +248,7 @@ void FeaParser::parseFeatureRowAndFeabits(const vector<string> &content)
|
|||
|
||||
int FeaParser::parse()
|
||||
{
|
||||
std::vector<string>lines;
|
||||
std::vector<std::string>lines;
|
||||
|
||||
_ss.str(_raw_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,8 @@
|
|||
#include "fsparser.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FsParser::FsParser(const string &filename, bool reverseByte, bool verbose):
|
||||
FsParser::FsParser(const std::string &filename, bool reverseByte, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE,
|
||||
verbose), _reverseByte(reverseByte), _end_header(0), _checksum(0),
|
||||
_8Zero(0xff), _4Zero(0xff), _2Zero(0xff),
|
||||
|
|
@ -36,11 +35,11 @@ uint64_t FsParser::bitToVal(const char *bits, int len)
|
|||
int FsParser::parseHeader()
|
||||
{
|
||||
int ret = 0;
|
||||
string buffer;
|
||||
std::string buffer;
|
||||
int line_index = 0;
|
||||
bool in_header = true;
|
||||
|
||||
istringstream lineStream(_raw_data);
|
||||
std::istringstream lineStream(_raw_data);
|
||||
|
||||
while (std::getline(lineStream, buffer, '\n')) {
|
||||
ret += buffer.size() + 1;
|
||||
|
|
@ -69,12 +68,12 @@ int FsParser::parseHeader()
|
|||
case 0x06: /* idCode */
|
||||
_idcode = (0xffffffff & val);
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%08x", _idcode);
|
||||
_hdr["idcode"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"].resize(8, ' ');
|
||||
break;
|
||||
case 0x0A: /* user code or checksum ? */
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%08x", (uint32_t)(0xffffffff & val));
|
||||
_hdr["CheckSum"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["CheckSum"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["CheckSum"].resize(8, ' ');
|
||||
break;
|
||||
case 0x0B: /* only present when bit_security is set */
|
||||
|
|
@ -90,7 +89,7 @@ int FsParser::parseHeader()
|
|||
} else {
|
||||
rate = 2500000; // default
|
||||
}
|
||||
_hdr["LoadingRate"] = to_string(rate);
|
||||
_hdr["LoadingRate"] = std::to_string(rate);
|
||||
_compressed = (val >> 13) & 1;
|
||||
_hdr["Compress"] = (_compressed) ? "ON" : "OFF";
|
||||
_hdr["ProgramDoneBypass"] = ((val >> 12) & 1) ? "ON" : "OFF";
|
||||
|
|
@ -112,7 +111,7 @@ int FsParser::parseHeader()
|
|||
uint32_t flash_addr;
|
||||
flash_addr = val & 0xffffffff;
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%08x", flash_addr);
|
||||
_hdr["SPIAddr"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["SPIAddr"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["SPIAddr"].resize(8, ' ');
|
||||
|
||||
break;
|
||||
|
|
@ -123,7 +122,7 @@ int FsParser::parseHeader()
|
|||
crc = 0x01 & (val >> 23);
|
||||
|
||||
_hdr["CRCCheck"] = (crc) ? "ON" : "OFF";
|
||||
_hdr["ConfDataLength"] = to_string(0xffff & val);
|
||||
_hdr["ConfDataLength"] = std::to_string(0xffff & val);
|
||||
_end_header = line_index;
|
||||
break;
|
||||
}
|
||||
|
|
@ -136,7 +135,7 @@ int FsParser::parseHeader()
|
|||
|
||||
int FsParser::parse()
|
||||
{
|
||||
string tmp;
|
||||
std::string tmp;
|
||||
/* GW1N-6 and GW1N(R)-9 are address length not multiple of byte */
|
||||
int padding = 0;
|
||||
|
||||
|
|
@ -236,17 +235,17 @@ int FsParser::parse()
|
|||
drop += 2 * 8;
|
||||
for (auto &&ll = _lstRawData.begin();
|
||||
ll != _lstRawData.end(); ll++) {
|
||||
string l = "";
|
||||
string line = *ll;
|
||||
std::string l = "";
|
||||
std::string line = *ll;
|
||||
if (_compressed) {
|
||||
for (size_t i = 0; i < line.size()-drop; i+=8) {
|
||||
uint8_t c = bitToVal((const char *)&line[i], 8);
|
||||
if (c == _8Zero)
|
||||
l += string(8*8, '0');
|
||||
l += std::string(8*8, '0');
|
||||
else if (c == _4Zero)
|
||||
l += string(4*8, '0');
|
||||
l += std::string(4*8, '0');
|
||||
else if (c == _2Zero)
|
||||
l += string(2*8, '0');
|
||||
l += std::string(2*8, '0');
|
||||
else
|
||||
l += line.substr(i, 8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#include "ftdiJtagBitbang.hpp"
|
||||
#include "ftdipp_mpsse.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
|
@ -31,7 +30,7 @@ using namespace std;
|
|||
#endif
|
||||
|
||||
FtdiJtagBitBang::FtdiJtagBitBang(const cable_t &cable,
|
||||
const jtag_pins_conf_t *pin_conf, const string &dev,
|
||||
const jtag_pins_conf_t *pin_conf, const std::string &dev,
|
||||
const std::string &serial, uint32_t clkHZ, int8_t verbose):
|
||||
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _bitmode(0),
|
||||
_curr_tms(0), _rx_size(0)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#include "ftdiJtagMPSSE.hpp"
|
||||
#include "ftdipp_mpsse.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
|
@ -31,7 +30,7 @@ using namespace std;
|
|||
#endif
|
||||
|
||||
FtdiJtagMPSSE::FtdiJtagMPSSE(const cable_t &cable,
|
||||
const string &dev, const string &serial, uint32_t clkHZ,
|
||||
const std::string &dev, const std::string &serial, uint32_t clkHZ,
|
||||
bool invert_read_edge, int8_t verbose):
|
||||
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _ch552WA(false),
|
||||
_cmd8EWA(false),
|
||||
|
|
|
|||
|
|
@ -20,13 +20,12 @@
|
|||
#include "display.hpp"
|
||||
#include "ftdipp_mpsse.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//#define DEBUG 1
|
||||
#define display(...) \
|
||||
do { if (_verbose) fprintf(stdout, __VA_ARGS__);}while(0)
|
||||
|
||||
FTDIpp_MPSSE::FTDIpp_MPSSE(const cable_t &cable, const string &dev,
|
||||
FTDIpp_MPSSE::FTDIpp_MPSSE(const cable_t &cable, const std::string &dev,
|
||||
const std::string &serial, uint32_t clkHZ, int8_t verbose):
|
||||
_verbose(verbose > 2), _cable(cable.config), _vid(0),
|
||||
_pid(0), _index(0),
|
||||
|
|
@ -41,7 +40,7 @@ FTDIpp_MPSSE::FTDIpp_MPSSE(const cable_t &cable, const string &dev,
|
|||
strcpy(_product, "");
|
||||
if (!dev.empty()) {
|
||||
if (!search_with_dev(dev)) {
|
||||
cerr << "No cable found" << endl;
|
||||
std::cerr << "No cable found" << std::endl;
|
||||
throw std::runtime_error("No cable found");
|
||||
}
|
||||
} else {
|
||||
|
|
@ -159,7 +158,7 @@ void FTDIpp_MPSSE::open_device(const std::string &serial, unsigned int baudrate)
|
|||
|
||||
_ftdi = ftdi_new();
|
||||
if (_ftdi == NULL) {
|
||||
cout << "open_device: failed to initialize ftdi" << endl;
|
||||
std::cout << "open_device: failed to initialize ftdi" << std::endl;
|
||||
throw std::runtime_error("open_device: failed to initialize ftdi");
|
||||
}
|
||||
#if (ATTACH_KERNEL && (FTDI_VERSION >= 105))
|
||||
|
|
@ -277,14 +276,14 @@ int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode,
|
|||
if ((ret = ftdi_usb_reset(_ftdi)) < 0) {
|
||||
printError("FTDI reset error with code " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = ftdi_set_bitmode(_ftdi, 0x00, BITMODE_RESET)) < 0) {
|
||||
printError("FTDI bitmode reset error with code " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -295,27 +294,27 @@ int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode,
|
|||
#endif
|
||||
printError("FTDI flush buffer error with code " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
if ((ret = ftdi_set_latency_timer(_ftdi, latency)) < 0) {
|
||||
printError("FTDI set latency timer error with code " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
/* enable mode */
|
||||
if ((ret = ftdi_set_bitmode(_ftdi, bitmask_mode, mode)) < 0) {
|
||||
printError("FTDI bitmode config error with code " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
if (mode == BITMODE_MPSSE) {
|
||||
unsigned char buf1[5];
|
||||
if ((ret = ftdi_read_data(_ftdi, buf1, 5)) < 0) {
|
||||
printError("fail to read data " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -344,24 +343,24 @@ int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode,
|
|||
}
|
||||
if ((ret = mpsse_store(buf_cmd, to_wr)) < 0) {
|
||||
printError("fail to store buffer " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return -1;
|
||||
}
|
||||
if (mpsse_write() < 0) {
|
||||
printError("fail to write buffer " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ftdi_read_data_set_chunksize(_ftdi, _buffer_size) < 0) {
|
||||
printError("fail to set read chunk size: " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return -1;
|
||||
}
|
||||
if (ftdi_write_data_set_chunksize(_ftdi, _buffer_size) < 0) {
|
||||
printError("fail to set write chunk size: " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +381,7 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ)
|
|||
#else
|
||||
if ((ret = ftdi_tcioflush(_ftdi)) < 0) {
|
||||
printError("selfClkFreq: fail to flush buffers: " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +420,7 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ)
|
|||
__buf_valid_bytes = snprintf(__buf, 10, "%3.2fKHz", clkHZ / 1e3);
|
||||
else
|
||||
__buf_valid_bytes = snprintf(__buf, 10, "%3u.00Hz", clkHZ);
|
||||
string clkHZ_str(__buf, __buf_valid_bytes);
|
||||
std::string clkHZ_str(__buf, __buf_valid_bytes);
|
||||
clkHZ_str.resize(10, ' ');
|
||||
if (real_freq >= 1e6)
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%2.2fMHz", real_freq / 1e6);
|
||||
|
|
@ -429,7 +428,7 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ)
|
|||
__buf_valid_bytes = snprintf(__buf, 10, "%3.2fKHz", real_freq / 1e3);
|
||||
else
|
||||
__buf_valid_bytes = snprintf(__buf, 10, "%3.2fHz", real_freq);
|
||||
string real_freq_str(__buf, __buf_valid_bytes);
|
||||
std::string real_freq_str(__buf, __buf_valid_bytes);
|
||||
real_freq_str.resize(10, ' ');
|
||||
|
||||
|
||||
|
|
@ -453,7 +452,7 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ)
|
|||
}
|
||||
if ((ret = ftdi_read_data(_ftdi, buffer, 4)) < 0) {
|
||||
printError("selfClkFreq: fail to read: " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -478,7 +477,7 @@ int FTDIpp_MPSSE::mpsse_store(unsigned char *buff, int len)
|
|||
if ((ret = mpsse_write()) < 0) {
|
||||
printError("mpsse_store: fails to first flush " +
|
||||
std::to_string(ret) + " " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
@ -493,7 +492,7 @@ int FTDIpp_MPSSE::mpsse_store(unsigned char *buff, int len)
|
|||
if ((ret = mpsse_write()) < 0) {
|
||||
printError("mpsse_store: fails to first flush " +
|
||||
std::to_string(ret) + " " +
|
||||
string(ftdi_get_error_string(_ftdi)));
|
||||
std::string(ftdi_get_error_string(_ftdi)));
|
||||
return ret;
|
||||
}
|
||||
ptr += store_size;
|
||||
|
|
@ -523,7 +522,7 @@ int FTDIpp_MPSSE::mpsse_write()
|
|||
if ((ret = ftdi_write_data(_ftdi, _buffer, _num)) != _num) {
|
||||
printError("mpsse_write: fail to write with error " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -541,14 +540,14 @@ int FTDIpp_MPSSE::mpsse_read(unsigned char *rx_buff, int len)
|
|||
if ((ret = mpsse_store(SEND_IMMEDIATE)) < 0) {
|
||||
printError("mpsse_read: fail to store with error: " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = mpsse_write()) < 0) {
|
||||
printError("mpsse_read: fail to flush buffer with error: " +
|
||||
std::to_string(ret) + " (" +
|
||||
string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
std::string(ftdi_get_error_string(_ftdi)) + ")");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -825,7 +824,7 @@ unsigned int FTDIpp_MPSSE::udevstufftoint(const char *udevstring, int base)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
bool FTDIpp_MPSSE::search_with_dev(const string &device)
|
||||
bool FTDIpp_MPSSE::search_with_dev(const std::string &device)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_device *dev, *usbdeviceparent;
|
||||
|
|
@ -899,7 +898,7 @@ unsigned int FTDIpp_MPSSE::udevstufftoint(const char *udevstring, int base)
|
|||
(void)base;
|
||||
return 0;
|
||||
}
|
||||
bool FTDIpp_MPSSE::search_with_dev(const string &device)
|
||||
bool FTDIpp_MPSSE::search_with_dev(const std::string &device)
|
||||
{
|
||||
(void)device;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -15,14 +15,13 @@
|
|||
#include "fx2_ll.hpp"
|
||||
#include "ihexParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define FX2_FIRM_LOAD 0xA0
|
||||
#define FX2_GCR_CPUCS 0xe600
|
||||
#define FX2_GCR_CPUCS_8051_RES (1 << 0)
|
||||
|
||||
FX2_ll::FX2_ll(uint16_t uninit_vid, uint16_t uninit_pid,
|
||||
uint16_t vid, uint16_t pid, const string &firmware_path)
|
||||
uint16_t vid, uint16_t pid, const std::string &firmware_path)
|
||||
{
|
||||
int ret;
|
||||
bool reenum = false;
|
||||
|
|
@ -168,7 +167,7 @@ int FX2_ll::read_ctrl(uint8_t bRequest, uint16_t wValue,
|
|||
* and 64B by 64B
|
||||
* set CPU in reset state before and restart after
|
||||
*/
|
||||
bool FX2_ll::load_firmware(string firmware_path)
|
||||
bool FX2_ll::load_firmware(std::string firmware_path)
|
||||
{
|
||||
IhexParser ihex(firmware_path, false, true);
|
||||
ihex.parse();
|
||||
|
|
@ -177,7 +176,7 @@ bool FX2_ll::load_firmware(string firmware_path)
|
|||
if (!reset(1))
|
||||
return false;
|
||||
/* load */
|
||||
vector<IhexParser::data_line_t> data = ihex.getDataArray();
|
||||
std::vector<IhexParser::data_line_t> data = ihex.getDataArray();
|
||||
for (size_t i = 0; i < data.size(); i++) {
|
||||
IhexParser::data_line_t data_line = data[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#include "rawParser.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef STATUS_TIMEOUT
|
||||
// defined in the Windows headers included by libftdi.h
|
||||
|
|
@ -75,7 +74,7 @@ using namespace std;
|
|||
#define BSCAN_GW1NSR_4C_SPI_DO (1 << 1)
|
||||
#define BSCAN_GW1NSR_4C_SPI_MSK (1 << 0)
|
||||
|
||||
Gowin::Gowin(Jtag *jtag, const string filename, const string &file_type, std::string mcufw,
|
||||
Gowin::Gowin(Jtag *jtag, const std::string filename, const std::string &file_type, std::string mcufw,
|
||||
Device::prog_type_t prg_type, bool external_flash,
|
||||
bool verify, int8_t verbose, const std::string& user_flash)
|
||||
: Device(jtag, filename, file_type, verify, verbose),
|
||||
|
|
@ -128,7 +127,7 @@ Gowin::Gowin(Jtag *jtag, const string filename, const string &file_type, std::st
|
|||
|
||||
/* for fs file check match with targeted device */
|
||||
if (_file_extension == "fs") {
|
||||
string idcode_str = _fs->getHeaderVal("idcode");
|
||||
std::string idcode_str = _fs->getHeaderVal("idcode");
|
||||
uint32_t fs_idcode = std::stoul(idcode_str.c_str(), NULL, 16);
|
||||
if ((fs_idcode & 0x0fffffff) != _idcode) {
|
||||
char mess[256];
|
||||
|
|
@ -437,7 +436,7 @@ void Gowin::checkCRC()
|
|||
* is used, try to compare with this value
|
||||
*/
|
||||
try {
|
||||
string hdr = _fs->getHeaderVal("checkSum");
|
||||
std::string hdr = _fs->getHeaderVal("checkSum");
|
||||
if (!hdr.empty()) {
|
||||
if (ucode == strtol(hdr.c_str(), NULL, 16))
|
||||
goto success;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include "display.hpp"
|
||||
#include "ihexParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* line format
|
||||
* :LLAAAATTHH...HHCC
|
||||
|
|
@ -34,7 +33,7 @@ using namespace std;
|
|||
#define TYPE_BASE 7
|
||||
#define DATA_BASE 9
|
||||
|
||||
IhexParser::IhexParser(const string &filename, bool reverseOrder, bool verbose):
|
||||
IhexParser::IhexParser(const std::string &filename, bool reverseOrder, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE,
|
||||
verbose),
|
||||
_base_addr(0), _reverseOrder(reverseOrder)
|
||||
|
|
@ -42,8 +41,8 @@ IhexParser::IhexParser(const string &filename, bool reverseOrder, bool verbose):
|
|||
|
||||
int IhexParser::parse()
|
||||
{
|
||||
string str;
|
||||
istringstream lineStream(_raw_data);
|
||||
std::string str;
|
||||
std::istringstream lineStream(_raw_data);
|
||||
|
||||
uint16_t next_addr = 0;
|
||||
bool is_first = true;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@
|
|||
* - be less lattice compliant
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
JedParser::JedParser(const string &filename, bool verbose):
|
||||
JedParser::JedParser(const std::string &filename, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||
_fuse_count(0), _pin_count(0), _max_vect_test(0),
|
||||
_featuresRow(0), _feabits(0), _has_feabits(false), _checksum(0),
|
||||
|
|
@ -46,9 +45,9 @@ JedParser::JedParser(const string &filename, bool verbose):
|
|||
* check if last char is '\r'
|
||||
* \return the line without [\r]\n
|
||||
*/
|
||||
string JedParser::readline()
|
||||
std::string JedParser::readline()
|
||||
{
|
||||
string buffer;
|
||||
std::string buffer;
|
||||
std::getline(_ss, buffer, '\n');
|
||||
if (!buffer.empty()) {
|
||||
/* if '\r' is present -> drop */
|
||||
|
|
@ -60,10 +59,10 @@ string JedParser::readline()
|
|||
|
||||
/* fill a vector with consecutive lines until '*'
|
||||
*/
|
||||
vector<string> JedParser::readJEDLine()
|
||||
std::vector<std::string> JedParser::readJEDLine()
|
||||
{
|
||||
string buffer;
|
||||
vector<string> lines;
|
||||
std::string buffer;
|
||||
std::vector<std::string> lines;
|
||||
bool inLine = true;
|
||||
|
||||
do {
|
||||
|
|
@ -83,10 +82,10 @@ vector<string> JedParser::readJEDLine()
|
|||
/* convert one serie ASCII 1/0 to a vector of
|
||||
* unsigned char
|
||||
*/
|
||||
void JedParser::buildDataArray(const string &content, struct jed_data &jed)
|
||||
void JedParser::buildDataArray(const std::string &content, struct jed_data &jed)
|
||||
{
|
||||
size_t data_len = content.size();
|
||||
string tmp_buff;
|
||||
std::string tmp_buff;
|
||||
fuselist += content;
|
||||
for (size_t i = 0; i < content.size(); i+=8) {
|
||||
uint8_t data = 0;
|
||||
|
|
@ -104,11 +103,11 @@ void JedParser::buildDataArray(const string &content, struct jed_data &jed)
|
|||
* unsigned char
|
||||
* string must be up to 8 bits
|
||||
*/
|
||||
void JedParser::buildDataArray(const vector<string> &content,
|
||||
void JedParser::buildDataArray(const std::vector<std::string> &content,
|
||||
struct jed_data &jed)
|
||||
{
|
||||
size_t data_len = 0;
|
||||
string tmp_buff;
|
||||
std::string tmp_buff;
|
||||
for (size_t i = 0; i < content.size(); i++) {
|
||||
uint8_t data = 0;
|
||||
data_len += content[i].size();
|
||||
|
|
@ -183,20 +182,20 @@ void JedParser::displayHeader()
|
|||
* 1: Exxxx\n : feature Row
|
||||
* 2: yyyy*\n : feabits
|
||||
*/
|
||||
void JedParser::parseEField(const vector<string> &content)
|
||||
void JedParser::parseEField(const std::vector<std::string> &content)
|
||||
{
|
||||
_featuresRow = 0;
|
||||
string featuresRow = content[0].substr(1);
|
||||
std::string featuresRow = content[0].substr(1);
|
||||
for (size_t i = 0; i < featuresRow.size(); ++i)
|
||||
_featuresRow |= (uint64_t(featuresRow[i] - '0') << i);
|
||||
string feabits = content[1];
|
||||
std::string feabits = content[1];
|
||||
_feabits = 0;
|
||||
for (size_t i = 0; i < feabits.size(); i++) {
|
||||
_feabits |= ((feabits[i] - '0') << i);
|
||||
}
|
||||
}
|
||||
|
||||
void JedParser::parseLField(const vector<string> &content)
|
||||
void JedParser::parseLField(const std::vector<std::string> &content)
|
||||
{
|
||||
int start_offset;
|
||||
sscanf(content[0].substr(1).c_str(), "%d", &start_offset);
|
||||
|
|
@ -216,8 +215,8 @@ void JedParser::parseLField(const vector<string> &content)
|
|||
} else {
|
||||
// search space
|
||||
std::istringstream iss(content[0]);
|
||||
vector<string> myList((std::istream_iterator<string>(iss)),
|
||||
std::istream_iterator<string>());
|
||||
std::vector<std::string> myList((std::istream_iterator<std::string>(iss)),
|
||||
std::istream_iterator<std::string>());
|
||||
|
||||
myList.erase(myList.begin());
|
||||
|
||||
|
|
@ -228,11 +227,11 @@ void JedParser::parseLField(const vector<string> &content)
|
|||
|
||||
int JedParser::parse()
|
||||
{
|
||||
string previousNote;
|
||||
std::string previousNote;
|
||||
|
||||
_ss.str(_raw_data);
|
||||
|
||||
string content;
|
||||
std::string content;
|
||||
|
||||
/* JED file may have some ASCII line before STX (0x02)
|
||||
* read until STX or EOF
|
||||
|
|
@ -261,7 +260,7 @@ int JedParser::parse()
|
|||
/* read full content
|
||||
* JED file end fix ETX (0x03) + file checksum + \n
|
||||
*/
|
||||
std::vector<string>lines;
|
||||
std::vector<std::string>lines;
|
||||
int first_pos;
|
||||
char instr;
|
||||
do {
|
||||
|
|
@ -297,7 +296,7 @@ int JedParser::parse()
|
|||
_max_vect_test = count;
|
||||
break;
|
||||
default:
|
||||
cerr << "Error for 'Q' unknown qualifier " << lines[0] << endl;
|
||||
std::cerr << "Error for 'Q' unknown qualifier " << lines[0] << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -316,7 +315,7 @@ int JedParser::parse()
|
|||
break;
|
||||
case 0x03:
|
||||
if (_verbose)
|
||||
cout << "end" << endl;
|
||||
std::cout << "end" << std::endl;
|
||||
break;
|
||||
case 'E':
|
||||
parseEField(lines);
|
||||
|
|
@ -344,7 +343,7 @@ int JedParser::parse()
|
|||
break;
|
||||
default:
|
||||
printf("inconnu\n");
|
||||
cout << lines[0]<< endl;
|
||||
std::cout << lines[0]<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} while (instr != 0x03);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#define VID 0x1366
|
||||
#define PID 0x0105
|
||||
|
||||
using namespace std;
|
||||
|
||||
// convert 2Byte to 1 short
|
||||
#define CONV_16B(_val) ((((uint16_t) _val[0]) << 0) | \
|
||||
|
|
@ -458,13 +457,13 @@ bool Jlink::write_device(const uint8_t *buf, uint32_t size)
|
|||
return ((uint32_t)recv == size);
|
||||
}
|
||||
|
||||
string Jlink::get_version()
|
||||
std::string Jlink::get_version()
|
||||
{
|
||||
uint16_t length = 0;
|
||||
cmd_read(EMU_CMD_VERSION, &length);
|
||||
uint8_t version[length];
|
||||
read_device(version, length);
|
||||
return string(reinterpret_cast<char*>(version));
|
||||
return std::string(reinterpret_cast<char*>(version));
|
||||
}
|
||||
|
||||
int Jlink::get_hw_version()
|
||||
|
|
@ -689,7 +688,7 @@ bool Jlink::jlink_scan_usb(int vid, int pid)
|
|||
continue;
|
||||
if (desc.idProduct != pid) {
|
||||
if (_verbose)
|
||||
cerr << "skip pid" << hex << desc.idProduct << dec << endl;
|
||||
std::cerr << "skip pid" << std::hex << desc.idProduct << std::dec << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
15
src/jtag.cpp
15
src/jtag.cpp
|
|
@ -59,7 +59,6 @@
|
|||
#include "xvc_client.hpp"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
|
@ -94,10 +93,10 @@ using namespace std;
|
|||
*/
|
||||
|
||||
Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||
const string &dev,
|
||||
const string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const string &ip_adr, int port,
|
||||
const bool invert_read_edge, const string &firmware_path,
|
||||
const std::string &dev,
|
||||
const std::string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const std::string &ip_adr, int port,
|
||||
const bool invert_read_edge, const std::string &firmware_path,
|
||||
const std::map<uint32_t, misc_device> &user_misc_devs):
|
||||
_verbose(verbose > 1),
|
||||
_state(RUN_TEST_IDLE),
|
||||
|
|
@ -344,7 +343,7 @@ int Jtag::device_select(unsigned index)
|
|||
* after the selected one
|
||||
*/
|
||||
_dr_bits_after = device_index;
|
||||
_dr_bits = vector<uint8_t>((std::max(_dr_bits_after, _dr_bits_before) + 7)/8, 0);
|
||||
_dr_bits = std::vector<uint8_t>((std::max(_dr_bits_after, _dr_bits_before) + 7)/8, 0);
|
||||
|
||||
/* when the device is not alone and not
|
||||
* the first a serie of bypass must be
|
||||
|
|
@ -361,7 +360,7 @@ int Jtag::device_select(unsigned index)
|
|||
_ir_bits_before = 0;
|
||||
for (unsigned i = device_index + 1; i < _devices_list.size(); ++i)
|
||||
_ir_bits_before += _irlength_list[i];
|
||||
_ir_bits = vector<uint8_t>((std::max(_ir_bits_before, _ir_bits_after) + 7) / 8, 0xff); // BYPASS command is all-ones
|
||||
_ir_bits = std::vector<uint8_t>((std::max(_ir_bits_before, _ir_bits_after) + 7) / 8, 0xff); // BYPASS command is all-ones
|
||||
|
||||
return device_index;
|
||||
}
|
||||
|
|
@ -466,7 +465,7 @@ int Jtag::shiftDR(const uint8_t *tdi, unsigned char *tdo, int drlen, tapState_t
|
|||
int Jtag::shiftIR(unsigned char tdi, int irlen, tapState_t end_state)
|
||||
{
|
||||
if (irlen > 8) {
|
||||
cerr << "Error: this method this direct char don't support more than 1 byte" << endl;
|
||||
std::cerr << "Error: this method this direct char don't support more than 1 byte" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
return shiftIR(&tdi, NULL, irlen, end_state);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "part.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define ISC_ENABLE 0xC6 /* ISC_ENABLE - Offline Mode */
|
||||
# define ISC_ENABLE_FLASH_MODE (1 << 3)
|
||||
|
|
@ -162,7 +161,7 @@ using namespace std;
|
|||
/* Nexus */
|
||||
#define REG_NEXUS_STATUS_BSE_ERR_MASK (0x0f << 24)
|
||||
|
||||
Lattice::Lattice(Jtag *jtag, const string filename, const 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(jtag, filename, file_type, verify, verbose),
|
||||
SPIInterface(filename, verbose, 0, verify, skip_load_bridge, skip_reset),
|
||||
|
|
@ -188,7 +187,7 @@ Lattice::Lattice(Jtag *jtag, const string filename, const string &file_type,
|
|||
}
|
||||
/* check device family */
|
||||
uint32_t idcode = _jtag->get_target_device_id();
|
||||
string family = fpga_list[idcode].family;
|
||||
std::string family = fpga_list[idcode].family;
|
||||
if (family == "MachXO2") {
|
||||
_fpga_family = MACHXO2_FAMILY;
|
||||
} else if (family == "MachXO3L" || family == "MachXO3LF") {
|
||||
|
|
@ -643,7 +642,7 @@ bool Lattice::program_intFlash(ConfigBitstreamParser *_cbp)
|
|||
uint16_t ufm_start = 0;
|
||||
uint16_t feabits;
|
||||
uint8_t eraseMode = 0;
|
||||
vector<string> ufm_data, cfg_data, ebr_data;
|
||||
std::vector<std::string> ufm_data, cfg_data, ebr_data;
|
||||
|
||||
/* bypass */
|
||||
wr_rd(0xff, NULL, 0, NULL, 0);
|
||||
|
|
@ -663,7 +662,7 @@ bool Lattice::program_intFlash(ConfigBitstreamParser *_cbp)
|
|||
if (_file_extension == "jed") {
|
||||
JedParser *_jed = reinterpret_cast<JedParser *>(_cbp);
|
||||
for (size_t i = 0; i < _jed->nb_section(); i++) {
|
||||
string note = _jed->noteForSection(i);
|
||||
std::string note = _jed->noteForSection(i);
|
||||
if (note == "TAG DATA") {
|
||||
eraseMode |= FLASH_ERASE_UFM;
|
||||
ufm_data = _jed->data_for_section(i);
|
||||
|
|
@ -1536,7 +1535,7 @@ bool Lattice::pollBusyFlag(bool verbose)
|
|||
if (verbose)
|
||||
printf("pollBusyFlag :%02x\n", rx);
|
||||
if (timeout == 100000000){
|
||||
cerr << "timeout" << endl;
|
||||
std::cerr << "timeout" << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
timeout++;
|
||||
|
|
@ -1586,7 +1585,7 @@ bool Lattice::flashErase(uint32_t mask)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Lattice::flashProg(uint32_t start_addr, const string &name, vector<string> data)
|
||||
bool Lattice::flashProg(uint32_t start_addr, const std::string &name, std::vector<std::string> data)
|
||||
{
|
||||
(void)start_addr;
|
||||
ProgressBar progress("Writing " + name, data.size(), 50, _quiet);
|
||||
|
|
@ -2225,7 +2224,7 @@ bool Lattice::program_fea_MachXO3D()
|
|||
bool Lattice::program_intFlash_MachXO3D(JedParser& _jed)
|
||||
{
|
||||
uint32_t erase_op = 0, prog_op = 0;
|
||||
vector<string> data;
|
||||
std::vector<std::string> data;
|
||||
int offset, fuse_count;
|
||||
|
||||
/* bypass */
|
||||
|
|
@ -2251,7 +2250,7 @@ bool Lattice::program_intFlash_MachXO3D(JedParser& _jed)
|
|||
/* if no data, nothing to do */
|
||||
continue;
|
||||
}
|
||||
string note = _jed.noteForSection(i);
|
||||
std::string note = _jed.noteForSection(i);
|
||||
offset = _jed.offset_for_section(i) / 128;
|
||||
|
||||
erase_op = 0;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
#include "latticeBitParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
LatticeBitParser::LatticeBitParser(const string &filename, bool machxo2, bool ecp3,
|
||||
LatticeBitParser::LatticeBitParser(const std::string &filename, bool machxo2, bool ecp3,
|
||||
bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||
_endHeader(0), _is_machXO2(machxo2), _is_ecp3(ecp3)
|
||||
|
|
@ -57,14 +56,14 @@ int LatticeBitParser::parseHeader()
|
|||
|
||||
|
||||
_endHeader = _raw_data.find(0xff, currPos);
|
||||
if (_endHeader == string::npos) {
|
||||
if (_endHeader == std::string::npos) {
|
||||
printError("Error: preamble not found\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* .bit for MACHXO3D seems to have more 0xff before preamble key */
|
||||
size_t pos = _raw_data.find(0xb3, _endHeader);
|
||||
if (pos == string::npos) {
|
||||
if (pos == std::string::npos) {
|
||||
printError("Preamble key not found");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -76,13 +75,13 @@ int LatticeBitParser::parseHeader()
|
|||
_endHeader = pos - 4; // align to 3 Dummy Bytes + preamble (ie. Header start offset).
|
||||
|
||||
/* parse header */
|
||||
istringstream lineStream(_raw_data.substr(currPos, _endHeader - currPos));
|
||||
string buff;
|
||||
std::istringstream lineStream(_raw_data.substr(currPos, _endHeader - currPos));
|
||||
std::string buff;
|
||||
while (std::getline(lineStream, buff, '\0')) {
|
||||
pos = buff.find_first_of(':', 0);
|
||||
if (pos != string::npos) {
|
||||
string key(buff.substr(0, pos));
|
||||
string val(buff.substr(pos+1, buff.size()));
|
||||
if (pos != std::string::npos) {
|
||||
std::string key(buff.substr(0, pos));
|
||||
std::string val(buff.substr(pos+1, buff.size()));
|
||||
int startPos = val.find_first_not_of(" ");
|
||||
int endPos = val.find_last_not_of(" ")+1;
|
||||
_hdr[key] = val.substr(startPos, endPos).c_str();
|
||||
|
|
@ -117,17 +116,17 @@ int LatticeBitParser::parse()
|
|||
printError("encrypted bitstream not supported for machXO2");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
string part = getHeaderVal("Part");
|
||||
string subpart = part.substr(0, part.find_last_of("-"));
|
||||
std::string part = getHeaderVal("Part");
|
||||
std::string subpart = part.substr(0, part.find_last_of("-"));
|
||||
for (auto && fpga : fpga_list) {
|
||||
if (fpga.second.manufacturer != "lattice")
|
||||
continue;
|
||||
string model = fpga.second.model;
|
||||
std::string model = fpga.second.model;
|
||||
if (subpart.compare(0, model.size(), model) == 0) {
|
||||
char __buf[10];
|
||||
int __buf_valid_bytes;
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%08x", fpga.first);
|
||||
_hdr["idcode"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"].resize(8, ' ');
|
||||
}
|
||||
}
|
||||
|
|
@ -203,7 +202,7 @@ bool LatticeBitParser::parseCfgData()
|
|||
(((uint32_t)reverseByte(ptr[4])) << 8) |
|
||||
(((uint32_t)reverseByte(ptr[3])) << 0);
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%08x", idcode);
|
||||
_hdr["idcode"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"].resize(8, ' ');
|
||||
pos += 7;
|
||||
if (!_is_machXO2)
|
||||
|
|
@ -216,7 +215,7 @@ bool LatticeBitParser::parseCfgData()
|
|||
(((uint32_t)ptr[5]) << 8) |
|
||||
(((uint32_t)ptr[6]) << 0);
|
||||
__buf_valid_bytes = snprintf(__buf, 9, "%08x", idcode);
|
||||
_hdr["idcode"] = string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"] = std::string(__buf, __buf_valid_bytes);
|
||||
_hdr["idcode"].resize(8, ' ');
|
||||
pos += 7;
|
||||
if (!_is_machXO2)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include "display.hpp"
|
||||
#include "libusb_ll.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
libusb_ll::libusb_ll(int vid, int pid, int8_t _verbose):
|
||||
_usb_ctx(nullptr), _verbose(_verbose >= 2)
|
||||
|
|
|
|||
163
src/main.cpp
163
src/main.cpp
|
|
@ -69,23 +69,22 @@
|
|||
|
||||
#define DEFAULT_FREQ 6000000
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct arguments {
|
||||
int8_t verbose;
|
||||
bool force_terminal_mode;
|
||||
bool reset, detect, detect_flash, verify, scan_usb;
|
||||
unsigned int offset;
|
||||
string bit_file;
|
||||
string secondary_bit_file;
|
||||
string device;
|
||||
string cable;
|
||||
string ftdi_serial;
|
||||
std::string bit_file;
|
||||
std::string secondary_bit_file;
|
||||
std::string device;
|
||||
std::string cable;
|
||||
std::string ftdi_serial;
|
||||
int ftdi_channel;
|
||||
int status_pin;
|
||||
uint32_t freq;
|
||||
bool invert_read_edge;
|
||||
string board;
|
||||
std::string board;
|
||||
bool pin_config;
|
||||
bool list_cables;
|
||||
bool list_boards;
|
||||
|
|
@ -94,13 +93,13 @@ struct arguments {
|
|||
bool is_list_command;
|
||||
bool spi;
|
||||
bool dfu;
|
||||
string file_type;
|
||||
string fpga_part;
|
||||
string bridge_path;
|
||||
string probe_firmware;
|
||||
std::string file_type;
|
||||
std::string fpga_part;
|
||||
std::string bridge_path;
|
||||
std::string probe_firmware;
|
||||
int index_chain;
|
||||
unsigned int file_size;
|
||||
string target_flash;
|
||||
std::string target_flash;
|
||||
bool external_flash;
|
||||
bool spi_flash_type;
|
||||
int16_t altsetting;
|
||||
|
|
@ -109,26 +108,26 @@ struct arguments {
|
|||
int16_t cable_index;
|
||||
uint8_t bus_addr;
|
||||
uint8_t device_addr;
|
||||
string ip_adr;
|
||||
std::string ip_adr;
|
||||
uint32_t protect_flash;
|
||||
bool unprotect_flash;
|
||||
bool enable_quad;
|
||||
bool disable_quad;
|
||||
bool bulk_erase_flash;
|
||||
string flash_sector;
|
||||
std::string flash_sector;
|
||||
bool skip_load_bridge;
|
||||
bool skip_reset;
|
||||
/* xvc server */
|
||||
bool xvc;
|
||||
int port;
|
||||
string interface;
|
||||
string mcufw;
|
||||
std::string interface;
|
||||
std::string mcufw;
|
||||
bool conmcu;
|
||||
std::map<uint32_t, misc_device> user_misc_devs;
|
||||
bool read_dna;
|
||||
bool read_xadc;
|
||||
string read_register;
|
||||
string user_flash;
|
||||
std::string read_register;
|
||||
std::string user_flash;
|
||||
};
|
||||
|
||||
int run_xvc_server(const struct arguments &args, const cable_t &cable,
|
||||
|
|
@ -185,9 +184,9 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (args.prg_type == Device::WR_SRAM)
|
||||
cout << "write to ram" << endl;
|
||||
std::cout << "write to ram" << std::endl;
|
||||
if (args.prg_type == Device::WR_FLASH)
|
||||
cout << "write to flash" << endl;
|
||||
std::cout << "write to flash" << std::endl;
|
||||
|
||||
if (args.board[0] != '-') {
|
||||
if (board_list.find(args.board) != board_list.end()) {
|
||||
|
|
@ -215,7 +214,7 @@ int main(int argc, char **argv)
|
|||
if (args.cable[0] == '-') { // no user selection
|
||||
args.cable = (*t).first; // use board default cable
|
||||
} else {
|
||||
cout << "Board default cable overridden with " << args.cable << endl;
|
||||
std::cout << "Board default cable overridden with " << args.cable << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +341,7 @@ int main(int argc, char **argv)
|
|||
dfu = new DFU(args.bit_file, args.detect, vid, pid, altsetting,
|
||||
args.verbose);
|
||||
} catch (std::exception &e) {
|
||||
printError("DFU init failed with: " + string(e.what()));
|
||||
printError("DFU init failed with: " + std::string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* if verbose or detect: display device */
|
||||
|
|
@ -356,7 +355,7 @@ int main(int argc, char **argv)
|
|||
try {
|
||||
dfu->download();
|
||||
} catch (std::exception &e) {
|
||||
printError("DFU download failed with: " + string(e.what()));
|
||||
printError("DFU download failed with: " + std::string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -394,18 +393,18 @@ int main(int argc, char **argv)
|
|||
args.invert_read_edge, args.probe_firmware,
|
||||
args.user_misc_devs);
|
||||
} catch (std::exception &e) {
|
||||
printError("JTAG init failed with: " + string(e.what()));
|
||||
printError("JTAG init failed with: " + std::string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* chain detection */
|
||||
vector<uint32_t> listDev = jtag->get_devices_list();
|
||||
std::vector<uint32_t> listDev = jtag->get_devices_list();
|
||||
size_t found = listDev.size();
|
||||
int idcode = -1;
|
||||
size_t index = 0;
|
||||
|
||||
if (args.verbose > 0)
|
||||
cout << "found " << std::to_string(found) << " devices" << endl;
|
||||
std::cout << "found " << std::to_string(found) << " devices" << std::endl;
|
||||
|
||||
/* in verbose mode or when detect
|
||||
* display full chain with details
|
||||
|
|
@ -475,7 +474,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* detect svf file and program the device */
|
||||
if (!args.file_type.compare("svf") ||
|
||||
args.bit_file.find(".svf") != string::npos) {
|
||||
args.bit_file.find(".svf") != std::string::npos) {
|
||||
#ifdef ENABLE_SVF_JTAG
|
||||
SVF_jtag *svf = new SVF_jtag(jtag, args.verbose);
|
||||
try {
|
||||
|
|
@ -495,12 +494,12 @@ int main(int argc, char **argv)
|
|||
* mainly used in conjunction with --index-chain
|
||||
*/
|
||||
if (fpga_list.find(idcode) == fpga_list.end()) {
|
||||
cerr << "Error: device " << hex << idcode << " not supported" << endl;
|
||||
std::cerr << "Error: device " << std::hex << idcode << " not supported" << std::endl;
|
||||
delete(jtag);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
string fab = fpga_list[idcode].manufacturer;
|
||||
std::string fab = fpga_list[idcode].manufacturer;
|
||||
|
||||
|
||||
Device *fpga;
|
||||
|
|
@ -578,7 +577,7 @@ int main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
printError("Error: Failed to claim FPGA device: " + string(e.what()));
|
||||
printError("Error: Failed to claim FPGA device: " + std::string(e.what()));
|
||||
delete(jtag);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -590,7 +589,7 @@ int main(int argc, char **argv)
|
|||
try {
|
||||
fpga->program(args.offset, args.unprotect_flash);
|
||||
} catch (std::exception &e) {
|
||||
printError("Error: Failed to program FPGA: " + string(e.what()));
|
||||
printError("Error: Failed to program FPGA: " + std::string(e.what()));
|
||||
delete(fpga);
|
||||
delete(jtag);
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -677,7 +676,7 @@ int run_xvc_server(const struct arguments &args, const cable_t &cable,
|
|||
xvc->close_connection();
|
||||
delete xvc;
|
||||
} catch (std::exception &e) {
|
||||
printError("XVC_server failed with " + string(e.what()));
|
||||
printError("XVC_server failed with " + std::string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printInfo("Xilinx Virtual Cable Stopped! ");
|
||||
|
|
@ -821,7 +820,7 @@ int spi_comm(struct arguments args, const cable_t &cable,
|
|||
try {
|
||||
flash.erase_and_prog(args.offset, bit->getData(), bit->getLength()/8);
|
||||
} catch (std::exception &e) {
|
||||
printError("FAIL: " + string(e.what()));
|
||||
printError("FAIL: " + std::string(e.what()));
|
||||
}
|
||||
|
||||
if (args.verify)
|
||||
|
|
@ -857,7 +856,7 @@ int spi_comm(struct arguments args, const cable_t &cable,
|
|||
|
||||
// parse double from string in engineering notation
|
||||
// can deal with postfixes k and m, add more when required
|
||||
static int parse_eng(string arg, double *dst) {
|
||||
static int parse_eng(std::string arg, double *dst) {
|
||||
try {
|
||||
size_t end;
|
||||
double base = stod(arg, &end);
|
||||
|
|
@ -879,7 +878,7 @@ static int parse_eng(string arg, double *dst) {
|
|||
return EINVAL;
|
||||
}
|
||||
} catch (...) {
|
||||
cerr << "error : speed: invalid format" << endl;
|
||||
std::cerr << "error : speed: invalid format" << std::endl;
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -888,8 +887,8 @@ static int parse_eng(string arg, double *dst) {
|
|||
int parse_opt(int argc, char **argv, struct arguments *args,
|
||||
jtag_pins_conf_t *pins_config)
|
||||
{
|
||||
string freqo;
|
||||
vector<string> pins, bus_dev_num;
|
||||
std::string freqo;
|
||||
std::vector<std::string> pins, bus_dev_num;
|
||||
bool verbose = false, quiet = false;
|
||||
int8_t verbose_level = -2;
|
||||
try {
|
||||
|
|
@ -909,11 +908,11 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
" UltraScale boards)",
|
||||
cxxopts::value<std::string>(args->secondary_bit_file))
|
||||
("b,board", "board name, may be used instead of cable",
|
||||
cxxopts::value<string>(args->board))
|
||||
cxxopts::value<std::string>(args->board))
|
||||
("B,bridge", "disable spiOverJtag model detection by providing "
|
||||
"bitstream(intel/xilinx)",
|
||||
cxxopts::value<string>(args->bridge_path))
|
||||
("c,cable", "jtag interface", cxxopts::value<string>(args->cable))
|
||||
cxxopts::value<std::string>(args->bridge_path))
|
||||
("c,cable", "jtag interface", cxxopts::value<std::string>(args->cable))
|
||||
("status-pin",
|
||||
"JTAG mode / FTDI: GPIO pin number to use as a status indicator (active low)",
|
||||
cxxopts::value<int>(args->status_pin))
|
||||
|
|
@ -926,15 +925,15 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
cxxopts::value<int16_t>(args->cable_index))
|
||||
("busdev-num",
|
||||
"select a probe by it bus and device number (bus_num:device_addr)",
|
||||
cxxopts::value<vector<string>>(bus_dev_num))
|
||||
cxxopts::value<std::vector<std::string>>(bus_dev_num))
|
||||
("ftdi-serial", "FTDI chip serial number",
|
||||
cxxopts::value<string>(args->ftdi_serial))
|
||||
cxxopts::value<std::string>(args->ftdi_serial))
|
||||
("ftdi-channel",
|
||||
"FTDI chip channel number (channels 0-3 map to A-D)",
|
||||
cxxopts::value<int>(args->ftdi_channel))
|
||||
#if defined(USE_DEVICE_ARG)
|
||||
("d,device", "device to use (/dev/ttyUSBx)",
|
||||
cxxopts::value<string>(args->device))
|
||||
cxxopts::value<std::string>(args->device))
|
||||
#endif
|
||||
("detect", "detect FPGA, add -f to show connected flash",
|
||||
cxxopts::value<bool>(args->detect))
|
||||
|
|
@ -949,7 +948,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
("target-flash",
|
||||
"for boards with multiple flash chips (some Xilinx UltraScale"
|
||||
" boards), select the target flash: primary (default), secondary or both",
|
||||
cxxopts::value<string>(args->target_flash))
|
||||
cxxopts::value<std::string>(args->target_flash))
|
||||
("external-flash",
|
||||
"select ext flash for device with internal and external storage",
|
||||
cxxopts::value<bool>(args->external_flash))
|
||||
|
|
@ -958,20 +957,20 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
cxxopts::value<unsigned int>(args->file_size))
|
||||
("file-type",
|
||||
"provides file type instead of let's deduced by using extension",
|
||||
cxxopts::value<string>(args->file_type))
|
||||
cxxopts::value<std::string>(args->file_type))
|
||||
("flash-sector", "flash sector (Lattice and Altera MAX10 parts only)",
|
||||
cxxopts::value<string>(args->flash_sector))
|
||||
cxxopts::value<std::string>(args->flash_sector))
|
||||
("fpga-part", "fpga model flavor + package",
|
||||
cxxopts::value<string>(args->fpga_part))
|
||||
("freq", "jtag frequency (Hz)", cxxopts::value<string>(freqo))
|
||||
cxxopts::value<std::string>(args->fpga_part))
|
||||
("freq", "jtag frequency (Hz)", cxxopts::value<std::string>(freqo))
|
||||
("f,write-flash",
|
||||
"write bitstream in flash (default: false)")
|
||||
("index-chain", "device index in JTAG-chain",
|
||||
cxxopts::value<int>(args->index_chain))
|
||||
("misc-device", "add JTAG non-FPGA devices <idcode,irlen,name>",
|
||||
cxxopts::value<vector<string>>())
|
||||
cxxopts::value<std::vector<std::string>>())
|
||||
("ip", "IP address (XVC and remote bitbang client)",
|
||||
cxxopts::value<string>(args->ip_adr))
|
||||
cxxopts::value<std::string>(args->ip_adr))
|
||||
("list-boards", "list all supported boards",
|
||||
cxxopts::value<bool>(args->list_boards))
|
||||
("list-cables", "list all supported cables",
|
||||
|
|
@ -983,9 +982,9 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
("o,offset", "Start address (in bytes) for read/write into non volatile memory (default: 0)",
|
||||
cxxopts::value<unsigned int>(args->offset))
|
||||
("pins", "pin config TDI:TDO:TCK:TMS or MOSI:MISO:SCK:CS[:HOLDN:WPN]",
|
||||
cxxopts::value<vector<string>>(pins))
|
||||
cxxopts::value<std::vector<std::string>>(pins))
|
||||
("probe-firmware", "firmware for JTAG probe (usbBlasterII)",
|
||||
cxxopts::value<string>(args->probe_firmware))
|
||||
cxxopts::value<std::string>(args->probe_firmware))
|
||||
("protect-flash", "protect SPI flash area",
|
||||
cxxopts::value<uint32_t>(args->protect_flash))
|
||||
("quiet", "Produce quiet output (no progress bar)",
|
||||
|
|
@ -1026,16 +1025,16 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
("X,read-xadc", "Read XADC (Xilinx FPGA only)",
|
||||
cxxopts::value<bool>(args->read_xadc))
|
||||
("read-register", "Read Status Register(Xilinx FPGA only)",
|
||||
cxxopts::value<string>(args->read_register))
|
||||
cxxopts::value<std::string>(args->read_register))
|
||||
("user-flash", "User flash file (Gowin LittleBee FPGA only)",
|
||||
cxxopts::value<string>(args->user_flash))
|
||||
cxxopts::value<std::string>(args->user_flash))
|
||||
("V,Version", "Print program version");
|
||||
|
||||
options.parse_positional({"bitstream"});
|
||||
auto result = options.parse(argc, argv);
|
||||
|
||||
if (result.count("help")) {
|
||||
cout << options.help() << endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1058,7 +1057,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
}
|
||||
|
||||
if (result.count("Version")) {
|
||||
cout << "openFPGALoader " << VERSION << endl;
|
||||
std::cout << "openFPGALoader " << VERSION << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1202,7 +1201,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
!args->detect
|
||||
) {
|
||||
printError("Error: secondary bitfile not specified");
|
||||
cout << options.help() << endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1235,7 +1234,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
!args->read_xadc &&
|
||||
args->read_register.empty()) {
|
||||
printError("Error: bitfile not specified");
|
||||
cout << options.help() << endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1247,7 +1246,7 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
args->detect_flash = true;
|
||||
}
|
||||
} catch (const cxxopts::OptionException& e) {
|
||||
printError("Error parsing options: " + string(e.what()));
|
||||
printError("Error parsing options: " + std::string(e.what()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1258,27 +1257,27 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
void displaySupported(const struct arguments &args)
|
||||
{
|
||||
if (args.list_cables == true) {
|
||||
stringstream t;
|
||||
t << setw(25) << left << "cable name" << "vid:pid";
|
||||
std::stringstream t;
|
||||
t << std::setw(25) << std::left << "cable name" << "vid:pid";
|
||||
printSuccess(t.str());
|
||||
for (auto b = cable_list.begin(); b != cable_list.end(); b++) {
|
||||
cable_t c = (*b).second;
|
||||
stringstream ss;
|
||||
ss << setw(25) << left << (*b).first;
|
||||
ss << "0x" << hex << right << setw(4) << setfill('0') << c.vid
|
||||
<< ":" << setw(4) << c.pid;
|
||||
std::stringstream ss;
|
||||
ss << std::setw(25) << std::left << (*b).first;
|
||||
ss << "0x" << std::hex << std::right << std::setw(4) << std::setfill('0') << c.vid
|
||||
<< ":" << std::setw(4) << c.pid;
|
||||
printInfo(ss.str());
|
||||
}
|
||||
cout << endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
if (args.list_boards) {
|
||||
stringstream t;
|
||||
t << setw(27) << left << "board name" << setw(19) << "cable_name";
|
||||
t << setw(25) << "fpga_part";
|
||||
std::stringstream t;
|
||||
t << std::setw(27) << std::left << "board name" << std::setw(19) << "cable_name";
|
||||
t << std::setw(25) << "fpga_part";
|
||||
printSuccess(t.str());
|
||||
for (auto b = board_list.begin(); b != board_list.end(); b++) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
target_board_t c = (*b).second;
|
||||
std::string cable_name = c.cable_name;
|
||||
std::string fpga_part = c.fpga_part;
|
||||
|
|
@ -1286,28 +1285,28 @@ void displaySupported(const struct arguments &args)
|
|||
cable_name = "Undefined";
|
||||
if (fpga_part.size() == 0)
|
||||
fpga_part = "Undefined";
|
||||
ss << setw(27) << left << (*b).first << setw(19) << cable_name;
|
||||
ss << setw(25)<< fpga_part;
|
||||
ss << std::setw(27) << std::left << (*b).first << std::setw(19) << cable_name;
|
||||
ss << std::setw(25)<< fpga_part;
|
||||
printInfo(ss.str());
|
||||
}
|
||||
cout << endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
if (args.list_fpga) {
|
||||
stringstream t;
|
||||
t << setw(12) << left << "IDCode" << setw(14) << "manufacturer";
|
||||
t << setw(16) << "family" << setw(20) << "model";
|
||||
std::stringstream t;
|
||||
t << std::setw(12) << std::left << "IDCode" << std::setw(14) << "manufacturer";
|
||||
t << std::setw(16) << "family" << std::setw(20) << "model";
|
||||
printSuccess(t.str());
|
||||
for (auto b = fpga_list.begin(); b != fpga_list.end(); b++) {
|
||||
fpga_model fpga = (*b).second;
|
||||
stringstream ss, idCode;
|
||||
idCode << "0x" << hex << setw(8) << setfill('0') << (*b).first;
|
||||
ss << setw(12) << left << idCode.str();
|
||||
ss << setw(14) << fpga.manufacturer << setw(16) << fpga.family;
|
||||
ss << setw(20) << fpga.model;
|
||||
std::stringstream ss, idCode;
|
||||
idCode << "0x" << std::hex << std::setw(8) << std::setfill('0') << (*b).first;
|
||||
ss << std::setw(12) << std::left << idCode.str();
|
||||
ss << std::setw(14) << fpga.manufacturer << std::setw(16) << fpga.family;
|
||||
ss << std::setw(20) << fpga.model;
|
||||
printInfo(ss.str());
|
||||
}
|
||||
cout << endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_USB_SCAN
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include "display.hpp"
|
||||
#include "mcsParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* line format
|
||||
* :LLAAAATTHH...HHCC
|
||||
|
|
@ -34,7 +33,7 @@ using namespace std;
|
|||
#define TYPE_BASE 7
|
||||
#define DATA_BASE 9
|
||||
|
||||
McsParser::McsParser(const string &filename, bool reverseOrder, bool verbose):
|
||||
McsParser::McsParser(const std::string &filename, bool reverseOrder, bool verbose):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE,
|
||||
verbose),
|
||||
_base_addr(0), _reverseOrder(reverseOrder)
|
||||
|
|
@ -42,8 +41,8 @@ McsParser::McsParser(const string &filename, bool reverseOrder, bool verbose):
|
|||
|
||||
int McsParser::parse()
|
||||
{
|
||||
string str;
|
||||
istringstream lineStream(_raw_data);
|
||||
std::string str;
|
||||
std::istringstream lineStream(_raw_data);
|
||||
|
||||
FlashDataSection *rec = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@
|
|||
#include "display.hpp"
|
||||
#include "rawParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
RawParser::RawParser(const string &filename, bool reverseOrder):
|
||||
RawParser::RawParser(const std::string &filename, bool reverseOrder):
|
||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE,
|
||||
false), _reverseOrder(reverseOrder)
|
||||
{}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define TCK_OFFSET 2
|
||||
#define TMS_OFFSET 1
|
||||
|
|
@ -170,7 +169,7 @@ int RemoteBitbang_client::setClkFreq(uint32_t clkHz)
|
|||
return clkHz;
|
||||
}
|
||||
|
||||
bool RemoteBitbang_client::open_connection(const string &ip_addr)
|
||||
bool RemoteBitbang_client::open_connection(const std::string &ip_addr)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
|
|
|
|||
147
src/svf_jtag.cpp
147
src/svf_jtag.cpp
|
|
@ -18,12 +18,11 @@
|
|||
|
||||
#include "jtag.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void SVF_jtag::split_str(string const &str, vector<string> &vparse)
|
||||
void SVF_jtag::split_str(std::string const &str, std::vector<std::string> &vparse)
|
||||
{
|
||||
string token;
|
||||
istringstream tokenStream(str);
|
||||
std::string token;
|
||||
std::istringstream tokenStream(str);
|
||||
while (getline(tokenStream, token, ' '))
|
||||
vparse.push_back(token);
|
||||
}
|
||||
|
|
@ -37,7 +36,7 @@ void SVF_jtag::clear_XYR(svf_XYR &t)
|
|||
t.smask.clear();
|
||||
}
|
||||
|
||||
static unsigned char *parse_hex(string const &in, size_t byte_length,
|
||||
static unsigned char *parse_hex(std::string const &in, size_t byte_length,
|
||||
bool default_value)
|
||||
{
|
||||
unsigned char *txbuf = new unsigned char[byte_length];
|
||||
|
|
@ -67,13 +66,13 @@ static unsigned char *parse_hex(string const &in, size_t byte_length,
|
|||
* tdo si absent on s'en fout
|
||||
* TODO: ameliorer l'analyse des chaines de caracteres
|
||||
*/
|
||||
void SVF_jtag::parse_XYR(vector<string> const &vstr, svf_XYR &t)
|
||||
void SVF_jtag::parse_XYR(std::vector<std::string> const &vstr, svf_XYR &t)
|
||||
{
|
||||
if (_verbose)
|
||||
cout << endl;
|
||||
std::cout << std::endl;
|
||||
int mode = 0;
|
||||
string s;
|
||||
string full_line;
|
||||
std::string s;
|
||||
std::string full_line;
|
||||
full_line.reserve(1276);
|
||||
int write_data = -1;
|
||||
|
||||
|
|
@ -168,14 +167,14 @@ void SVF_jtag::parse_XYR(vector<string> const &vstr, svf_XYR &t)
|
|||
unsigned char *maskbuf = parse_hex(t.mask, byte_len, t.mask.empty() ? 1 : 0);
|
||||
for (size_t i = 0; i < byte_len; i++) {
|
||||
if ((read_buffer[i] ^ tdobuf[i]) & maskbuf[i]) {
|
||||
cerr << "TDO value ";
|
||||
std::cerr << "TDO value ";
|
||||
for (int j = byte_len - 1; j >= 0; j--) {
|
||||
cerr << uppercase << hex << int(read_buffer[j]);
|
||||
std::cerr << std::uppercase << std::hex << int(read_buffer[j]);
|
||||
}
|
||||
cerr << " isn't the one expected: " << uppercase << t.tdo << endl;
|
||||
std::cerr << " isn't the one expected: " << std::uppercase << t.tdo << std::endl;
|
||||
delete[] tdobuf;
|
||||
delete[] maskbuf;
|
||||
throw exception();
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
delete[] tdobuf;
|
||||
|
|
@ -187,7 +186,7 @@ void SVF_jtag::parse_XYR(vector<string> const &vstr, svf_XYR &t)
|
|||
}
|
||||
|
||||
/* Implementation partielle de la spec */
|
||||
void SVF_jtag::parse_runtest(vector<string> const &vstr)
|
||||
void SVF_jtag::parse_runtest(std::vector<std::string> const &vstr)
|
||||
{
|
||||
unsigned int pos = 1;
|
||||
int nb_iter = 0;
|
||||
|
|
@ -238,105 +237,105 @@ void SVF_jtag::parse_runtest(vector<string> const &vstr)
|
|||
_jtag->set_state(_end_state);
|
||||
}
|
||||
|
||||
void SVF_jtag::handle_instruction(vector<string> const &vstr)
|
||||
void SVF_jtag::handle_instruction(std::vector<std::string> const &vstr)
|
||||
{
|
||||
if (!vstr[0].compare("FREQUENCY")) {
|
||||
_freq_hz = atof(vstr[1].c_str());
|
||||
if (_verbose) {
|
||||
cout << "frequency value " << vstr[1] << " unit " << vstr[2];
|
||||
cout << _freq_hz << endl;
|
||||
std::cout << "frequency value " << vstr[1] << " unit " << vstr[2];
|
||||
std::cout << _freq_hz << std::endl;
|
||||
}
|
||||
_jtag->setClkFreq(_freq_hz);
|
||||
} else if (!vstr[0].compare("TRST")) {
|
||||
if (_verbose) cout << "trst value : " << vstr[1] << endl;
|
||||
if (_verbose) std::cout << "trst value : " << vstr[1] << std::endl;
|
||||
} else if (!vstr[0].compare("ENDDR")) {
|
||||
if (_verbose) cout << "enddr value : " << vstr[1] << endl;
|
||||
if (_verbose) std::cout << "enddr value : " << vstr[1] << std::endl;
|
||||
_enddr = (Jtag::tapState_t)fsm_state[vstr[1]];
|
||||
} else if (!vstr[0].compare("ENDIR")) {
|
||||
if (_verbose) cout << "endir value : " << vstr[1] << endl;
|
||||
if (_verbose) std::cout << "endir value : " << vstr[1] << std::endl;
|
||||
_endir = (Jtag::tapState_t)fsm_state[vstr[1]];
|
||||
} else if (!vstr[0].compare("STATE")) {
|
||||
if (_verbose) cout << "state value : " << vstr[1] << endl;
|
||||
if (_verbose) std::cout << "state value : " << vstr[1] << std::endl;
|
||||
_jtag->set_state((Jtag::tapState_t)fsm_state[vstr[1]]);
|
||||
} else if (!vstr[0].compare("RUNTEST")) {
|
||||
parse_runtest(vstr);
|
||||
} else if (!vstr[0].compare("HIR")) {
|
||||
parse_XYR(vstr, hir);
|
||||
if (hir.len > 0) {
|
||||
cerr << "HIR length supported is only 0 " << endl;
|
||||
std::cerr << "HIR length supported is only 0 " << std::endl;
|
||||
}
|
||||
if (_verbose) {
|
||||
cout << "HIR" << endl;
|
||||
cout << "\tlen : " << hir.len << endl;
|
||||
cout << "\ttdo : " << hir.tdo.size()*4 << endl;
|
||||
cout << "\ttdi : " << hir.tdi.size()*4 << endl;
|
||||
cout << "\tmask : " << hir.mask.size()*4 << endl;
|
||||
cout << "\tsmask : " << hir.smask.size()*4 << endl;
|
||||
std::cout << "HIR" << std::endl;
|
||||
std::cout << "\tlen : " << hir.len << std::endl;
|
||||
std::cout << "\ttdo : " << hir.tdo.size()*4 << std::endl;
|
||||
std::cout << "\ttdi : " << hir.tdi.size()*4 << std::endl;
|
||||
std::cout << "\tmask : " << hir.mask.size()*4 << std::endl;
|
||||
std::cout << "\tsmask : " << hir.smask.size()*4 << std::endl;
|
||||
}
|
||||
} else if (!vstr[0].compare("HDR")) {
|
||||
parse_XYR(vstr, hdr);
|
||||
if (hdr.len > 0) {
|
||||
cerr << "HDR length supported is only 0" << endl;
|
||||
std::cerr << "HDR length supported is only 0" << std::endl;
|
||||
}
|
||||
if (_verbose) {
|
||||
cout << "HDR" << endl;
|
||||
cout << "\tlen : " << hdr.len << endl;
|
||||
cout << "\ttdo : " << hdr.tdo.size()*4 << endl;
|
||||
cout << "\ttdi : " << hdr.tdi.size()*4 << endl;
|
||||
cout << "\tmask : " << hdr.mask.size()*4 << endl;
|
||||
cout << "\tsmask : " << hdr.smask.size()*4 << endl;
|
||||
std::cout << "HDR" << std::endl;
|
||||
std::cout << "\tlen : " << hdr.len << std::endl;
|
||||
std::cout << "\ttdo : " << hdr.tdo.size()*4 << std::endl;
|
||||
std::cout << "\ttdi : " << hdr.tdi.size()*4 << std::endl;
|
||||
std::cout << "\tmask : " << hdr.mask.size()*4 << std::endl;
|
||||
std::cout << "\tsmask : " << hdr.smask.size()*4 << std::endl;
|
||||
}
|
||||
} else if (!vstr[0].compare("SIR")) {
|
||||
parse_XYR(vstr, sir);
|
||||
if (_verbose) {
|
||||
for (auto &&t : vstr)
|
||||
cout << t << " ";
|
||||
cout << endl;
|
||||
cout << "\tlen : " << sir.len << endl;
|
||||
cout << "\ttdo : " << sir.tdo.size()*4 << endl;
|
||||
cout << "\ttdi : " << sir.tdi.size()*4 << endl;
|
||||
cout << "\tmask : " << sir.mask.size()*4 << endl;
|
||||
cout << "\tsmask : " << sir.smask.size()*4 << endl;
|
||||
std::cout << t << " ";
|
||||
std::cout << std::endl;
|
||||
std::cout << "\tlen : " << sir.len << std::endl;
|
||||
std::cout << "\ttdo : " << sir.tdo.size()*4 << std::endl;
|
||||
std::cout << "\ttdi : " << sir.tdi.size()*4 << std::endl;
|
||||
std::cout << "\tmask : " << sir.mask.size()*4 << std::endl;
|
||||
std::cout << "\tsmask : " << sir.smask.size()*4 << std::endl;
|
||||
}
|
||||
} else if (!vstr[0].compare("SDR")) {
|
||||
parse_XYR(vstr, sdr);
|
||||
if (_verbose) {
|
||||
cout << "SDR" << endl;
|
||||
cout << "\tlen : " << sdr.len << endl;
|
||||
cout << "\ttdo : " << sdr.tdo.size()*4 << endl;
|
||||
cout << "\ttdi : " << sdr.tdi.size()*4 << endl;
|
||||
cout << "\tmask : " << sdr.mask.size()*4 << endl;
|
||||
cout << "\tsmask : " << sdr.smask.size()*4 << endl;
|
||||
std::cout << "SDR" << std::endl;
|
||||
std::cout << "\tlen : " << sdr.len << std::endl;
|
||||
std::cout << "\ttdo : " << sdr.tdo.size()*4 << std::endl;
|
||||
std::cout << "\ttdi : " << sdr.tdi.size()*4 << std::endl;
|
||||
std::cout << "\tmask : " << sdr.mask.size()*4 << std::endl;
|
||||
std::cout << "\tsmask : " << sdr.smask.size()*4 << std::endl;
|
||||
}
|
||||
} else if (!vstr[0].compare("TDR")) {
|
||||
parse_XYR(vstr, tdr);
|
||||
if (tdr.len > 0) {
|
||||
cerr << "TDR length supported is only 0" << endl;
|
||||
std::cerr << "TDR length supported is only 0" << std::endl;
|
||||
}
|
||||
if (_verbose) {
|
||||
cout << "TDR" << endl;
|
||||
cout << "\tlen : " << tdr.len << endl;
|
||||
cout << "\ttdo : " << tdr.tdo.size() * 4 << endl;
|
||||
cout << "\ttdi : " << tdr.tdi.size() * 4 << endl;
|
||||
cout << "\tmask : " << tdr.mask.size() * 4 << endl;
|
||||
cout << "\tsmask : " << tdr.smask.size() * 4 << endl;
|
||||
std::cout << "TDR" << std::endl;
|
||||
std::cout << "\tlen : " << tdr.len << std::endl;
|
||||
std::cout << "\ttdo : " << tdr.tdo.size() * 4 << std::endl;
|
||||
std::cout << "\ttdi : " << tdr.tdi.size() * 4 << std::endl;
|
||||
std::cout << "\tmask : " << tdr.mask.size() * 4 << std::endl;
|
||||
std::cout << "\tsmask : " << tdr.smask.size() * 4 << std::endl;
|
||||
}
|
||||
} else if (!vstr[0].compare("TIR")) {
|
||||
parse_XYR(vstr, tir);
|
||||
if (tir.len > 0) {
|
||||
cerr << "TIR length supported is only 0" << endl;
|
||||
std::cerr << "TIR length supported is only 0" << std::endl;
|
||||
}
|
||||
if (_verbose) {
|
||||
cout << "TIR" << endl;
|
||||
cout << "\tlen : " << tir.len << endl;
|
||||
cout << "\ttdo : " << tir.tdo.size() * 4 << endl;
|
||||
cout << "\ttdi : " << tir.tdi.size() * 4 << endl;
|
||||
cout << "\tmask : " << tir.mask.size() * 4 << endl;
|
||||
cout << "\tsmask : " << tir.smask.size() * 4 << endl;
|
||||
std::cout << "TIR" << std::endl;
|
||||
std::cout << "\tlen : " << tir.len << std::endl;
|
||||
std::cout << "\ttdo : " << tir.tdo.size() * 4 << std::endl;
|
||||
std::cout << "\ttdi : " << tir.tdi.size() * 4 << std::endl;
|
||||
std::cout << "\tmask : " << tir.mask.size() * 4 << std::endl;
|
||||
std::cout << "\tsmask : " << tir.smask.size() * 4 << std::endl;
|
||||
}
|
||||
} else {
|
||||
cout << "error: unhandled instruction " << vstr[0] << endl;
|
||||
throw exception();
|
||||
std::cout << "error: unhandled instruction " << vstr[0] << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -358,16 +357,16 @@ bool is_space(char x) {
|
|||
* concat continuous lines
|
||||
* and pass instruction to handle_instruction
|
||||
*/
|
||||
void SVF_jtag::parse(string filename)
|
||||
void SVF_jtag::parse(std::string filename)
|
||||
{
|
||||
string str;
|
||||
vector<string> vstr;
|
||||
std::string str;
|
||||
std::vector<std::string> vstr;
|
||||
bool is_complete;
|
||||
ifstream fs;
|
||||
std::ifstream fs;
|
||||
|
||||
fs.open(filename);
|
||||
if (!fs.is_open()) {
|
||||
cerr << "Error opening svf file " << filename << endl;
|
||||
std::cerr << "Error opening svf file " << filename << std::endl;
|
||||
return;
|
||||
}
|
||||
unsigned int lineno = 0;
|
||||
|
|
@ -391,8 +390,8 @@ void SVF_jtag::parse(string filename)
|
|||
if (vstr[0].compare("HDR") && vstr[0].compare("HIR")
|
||||
&& vstr[0].compare("SDR") && vstr[0].compare("SIR")) {
|
||||
for (auto &&word : vstr)
|
||||
cout << word << " ";
|
||||
cout << endl;
|
||||
std::cout << word << " ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
handle_instruction(vstr);
|
||||
|
|
@ -400,11 +399,11 @@ void SVF_jtag::parse(string filename)
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (exception &e)
|
||||
catch (std::exception &e)
|
||||
{
|
||||
cerr << "Cannot proceed because of error(s) at line " << lineno << endl;
|
||||
std::cerr << "Cannot proceed because of error(s) at line " << lineno << std::endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
cout << "end of SVF file" << endl;
|
||||
std::cout << "end of SVF file" << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,31 +11,30 @@
|
|||
#include <map>
|
||||
|
||||
#include "jtag.hpp"
|
||||
using namespace std;
|
||||
|
||||
class SVF_jtag {
|
||||
public:
|
||||
SVF_jtag(Jtag *jtag, bool verbose);
|
||||
~SVF_jtag();
|
||||
void parse(string filename);
|
||||
void parse(std::string filename);
|
||||
void setVerbose(bool verbose) {_verbose = verbose;}
|
||||
|
||||
private:
|
||||
typedef struct {
|
||||
uint32_t len;
|
||||
string tdo;
|
||||
string tdi;
|
||||
string mask;
|
||||
string smask;
|
||||
std::string tdo;
|
||||
std::string tdi;
|
||||
std::string mask;
|
||||
std::string smask;
|
||||
} svf_XYR;
|
||||
|
||||
void split_str(string const &str, vector<string> &vparse);
|
||||
void split_str(const std::string &str, std::vector<std::string> &vparse);
|
||||
void clear_XYR(svf_XYR &t);
|
||||
void parse_XYR(vector<string> const &vstr/*, svf_stat &svfs*/, svf_XYR &t);
|
||||
void parse_runtest(vector<string> const &vstr);
|
||||
void handle_instruction(vector<string> const &vstr);
|
||||
void parse_XYR(const std::vector<std::string> &vstr/*, svf_stat &svfs*/, svf_XYR &t);
|
||||
void parse_runtest(const std::vector<std::string> &vstr);
|
||||
void handle_instruction(const std::vector<std::string> &vstr);
|
||||
|
||||
map <string, uint8_t> fsm_state = {
|
||||
std::map<std::string, uint8_t> fsm_state = {
|
||||
{"RESET", 0},
|
||||
{"IDLE", 1},
|
||||
{"DRSELECT", 2},
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "fx2_ll.hpp"
|
||||
#include "usbBlaster.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DO_READ (1 << 6)
|
||||
#define DO_WRITE (0 << 6)
|
||||
|
|
@ -358,10 +357,8 @@ UsbBlasterI::UsbBlasterI()
|
|||
{
|
||||
int ret;
|
||||
_ftdi = ftdi_new();
|
||||
if (_ftdi == NULL) {
|
||||
cout << "open_device: failed to initialize ftdi" << endl;
|
||||
throw std::exception();
|
||||
}
|
||||
if (_ftdi == NULL)
|
||||
throw std::runtime_error("open_device: failed to initialize ftdi");
|
||||
|
||||
ret = ftdi_usb_open(_ftdi, 0x09fb, 0x6001);
|
||||
if (ret < 0) {
|
||||
|
|
@ -446,7 +443,7 @@ int UsbBlasterI::write(uint8_t *wr_buf, int wr_len,
|
|||
* USB Blash II specific implementation
|
||||
*/
|
||||
|
||||
UsbBlasterII::UsbBlasterII(const string &firmware_path)
|
||||
UsbBlasterII::UsbBlasterII(const std::string &firmware_path)
|
||||
{
|
||||
std::string fpath;
|
||||
uint8_t buf[5];
|
||||
|
|
|
|||
|
|
@ -14,9 +14,8 @@
|
|||
#include "jedParser.hpp"
|
||||
#include "xilinxMapParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
XilinxMapParser::XilinxMapParser(const string &filename,
|
||||
XilinxMapParser::XilinxMapParser(const std::string &filename,
|
||||
uint16_t num_row, uint16_t num_col,
|
||||
JedParser *jed, const uint32_t usercode,
|
||||
bool verbose): ConfigBitstreamParser(filename,
|
||||
|
|
@ -61,7 +60,7 @@ int XilinxMapParser::parse()
|
|||
} else {
|
||||
empty = false; // current line is not fully empty
|
||||
int len = end_pos - prev_pos; // section len
|
||||
string cnt = line.substr(prev_pos, len); // line substring
|
||||
std::string cnt = line.substr(prev_pos, len); // line substring
|
||||
if (cnt[0] <= '9' && cnt[0] >= '0') { // numeric value (index)
|
||||
map_val = std::stoi(cnt, nullptr, 10);
|
||||
} else { // information (done, spare, user, ...)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
XVC_client::XVC_client(const std::string &ip_addr, int port,
|
||||
uint32_t clkHz, int8_t verbose):
|
||||
|
|
@ -41,7 +40,7 @@ XVC_client::XVC_client(const std::string &ip_addr, int port,
|
|||
throw std::runtime_error("can't read info");
|
||||
|
||||
std::regex r("[_:]");
|
||||
string rep((const char *)buffer);
|
||||
std::string rep((const char *)buffer);
|
||||
|
||||
std::sregex_token_iterator start{ rep.begin(), rep.end(), r, -1 }, end;
|
||||
std::vector<std::string> toto(start, end);
|
||||
|
|
@ -223,7 +222,7 @@ int XVC_client::setClkFreq(uint32_t clkHz)
|
|||
return _clkHZ;
|
||||
}
|
||||
|
||||
bool XVC_client::open_connection(const string &ip_addr)
|
||||
bool XVC_client::open_connection(const std::string &ip_addr)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
|
|
@ -262,12 +261,12 @@ int sendall(int sock, const void* raw, size_t cnt, int flags)
|
|||
return cnt; // success
|
||||
}
|
||||
|
||||
ssize_t XVC_client::xfer_pkt(const string &instr,
|
||||
ssize_t XVC_client::xfer_pkt(const std::string &instr,
|
||||
const uint8_t *tx, uint32_t tx_size,
|
||||
uint8_t *rx, uint32_t rx_size)
|
||||
{
|
||||
ssize_t len = tx_size;
|
||||
vector<uint8_t> buffer(instr.size() + ((tx) ? tx_size : 0));
|
||||
std::vector<uint8_t> buffer(instr.size() + ((tx) ? tx_size : 0));
|
||||
memcpy(buffer.data(), instr.c_str(), instr.size());
|
||||
if (tx)
|
||||
memcpy(buffer.data() + instr.size(), tx, tx_size);
|
||||
|
|
|
|||
|
|
@ -20,13 +20,12 @@
|
|||
#include "cable.hpp"
|
||||
#include "display.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
XVC_server::XVC_server(int port, const cable_t & cable,
|
||||
const jtag_pins_conf_t * pin_conf, string dev,
|
||||
const string & serial, uint32_t clkHZ, int8_t verbose,
|
||||
const string & ip_adr, const bool invert_read_edge,
|
||||
const string & firmware_path):_verbose(verbose > 1),
|
||||
const jtag_pins_conf_t * pin_conf, std::string dev,
|
||||
const std::string & serial, uint32_t clkHZ, int8_t verbose,
|
||||
const std::string & ip_adr, const bool invert_read_edge,
|
||||
const std::string & firmware_path):_verbose(verbose > 1),
|
||||
_jtag(NULL), _port(port), _sock(-1),
|
||||
_is_stopped(false), _must_stop(false),
|
||||
_buffer_size(2048), _state(Jtag::RUN_TEST_IDLE)
|
||||
|
|
@ -282,7 +281,7 @@ int XVC_server::handle_data(int fd)
|
|||
if (_verbose) {
|
||||
printInfo(std::to_string((int)time(NULL)) +
|
||||
" : Received command: 'getinfo'");
|
||||
printInfo("\t Replied with " + string(xvcInfo));
|
||||
printInfo("\t Replied with " + std::string(xvcInfo));
|
||||
}
|
||||
break;
|
||||
/* settck */
|
||||
|
|
@ -329,7 +328,7 @@ int XVC_server::handle_data(int fd)
|
|||
" : Received command: 'shift'");
|
||||
}
|
||||
} else {
|
||||
printError("invalid cmd '" + string(cmd) + "'");
|
||||
printError("invalid cmd '" + std::string(cmd) + "'");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,12 @@
|
|||
|
||||
#include "jtag.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class XVC_server {
|
||||
public:
|
||||
XVC_server(int port, const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||
string dev, const string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const string &ip_adr,
|
||||
const bool invert_read_edge, const string &firmware_path);
|
||||
std::string dev, const std::string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const std::string &ip_adr,
|
||||
const bool invert_read_edge, const std::string &firmware_path);
|
||||
~XVC_server();
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue