main: enable xvc_server

This commit is contained in:
Gwenhael Goavec-Merou 2022-07-06 20:58:34 +02:00
parent 34ff4f4020
commit a90a7b6fa5
3 changed files with 59 additions and 1 deletions

View File

@ -98,6 +98,8 @@ openFPGALoader -- a program to flash FPGA
2:debug
-h, --help Give this help list
--verify Verify write operation (SPI Flash only)
--xvc Xilinx Virtual Cable Functions
--port arg Xilinx Virtual Cable Port (default 3721)
-V, --Version Print program version
Mandatory or optional arguments to long options are also mandatory or optional

View File

@ -229,3 +229,10 @@ xvc-client:
- Name: Xilinx Virtual Cable
Description: Xilinx Virtual Cable (XVC) is a TCP/IP-based protocol that acts like a JTAG cable.
URL: https://github.com/Xilinx/XilinxVirtualCable
xvc-server:
- Name: Xilinx Virtual Cable (server side)
Description: Xilinx Virtual Cable (XVC) is a TCP/IP-based protocol that acts like a JTAG cable.
URL: https://github.com/Xilinx/XilinxVirtualCable

View File

@ -30,6 +30,7 @@
#include "spiFlash.hpp"
#include "rawParser.hpp"
#include "xilinx.hpp"
#include "xvc_server.hpp"
#define DEFAULT_FREQ 6000000
@ -71,8 +72,15 @@ struct arguments {
string flash_sector;
bool skip_load_bridge;
bool skip_reset;
/* xvc server */
bool xvc;
int port;
string interface;
};
int run_xvc_server(const struct arguments &args, const cable_t &cable,
const jtag_pins_conf_t *pins_config);
int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *pins_config);
void displaySupported(const struct arguments &args);
@ -87,7 +95,10 @@ int main(int argc, char **argv)
struct arguments args = {0, false, false, false, 0, "", "", "-", "", -1,
0, false, "-", false, false, false, false, Device::PRG_NONE, false,
false, false, "", "", "", -1, 0, false, -1, 0, 0, 0, "127.0.0.1",
0, false, "", false, false};
0, false, "", false, false,
/* xvc server */
false, 3721, "-",
};
/* parse arguments */
try {
if (parse_opt(argc, argv, &args, &pins_config))
@ -370,8 +381,16 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
}
/* ------------------- */
/* XVC server */
/* ------------------- */
if (args.xvc) {
return run_xvc_server(args, cable, &pins_config);
}
/* jtag base */
/* if no instruction from user -> select load */
if (args.prg_type == Device::PRG_NONE)
args.prg_type = Device::WR_SRAM;
@ -466,6 +485,7 @@ int main(int argc, char **argv)
string fab = fpga_list[idcode].manufacturer;
Device *fpga;
try {
if (fab == "xilinx") {
@ -538,6 +558,30 @@ int main(int argc, char **argv)
delete(jtag);
}
int run_xvc_server(const struct arguments &args, const cable_t &cable,
const jtag_pins_conf_t *pins_config)
{
//create XVC instance
try {
XVC_server *xvc = NULL;
xvc = new XVC_server(args.port, cable, pins_config, args.device,
args.ftdi_serial, args.freq, args.verbose, args.ip_adr,
args.invert_read_edge, args.probe_firmware);
/* create connection */
xvc->open_connection();
/* start loop */
xvc->listen_loop();
/* close connection */
xvc->close_connection();
delete xvc;
} catch (std::exception &e) {
printError("XVC_server failed with " + string(e.what()));
return EXIT_FAILURE;
}
printInfo("Xilinx Virtual Cable Stopped! ");
return EXIT_SUCCESS;
}
// 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) {
@ -657,6 +701,10 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
("h,help", "Give this help list")
("verify", "Verify write operation (SPI Flash only)",
cxxopts::value<bool>(args->verify))
("xvc", "Xilinx Virtual Cable Functions",
cxxopts::value<bool>(args->xvc))
("port", "Xilinx Virtual Cable Port (default 3721)",
cxxopts::value<int>(args->port))
("V,Version", "Print program version");
options.parse_positional({"bitstream"});
@ -786,6 +834,7 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
!args->detect &&
!args->protect_flash &&
!args->unprotect_flash &&
!args->xvc &&
!args->reset) {
printError("Error: bitfile not specified");
cout << options.help() << endl;