main: introduce vid/pid args
This commit is contained in:
parent
2adf4d585e
commit
6858cabc7d
|
|
@ -44,6 +44,8 @@ openFPGALoader -- a program to flash FPGA
|
||||||
--bitstream arg bitstream
|
--bitstream arg bitstream
|
||||||
-b, --board arg board name, may be used instead of cable
|
-b, --board arg board name, may be used instead of cable
|
||||||
-c, --cable arg jtag interface
|
-c, --cable arg jtag interface
|
||||||
|
--vid arg probe Vendor ID
|
||||||
|
--pid arg probe Product ID
|
||||||
--ftdi-serial arg FTDI chip serial number
|
--ftdi-serial arg FTDI chip serial number
|
||||||
--ftdi-channel arg FTDI chip channel number (channels 0-3 map to
|
--ftdi-channel arg FTDI chip channel number (channels 0-3 map to
|
||||||
A-D)
|
A-D)
|
||||||
|
|
|
||||||
23
src/main.cpp
23
src/main.cpp
|
|
@ -59,7 +59,9 @@ struct arguments {
|
||||||
int index_chain;
|
int index_chain;
|
||||||
unsigned int file_size;
|
unsigned int file_size;
|
||||||
bool external_flash;
|
bool external_flash;
|
||||||
int altsetting;
|
int16_t altsetting;
|
||||||
|
uint16_t vid;
|
||||||
|
uint16_t pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *pins_config);
|
int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *pins_config);
|
||||||
|
|
@ -75,7 +77,7 @@ int main(int argc, char **argv)
|
||||||
/* command line args. */
|
/* command line args. */
|
||||||
struct arguments args = {0, false, false, false, 0, "", "", "-", "", -1,
|
struct arguments args = {0, false, false, false, 0, "", "", "-", "", -1,
|
||||||
0, "-", false, false, false, false, Device::WR_SRAM, false,
|
0, "-", false, false, false, false, Device::WR_SRAM, false,
|
||||||
false, false, "", "", "", -1, 0, false, -1};
|
false, false, "", "", "", -1, 0, false, -1, 0, 0};
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
try {
|
try {
|
||||||
if (parse_opt(argc, argv, &args, &pins_config))
|
if (parse_opt(argc, argv, &args, &pins_config))
|
||||||
|
|
@ -279,6 +281,18 @@ int main(int argc, char **argv)
|
||||||
printInfo("Board altsetting overridden");
|
printInfo("Board altsetting overridden");
|
||||||
altsetting = args.altsetting;
|
altsetting = args.altsetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.vid != 0) {
|
||||||
|
if (vid != 0)
|
||||||
|
printInfo("Board VID overridden");
|
||||||
|
vid = args.vid;
|
||||||
|
}
|
||||||
|
if (args.pid != 0) {
|
||||||
|
if (pid != 0)
|
||||||
|
printInfo("Board PID overridden");
|
||||||
|
pid = args.pid;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dfu = new DFU(args.bit_file, vid, pid, altsetting, args.verbose);
|
dfu = new DFU(args.bit_file, vid, pid, altsetting, args.verbose);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
|
|
@ -495,12 +509,15 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
||||||
options
|
options
|
||||||
.add_options()
|
.add_options()
|
||||||
("altsetting", "DFU interface altsetting (only for DFU mode)",
|
("altsetting", "DFU interface altsetting (only for DFU mode)",
|
||||||
cxxopts::value<int>(args->altsetting))
|
cxxopts::value<int16_t>(args->altsetting))
|
||||||
("bitstream", "bitstream",
|
("bitstream", "bitstream",
|
||||||
cxxopts::value<std::string>(args->bit_file))
|
cxxopts::value<std::string>(args->bit_file))
|
||||||
("b,board", "board name, may be used instead of cable",
|
("b,board", "board name, may be used instead of cable",
|
||||||
cxxopts::value<string>(args->board))
|
cxxopts::value<string>(args->board))
|
||||||
("c,cable", "jtag interface", cxxopts::value<string>(args->cable))
|
("c,cable", "jtag interface", cxxopts::value<string>(args->cable))
|
||||||
|
("vid", "probe Vendor ID", cxxopts::value<uint16_t>(args->vid))
|
||||||
|
("pid", "probe Product ID", cxxopts::value<uint16_t>(args->pid))
|
||||||
|
|
||||||
("ftdi-serial", "FTDI chip serial number", cxxopts::value<string>(args->ftdi_serial))
|
("ftdi-serial", "FTDI chip serial number", cxxopts::value<string>(args->ftdi_serial))
|
||||||
("ftdi-channel", "FTDI chip channel number (channels 0-3 map to A-D)", cxxopts::value<int>(args->ftdi_channel))
|
("ftdi-channel", "FTDI chip channel number (channels 0-3 map to A-D)", cxxopts::value<int>(args->ftdi_channel))
|
||||||
#ifdef USE_UDEV
|
#ifdef USE_UDEV
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue