propagate jtag_pins_conf_t and add support for bitbang mode

This commit is contained in:
Gwenhael Goavec-Merou 2020-03-07 11:44:17 +01:00
parent e8bff2d2f2
commit c4f6178733
3 changed files with 25 additions and 11 deletions

View File

@ -63,23 +63,24 @@ using namespace std;
* - envoyer le dernier avec 0x4B ou 0x6B * - envoyer le dernier avec 0x4B ou 0x6B
*/ */
Jtag::Jtag(cable_t &cable, string dev, Jtag::Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf, string dev,
uint32_t clkHZ, bool verbose): uint32_t clkHZ, bool verbose):
_verbose(verbose), _verbose(verbose),
_state(RUN_TEST_IDLE), _state(RUN_TEST_IDLE),
_tms_buffer_size(128), _num_tms(0), _tms_buffer_size(128), _num_tms(0),
_board_name("nope") _board_name("nope")
{ {
init_internal(cable, clkHZ); init_internal(cable, pin_conf, clkHZ);
} }
Jtag::Jtag(cable_t &cable, uint32_t clkHZ, bool verbose): Jtag::Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf,
uint32_t clkHZ, bool verbose):
_verbose(verbose), _verbose(verbose),
_state(RUN_TEST_IDLE), _state(RUN_TEST_IDLE),
_tms_buffer_size(128), _num_tms(0), _tms_buffer_size(128), _num_tms(0),
_board_name("nope") _board_name("nope")
{ {
init_internal(cable, clkHZ); init_internal(cable, pin_conf, clkHZ);
} }
Jtag::~Jtag() Jtag::~Jtag()
@ -88,9 +89,16 @@ Jtag::~Jtag()
delete _jtag; delete _jtag;
} }
void Jtag::init_internal(cable_t &cable, uint32_t clkHZ) void Jtag::init_internal(cable_t &cable, const jtag_pins_conf_t *pin_conf,
uint32_t clkHZ)
{ {
_jtag = new FtdiJtagMPSSE(cable.config, clkHZ, _verbose); if (cable.type == MODE_FTDI_BITBANG) {
if (pin_conf == NULL)
throw std::exception();
_jtag = new FtdiJtagBitBang(cable.config, pin_conf, clkHZ, _verbose);
} else {
_jtag = new FtdiJtagMPSSE(cable.config, clkHZ, _verbose);
}
_tms_buffer = (unsigned char *)malloc(sizeof(unsigned char) * _tms_buffer_size); _tms_buffer = (unsigned char *)malloc(sizeof(unsigned char) * _tms_buffer_size);
bzero(_tms_buffer, _tms_buffer_size); bzero(_tms_buffer, _tms_buffer_size);

View File

@ -22,15 +22,16 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "board.hpp"
#include "cable.hpp" #include "cable.hpp"
#include "ftdipp_mpsse.hpp" #include "ftdipp_mpsse.hpp"
#include "jtagInterface.hpp" #include "jtagInterface.hpp"
class Jtag { class Jtag {
public: public:
Jtag(cable_t &cable, std::string dev, Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf, std::string dev,
uint32_t clkHZ, bool verbose = false); uint32_t clkHZ, bool verbose = false);
Jtag(cable_t &cable, Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf,
uint32_t clkHZ, bool verbose); uint32_t clkHZ, bool verbose);
~Jtag(); ~Jtag();
@ -81,7 +82,8 @@ class Jtag {
void setVerbose(bool verbose){_verbose = verbose;} void setVerbose(bool verbose){_verbose = verbose;}
private: private:
void init_internal(cable_t &cable, uint32_t clkHZ); void init_internal(cable_t &cable, const jtag_pins_conf_t *pin_conf,
uint32_t clkHZ);
bool _verbose; bool _verbose;
int _state; int _state;
int _tms_buffer_size; int _tms_buffer_size;

View File

@ -86,6 +86,7 @@ void displaySupported(const struct arguments &args);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
cable_t cable; cable_t cable;
jtag_pins_conf_t *pins_config = NULL;
/* command line args. */ /* command line args. */
struct arguments args = {false, false, false, 0, "", "-", "-", "-", struct arguments args = {false, false, false, 0, "", "-", "-", "-",
@ -100,6 +101,9 @@ int main(int argc, char **argv)
/* if a board name is specified try to use this to determine cable */ /* if a board name is specified try to use this to determine cable */
if (args.board[0] != '-' && board_list.find(args.board) != board_list.end()) { if (args.board[0] != '-' && board_list.find(args.board) != board_list.end()) {
/* set pins config */
pins_config = &board_list[args.board].pins_config;
/* search for cable */
auto t = cable_list.find(board_list[args.board].cable_name); auto t = cable_list.find(board_list[args.board].cable_name);
if (t == cable_list.end()) { if (t == cable_list.end()) {
args.cable = "-"; args.cable = "-";
@ -124,9 +128,9 @@ int main(int argc, char **argv)
/* jtag base */ /* jtag base */
Jtag *jtag; Jtag *jtag;
if (args.device == "-") if (args.device == "-")
jtag = new Jtag(cable, 6000000, false); jtag = new Jtag(cable, pins_config, 6000000, false);
else else
jtag = new Jtag(cable, args.device, 6000000, false); jtag = new Jtag(cable, pins_config, args.device, 6000000, false);
/* chain detection */ /* chain detection */
vector<int> listDev; vector<int> listDev;