src/xx: cppcheck
This commit is contained in:
parent
3ca60dd14d
commit
0a9e8a7e4b
|
|
@ -107,11 +107,11 @@ int AnlogicBitParser::parse()
|
||||||
|
|
||||||
_bit_data.clear();
|
_bit_data.clear();
|
||||||
for (auto it = blocks.begin(); it != blocks.end(); it++) {
|
for (auto it = blocks.begin(); it != blocks.end(); it++) {
|
||||||
for (size_t pos = 0; pos < it->size(); pos++) {
|
for (size_t xpos = 0; xpos < it->size(); xpos++) {
|
||||||
if (_reverseOrder == true)
|
if (_reverseOrder == true)
|
||||||
_bit_data += reverseByte(((*it)[pos]));
|
_bit_data += reverseByte(((*it)[xpos]));
|
||||||
else
|
else
|
||||||
_bit_data += ((*it)[pos]);
|
_bit_data += ((*it)[xpos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bit_length = _bit_data.size() * 8;
|
_bit_length = _bit_data.size() * 8;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ int BitParser::parseHeader()
|
||||||
int pos_data = 0;
|
int pos_data = 0;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
short length;
|
short length;
|
||||||
string tmp(64, ' ');
|
string tmp;
|
||||||
int pos, prev_pos;
|
int pos, prev_pos;
|
||||||
|
|
||||||
/* Field 1 : misc header */
|
/* Field 1 : misc header */
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ using namespace std;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CH552_jtag::CH552_jtag(const cable_t &cable,
|
CH552_jtag::CH552_jtag(const cable_t &cable,
|
||||||
string dev, const string &serial, uint32_t clkHZ, uint8_t verbose):
|
const string &dev, const string &serial, uint32_t clkHZ,
|
||||||
|
uint8_t verbose):
|
||||||
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _to_read(0)
|
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _to_read(0)
|
||||||
{
|
{
|
||||||
init_internal(cable.config);
|
init_internal(cable.config);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
class CH552_jtag : public JtagInterface, private FTDIpp_MPSSE {
|
class CH552_jtag : public JtagInterface, private FTDIpp_MPSSE {
|
||||||
public:
|
public:
|
||||||
CH552_jtag(const cable_t &cable, std::string dev,
|
CH552_jtag(const cable_t &cable, const std::string &dev,
|
||||||
const std::string &serial, uint32_t clkHZ, uint8_t verbose = false);
|
const std::string &serial, uint32_t clkHZ, uint8_t verbose = false);
|
||||||
virtual ~CH552_jtag();
|
virtual ~CH552_jtag();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#define KCYN "\x1B[36m"
|
#define KCYN "\x1B[36m"
|
||||||
#define KWHT "\x1B[37m"
|
#define KWHT "\x1B[37m"
|
||||||
|
|
||||||
void printError(std::string err, bool eol)
|
void printError(const std::string &err, bool eol)
|
||||||
{
|
{
|
||||||
if (isatty(STDERR_FILENO))
|
if (isatty(STDERR_FILENO))
|
||||||
std::cerr << KRED << err << "\e[0m";
|
std::cerr << KRED << err << "\e[0m";
|
||||||
|
|
@ -31,7 +31,7 @@ void printError(std::string err, bool eol)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printWarn(std::string warn, bool eol)
|
void printWarn(const std::string &warn, bool eol)
|
||||||
{
|
{
|
||||||
if (isatty(STDOUT_FILENO))
|
if (isatty(STDOUT_FILENO))
|
||||||
std::cout << KYEL << warn << "\e[0m" << std::flush;
|
std::cout << KYEL << warn << "\e[0m" << std::flush;
|
||||||
|
|
@ -42,7 +42,7 @@ void printWarn(std::string warn, bool eol)
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printInfo(std::string info, bool eol)
|
void printInfo(const std::string &info, bool eol)
|
||||||
{
|
{
|
||||||
if (isatty(STDOUT_FILENO))
|
if (isatty(STDOUT_FILENO))
|
||||||
std::cout << KBLUL << info << "\e[0m" << std::flush;
|
std::cout << KBLUL << info << "\e[0m" << std::flush;
|
||||||
|
|
@ -53,7 +53,7 @@ void printInfo(std::string info, bool eol)
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printSuccess(std::string success, bool eol)
|
void printSuccess(const std::string &success, bool eol)
|
||||||
{
|
{
|
||||||
if (isatty(STDOUT_FILENO))
|
if (isatty(STDOUT_FILENO))
|
||||||
std::cout << KGRN << success << "\e[0m" << std::flush;
|
std::cout << KGRN << success << "\e[0m" << std::flush;
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void printError(std::string err, bool eol = true);
|
void printError(const std::string &err, bool eol = true);
|
||||||
void printWarn(std::string warn, bool eol = true);
|
void printWarn(const std::string &warn, bool eol = true);
|
||||||
void printInfo(std::string info, bool eol = true);
|
void printInfo(const std::string &info, bool eol = true);
|
||||||
void printSuccess(std::string success, bool eol = true);
|
void printSuccess(const std::string &success, bool eol = true);
|
||||||
|
|
||||||
#endif // DISPLAY_HPP_
|
#endif // DISPLAY_HPP_
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FeaParser::FeaParser(string filename, bool verbose):
|
FeaParser::FeaParser(const string &filename, bool verbose):
|
||||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||||
_feabits(0), _has_feabits(false)
|
_feabits(0), _has_feabits(false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
class FeaParser: public ConfigBitstreamParser {
|
class FeaParser: public ConfigBitstreamParser {
|
||||||
public:
|
public:
|
||||||
FeaParser(std::string filename, bool verbose = false);
|
FeaParser(const std::string &filename, bool verbose = false);
|
||||||
int parse() override;
|
int parse() override;
|
||||||
void displayHeader() override;
|
void displayHeader() override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ using namespace std;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FtdiJtagBitBang::FtdiJtagBitBang(const cable_t &cable,
|
FtdiJtagBitBang::FtdiJtagBitBang(const cable_t &cable,
|
||||||
const jtag_pins_conf_t *pin_conf, string dev, const std::string &serial,
|
const jtag_pins_conf_t *pin_conf, const string &dev,
|
||||||
uint32_t clkHZ, uint8_t verbose):
|
const std::string &serial, uint32_t clkHZ, uint8_t verbose):
|
||||||
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _bitmode(0),
|
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _bitmode(0),
|
||||||
_curr_tms(0), _rx_size(0)
|
_curr_tms(0), _rx_size(0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
class FtdiJtagBitBang : public JtagInterface, private FTDIpp_MPSSE {
|
class FtdiJtagBitBang : public JtagInterface, private FTDIpp_MPSSE {
|
||||||
public:
|
public:
|
||||||
FtdiJtagBitBang(const cable_t &cable,
|
FtdiJtagBitBang(const cable_t &cable,
|
||||||
const jtag_pins_conf_t *pin_conf, std::string dev, const std::string &serial,
|
const jtag_pins_conf_t *pin_conf, const std::string &dev,
|
||||||
uint32_t clkHZ, uint8_t verbose = 0);
|
const std::string &serial, uint32_t clkHZ, uint8_t verbose = 0);
|
||||||
virtual ~FtdiJtagBitBang();
|
virtual ~FtdiJtagBitBang();
|
||||||
|
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ using namespace std;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FtdiJtagMPSSE::FtdiJtagMPSSE(const cable_t &cable,
|
FtdiJtagMPSSE::FtdiJtagMPSSE(const cable_t &cable,
|
||||||
string dev, const string &serial, uint32_t clkHZ,
|
const string &dev, const string &serial, uint32_t clkHZ,
|
||||||
bool invert_read_edge, int8_t verbose):
|
bool invert_read_edge, int8_t verbose):
|
||||||
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _ch552WA(false),
|
FTDIpp_MPSSE(cable, dev, serial, clkHZ, verbose), _ch552WA(false),
|
||||||
_write_mode(MPSSE_WRITE_NEG), // always write on neg edge
|
_write_mode(MPSSE_WRITE_NEG), // always write on neg edge
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
class FtdiJtagMPSSE : public JtagInterface, public FTDIpp_MPSSE {
|
class FtdiJtagMPSSE : public JtagInterface, public FTDIpp_MPSSE {
|
||||||
public:
|
public:
|
||||||
FtdiJtagMPSSE(const cable_t &cable, std::string dev,
|
FtdiJtagMPSSE(const cable_t &cable, const std::string &dev,
|
||||||
const std::string &serial, uint32_t clkHZ, bool invert_read_edge,
|
const std::string &serial, uint32_t clkHZ, bool invert_read_edge,
|
||||||
int8_t verbose = 0);
|
int8_t verbose = 0);
|
||||||
virtual ~FtdiJtagMPSSE();
|
virtual ~FtdiJtagMPSSE();
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
JedParser::JedParser(string filename, bool verbose):
|
JedParser::JedParser(const string &filename, bool verbose):
|
||||||
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
ConfigBitstreamParser(filename, ConfigBitstreamParser::BIN_MODE, verbose),
|
||||||
_fuse_count(0), _pin_count(0), _max_vect_test(0),
|
_fuse_count(0), _pin_count(0), _max_vect_test(0),
|
||||||
_featuresRow(0), _feabits(0), _has_feabits(false), _checksum(0),
|
_featuresRow(0), _feabits(0), _has_feabits(false), _checksum(0),
|
||||||
|
|
@ -168,7 +168,7 @@ void JedParser::displayHeader()
|
||||||
printf("Fuse Count : %d\n", _fuse_count);
|
printf("Fuse Count : %d\n", _fuse_count);
|
||||||
|
|
||||||
for (size_t i = 0; i < _data_list.size(); i++) {
|
for (size_t i = 0; i < _data_list.size(); i++) {
|
||||||
printf("area[%zd] %4d %4d ", i, _data_list[i].offset, _data_list[i].len);
|
printf("area[%zu] %4d %4d ", i, _data_list[i].offset, _data_list[i].len);
|
||||||
printf("%zu ", _data_list[i].data.size());
|
printf("%zu ", _data_list[i].data.size());
|
||||||
for (size_t ii = 0; ii < _data_list[i].data.size(); ii++)
|
for (size_t ii = 0; ii < _data_list[i].data.size(); ii++)
|
||||||
for (size_t iii = 0; iii < _data_list[i].data[ii].size(); iii++)
|
for (size_t iii = 0; iii < _data_list[i].data[ii].size(); iii++)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class JedParser: public ConfigBitstreamParser {
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JedParser(std::string filename, bool verbose = false);
|
JedParser(const std::string &filename, bool verbose = false);
|
||||||
int parse() override;
|
int parse() override;
|
||||||
void displayHeader() override;
|
void displayHeader() override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,9 @@ int JetsonNanoJtagBitbang::writeTMS(uint8_t *tms_buf, uint32_t len,
|
||||||
{
|
{
|
||||||
int tms;
|
int tms;
|
||||||
|
|
||||||
|
if (len == 0) // nothing -> stop
|
||||||
|
return len;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
tms = ((tms_buf[i >> 3] & (1 << (i & 7))) ? 1 : 0);
|
tms = ((tms_buf[i >> 3] & (1 << (i & 7))) ? 1 : 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ using namespace std;
|
||||||
* - envoyer le dernier avec 0x4B ou 0x6B
|
* - envoyer le dernier avec 0x4B ou 0x6B
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf, string dev,
|
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 &serial, uint32_t clkHZ, int8_t verbose,
|
||||||
const string &ip_adr, int port,
|
const string &ip_adr, int port,
|
||||||
const bool invert_read_edge, const string &firmware_path):
|
const bool invert_read_edge, const string &firmware_path):
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
class Jtag {
|
class Jtag {
|
||||||
public:
|
public:
|
||||||
Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf, std::string dev,
|
Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||||
|
const std::string &dev,
|
||||||
const std::string &serial, uint32_t clkHZ, int8_t verbose,
|
const std::string &serial, uint32_t clkHZ, int8_t verbose,
|
||||||
const std::string &ip_adr, int port,
|
const std::string &ip_adr, int port,
|
||||||
const bool invert_read_edge = false,
|
const bool invert_read_edge = false,
|
||||||
|
|
|
||||||
|
|
@ -883,7 +883,7 @@ bool Lattice::wr_rd(uint8_t cmd,
|
||||||
uint8_t xfer_rx[kXferLen];
|
uint8_t xfer_rx[kXferLen];
|
||||||
memset(xfer_tx, 0, kXferLen);
|
memset(xfer_tx, 0, kXferLen);
|
||||||
int i;
|
int i;
|
||||||
if (tx) {
|
if (tx != NULL && tx_len > 0) {
|
||||||
for (i = 0; i < tx_len; i++)
|
for (i = 0; i < tx_len; i++)
|
||||||
xfer_tx[i] = tx[i];
|
xfer_tx[i] = tx[i];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,9 @@ int LibgpiodJtagBitbang::writeTMS(uint8_t *tms_buf, uint32_t len,
|
||||||
{
|
{
|
||||||
int tms;
|
int tms;
|
||||||
|
|
||||||
|
if (len == 0) // nothing -> stop
|
||||||
|
return len;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
tms = ((tms_buf[i >> 3] & (1 << (i & 7))) ? 1 : 0);
|
tms = ((tms_buf[i >> 3] & (1 << (i & 7))) ? 1 : 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ uint32_t POFParser::parseSection(uint16_t flag, uint32_t pos, uint32_t size)
|
||||||
_bit_data.begin());
|
_bit_data.begin());
|
||||||
_bit_length = size * 8;
|
_bit_length = size * 8;
|
||||||
if (_verbose)
|
if (_verbose)
|
||||||
printf("size %u %lu\n", size, _bit_data.size());
|
printf("size %u %zu\n", size, _bit_data.size());
|
||||||
break;
|
break;
|
||||||
case 0x1a: // flash sections
|
case 0x1a: // flash sections
|
||||||
// 12Bytes ?
|
// 12Bytes ?
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,13 @@
|
||||||
#include "progressBar.hpp"
|
#include "progressBar.hpp"
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
|
|
||||||
ProgressBar::ProgressBar(std::string mess, int maxValue, int progressLen,
|
ProgressBar::ProgressBar(const std::string &mess, int maxValue,
|
||||||
bool quiet): _mess(mess), _maxValue(maxValue),
|
int progressLen, bool quiet): _mess(mess), _maxValue(maxValue),
|
||||||
_progressLen(progressLen), _quiet(quiet), _first(true)
|
_progressLen(progressLen), last_time(std::chrono::system_clock::now()),
|
||||||
|
_quiet(quiet), _first(true)
|
||||||
{
|
{
|
||||||
last_time = std::chrono::system_clock::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressBar::display(int value, char force)
|
void ProgressBar::display(int value, char force)
|
||||||
{
|
{
|
||||||
if (_quiet) {
|
if (_quiet) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
class ProgressBar {
|
class ProgressBar {
|
||||||
public:
|
public:
|
||||||
ProgressBar(std::string mess, int maxValue, int progressLen,
|
ProgressBar(const std::string &mess, int maxValue, int progressLen,
|
||||||
bool quiet = false);
|
bool quiet = false);
|
||||||
void display(int value, char force = 0);
|
void display(int value, char force = 0);
|
||||||
void done();
|
void done();
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ Xilinx::Xilinx(Jtag *jtag, const std::string &filename,
|
||||||
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
|
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
|
||||||
skip_reset),
|
skip_reset),
|
||||||
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
|
_device_package(device_package), _spiOverJtagPath(spiOverJtagPath),
|
||||||
_irlen(6), _filename(filename), _secondary_filename(secondary_filename)
|
_irlen(6), _secondary_filename(secondary_filename)
|
||||||
{
|
{
|
||||||
if (prg_type == Device::RD_FLASH) {
|
if (prg_type == Device::RD_FLASH) {
|
||||||
_mode = Device::READ_MODE;
|
_mode = Device::READ_MODE;
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,6 @@ class Xilinx: public Device, SPIInterface {
|
||||||
char _cpld_base_name[7]; /**< cpld name (without package size) */
|
char _cpld_base_name[7]; /**< cpld name (without package size) */
|
||||||
int _irlen; /**< IR bit length */
|
int _irlen; /**< IR bit length */
|
||||||
std::map<std::string, std::vector<uint8_t>> _ircode_map; /**< bscan instructions based on model */
|
std::map<std::string, std::vector<uint8_t>> _ircode_map; /**< bscan instructions based on model */
|
||||||
std::string _filename; /* path to the primary flash file */
|
|
||||||
std::string _secondary_filename; /* path to the secondary flash file (SPIx8) */
|
std::string _secondary_filename; /* path to the secondary flash file (SPIx8) */
|
||||||
std::string _secondary_file_extension; /* file type for the secondary flash file */
|
std::string _secondary_file_extension; /* file type for the secondary flash file */
|
||||||
int _flash_chips; /* bitfield to select the target in boards with two flash chips */
|
int _flash_chips; /* bitfield to select the target in boards with two flash chips */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue