hosted: Add -l argument to list only available debuggers and exit.
This commit is contained in:
parent
dc3fd2eb06
commit
425002a38f
|
@ -100,6 +100,7 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
||||||
char manufacturer[128];
|
char manufacturer[128];
|
||||||
char product[128];
|
char product[128];
|
||||||
bmp_type_t type = BMP_TYPE_NONE;
|
bmp_type_t type = BMP_TYPE_NONE;
|
||||||
|
bool access_problems = false;
|
||||||
rescan:
|
rescan:
|
||||||
found_debuggers = 0;
|
found_debuggers = 0;
|
||||||
for (int i = 0; devs[i]; i++) {
|
for (int i = 0; devs[i]; i++) {
|
||||||
|
@ -114,8 +115,11 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
||||||
libusb_device_handle *handle;
|
libusb_device_handle *handle;
|
||||||
res = libusb_open(dev, &handle);
|
res = libusb_open(dev, &handle);
|
||||||
if (res != LIBUSB_SUCCESS) {
|
if (res != LIBUSB_SUCCESS) {
|
||||||
DEBUG_INFO("INFO: Open USB %04x:%04x failed\n",
|
if (!access_problems) {
|
||||||
desc.idVendor, desc.idProduct);
|
DEBUG_INFO("INFO: Open USB %04x:%04x failed\n",
|
||||||
|
desc.idVendor, desc.idProduct);
|
||||||
|
access_problems = true;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
res = libusb_get_string_descriptor_ascii(
|
res = libusb_get_string_descriptor_ascii(
|
||||||
|
@ -198,15 +202,23 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found_debuggers > 1) {
|
if ((found_debuggers > 1) ||
|
||||||
|
((found_debuggers == 1) && (cl_opts->opt_list_only))) {
|
||||||
if (!report) {
|
if (!report) {
|
||||||
DEBUG_WARN("%d debuggers found! Select with -P <num>, -s <string> "
|
if (found_debuggers > 1)
|
||||||
"and/or -S <string>\n",
|
DEBUG_WARN("%d debuggers found!\nSelect with -P <pos>, "
|
||||||
found_debuggers);
|
"-s <(partial)serial no.> "
|
||||||
|
"and/or -S <(partial)description>\n",
|
||||||
|
found_debuggers);
|
||||||
report = true;
|
report = true;
|
||||||
goto rescan;
|
goto rescan;
|
||||||
|
} else {
|
||||||
|
found_debuggers = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found_debuggers && access_problems)
|
||||||
|
DEBUG_WARN(
|
||||||
|
"No debugger found. Please check access rights to USB devices!\n");
|
||||||
libusb_free_device_list(devs, 1);
|
libusb_free_device_list(devs, 1);
|
||||||
return (found_debuggers == 1) ? 0 : -1;
|
return (found_debuggers == 1) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,10 +124,10 @@ static void cl_help(char **argv, BMP_CL_OPTIONS_t *opt)
|
||||||
DEBUG_WARN("\t\t\t 1 = INFO, 2 = GDB, 4 = TARGET, 8 = PROBE, 16 = WIRE\n");
|
DEBUG_WARN("\t\t\t 1 = INFO, 2 = GDB, 4 = TARGET, 8 = PROBE, 16 = WIRE\n");
|
||||||
DEBUG_WARN("Probe selection arguments:\n");
|
DEBUG_WARN("Probe selection arguments:\n");
|
||||||
DEBUG_WARN("\t-d \"path\"\t: Use serial device at \"path\"\n");
|
DEBUG_WARN("\t-d \"path\"\t: Use serial device at \"path\"\n");
|
||||||
DEBUG_WARN("\t-P <num>\t: Use debugger found at position <num>\n");
|
DEBUG_WARN("\t-P <pos>\t: Use debugger found at position <pos>\n");
|
||||||
DEBUG_WARN("\t-n <num>\t: Use target device found at position <num>\n");
|
DEBUG_WARN("\t-n <num>\t: Use target device found at position <num>\n");
|
||||||
DEBUG_WARN("\t-s \"string\"\t: Use dongle with (partial) "
|
DEBUG_WARN("\t-s \"serial\"\t: Use dongle with (partial) "
|
||||||
"serial number \"string\"\n");
|
"serial number \"serial\"\n");
|
||||||
DEBUG_WARN("\t-c \"string\"\t: Use ftdi dongle with type \"string\"\n");
|
DEBUG_WARN("\t-c \"string\"\t: Use ftdi dongle with type \"string\"\n");
|
||||||
DEBUG_WARN("Run mode related options:\n");
|
DEBUG_WARN("Run mode related options:\n");
|
||||||
DEBUG_WARN("\tDefault mode is to start the debug server at :2000\n");
|
DEBUG_WARN("\tDefault mode is to start the debug server at :2000\n");
|
||||||
|
@ -155,7 +155,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
||||||
opt->opt_target_dev = 1;
|
opt->opt_target_dev = 1;
|
||||||
opt->opt_flash_start = 0x08000000;
|
opt->opt_flash_start = 0x08000000;
|
||||||
opt->opt_flash_size = 16 * 1024 *1024;
|
opt->opt_flash_size = 16 * 1024 *1024;
|
||||||
while((c = getopt(argc, argv, "Ehv:d:s:I:c:Cn:tVta:S:jpP:rR")) != -1) {
|
while((c = getopt(argc, argv, "Ehv:d:s:I:c:CnltVta:S:jpP:rR")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
|
@ -171,6 +171,10 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
||||||
case 'j':
|
case 'j':
|
||||||
opt->opt_usejtag = true;
|
opt->opt_usejtag = true;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
opt->opt_list_only = true;
|
||||||
|
cl_debuglevel |= BMP_DEBUG_STDOUT;
|
||||||
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
opt->opt_connect_under_reset = true;
|
opt->opt_connect_under_reset = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef struct BMP_CL_OPTIONS_s {
|
||||||
enum bmp_cl_mode opt_mode;
|
enum bmp_cl_mode opt_mode;
|
||||||
bool opt_usejtag;
|
bool opt_usejtag;
|
||||||
bool opt_tpwr;
|
bool opt_tpwr;
|
||||||
|
bool opt_list_only;
|
||||||
bool opt_connect_under_reset;
|
bool opt_connect_under_reset;
|
||||||
char *opt_flash_file;
|
char *opt_flash_file;
|
||||||
char *opt_device;
|
char *opt_device;
|
||||||
|
|
Loading…
Reference in New Issue