add --detect option to display wich FPGA
This commit is contained in:
parent
4252e6dc45
commit
d5e696b5c3
|
|
@ -63,6 +63,7 @@ openFPGALoader -- a program to flash cyclone10 LP FPGA
|
||||||
-b, --board=BOARD board name, may be used instead of cable
|
-b, --board=BOARD board name, may be used instead of cable
|
||||||
-c, --cable=CABLE jtag interface
|
-c, --cable=CABLE jtag interface
|
||||||
-d, --device=DEVICE device to use (/dev/ttyUSBx)
|
-d, --device=DEVICE device to use (/dev/ttyUSBx)
|
||||||
|
--detect detect FPGA
|
||||||
-f, --write-flash write bitstream in flash (default: false, only for
|
-f, --write-flash write bitstream in flash (default: false, only for
|
||||||
Gowin devices)
|
Gowin devices)
|
||||||
--list-boards list all supported boards
|
--list-boards list all supported boards
|
||||||
|
|
|
||||||
18
src/main.cpp
18
src/main.cpp
|
|
@ -38,7 +38,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct arguments {
|
struct arguments {
|
||||||
bool verbose, reset;
|
bool verbose, reset, detect;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
string bit_file;
|
string bit_file;
|
||||||
string device;
|
string device;
|
||||||
|
|
@ -55,6 +55,7 @@ struct arguments {
|
||||||
#define LIST_CABLE 1
|
#define LIST_CABLE 1
|
||||||
#define LIST_BOARD 2
|
#define LIST_BOARD 2
|
||||||
#define LIST_FPGA 3
|
#define LIST_FPGA 3
|
||||||
|
#define DETECT 4
|
||||||
|
|
||||||
const char *argp_program_version = "openFPGALoader 1.0";
|
const char *argp_program_version = "openFPGALoader 1.0";
|
||||||
const char *argp_program_bug_address = "<gwenhael.goavec-merou@trabucayre.com>";
|
const char *argp_program_bug_address = "<gwenhael.goavec-merou@trabucayre.com>";
|
||||||
|
|
@ -68,6 +69,7 @@ static struct argp_option options[] = {
|
||||||
{"list-boards", LIST_BOARD, 0, 0, "list all supported boards"},
|
{"list-boards", LIST_BOARD, 0, 0, "list all supported boards"},
|
||||||
{"device", 'd', "DEVICE", 0, "device to use (/dev/ttyUSBx)"},
|
{"device", 'd', "DEVICE", 0, "device to use (/dev/ttyUSBx)"},
|
||||||
{"list-fpga", LIST_FPGA, 0, 0, "list all supported FPGA"},
|
{"list-fpga", LIST_FPGA, 0, 0, "list all supported FPGA"},
|
||||||
|
{"detect", DETECT, 0, 0, "detect FPGA"},
|
||||||
{"write-flash", 'f', 0, 0,
|
{"write-flash", 'f', 0, 0,
|
||||||
"write bitstream in flash (default: false, only for Gowin devices)"},
|
"write bitstream in flash (default: false, only for Gowin devices)"},
|
||||||
{"write-sram", 'm', 0, 0,
|
{"write-sram", 'm', 0, 0,
|
||||||
|
|
@ -86,7 +88,7 @@ int main(int argc, char **argv)
|
||||||
FTDIpp_MPSSE::mpsse_bit_config cable;
|
FTDIpp_MPSSE::mpsse_bit_config cable;
|
||||||
|
|
||||||
/* command line args. */
|
/* command line args. */
|
||||||
struct arguments args = {false, false, 0, "", "-", "-", "-",
|
struct arguments args = {false, false, false, 0, "", "-", "-", "-",
|
||||||
false, false, false, false, true, false};
|
false, false, false, false, true, false};
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
argp_parse(&argp, argc, argv, 0, 0, &args);
|
argp_parse(&argp, argc, argv, 0, 0, &args);
|
||||||
|
|
@ -145,13 +147,19 @@ int main(int argc, char **argv)
|
||||||
if (fpga_list.find(idcode) == fpga_list.end()) {
|
if (fpga_list.find(idcode) == fpga_list.end()) {
|
||||||
cerr << "Error: device " << hex << idcode << " not supported" << endl;
|
cerr << "Error: device " << hex << idcode << " not supported" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
} else if (args.verbose) {
|
} else if (args.verbose || args.detect) {
|
||||||
printf("idcode 0x%x\nmanufacturer %s\nmodel %s\nfamily %s\n",
|
printf("idcode 0x%x\nmanufacturer %s\nmodel %s\nfamily %s\n",
|
||||||
idcode,
|
idcode,
|
||||||
fpga_list[idcode].manufacturer.c_str(),
|
fpga_list[idcode].manufacturer.c_str(),
|
||||||
fpga_list[idcode].model.c_str(),
|
fpga_list[idcode].model.c_str(),
|
||||||
fpga_list[idcode].family.c_str());
|
fpga_list[idcode].family.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.detect == true) {
|
||||||
|
delete jtag;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
string fab = fpga_list[idcode].manufacturer;
|
string fab = fpga_list[idcode].manufacturer;
|
||||||
|
|
||||||
Device *fpga;
|
Device *fpga;
|
||||||
|
|
@ -224,6 +232,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||||
case ARGP_KEY_END:
|
case ARGP_KEY_END:
|
||||||
if (arguments->bit_file.empty() &&
|
if (arguments->bit_file.empty() &&
|
||||||
!arguments->is_list_command &&
|
!arguments->is_list_command &&
|
||||||
|
!arguments->detect &&
|
||||||
!arguments->reset) {
|
!arguments->reset) {
|
||||||
cout << "Error: bitfile not specified" << endl;
|
cout << "Error: bitfile not specified" << endl;
|
||||||
argp_usage(state);
|
argp_usage(state);
|
||||||
|
|
@ -241,6 +250,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||||
arguments->list_fpga = true;
|
arguments->list_fpga = true;
|
||||||
arguments->is_list_command = true;
|
arguments->is_list_command = true;
|
||||||
break;
|
break;
|
||||||
|
case DETECT:
|
||||||
|
arguments->detect = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return ARGP_ERR_UNKNOWN;
|
return ARGP_ERR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue