Merge pull request #943 from grevaillot/to_merge/probe_unconnected_target

handle probed STlink programmer with unconnected target properly
pull/960/head
nightwalker-87 2020-04-21 15:42:27 +02:00 zatwierdzone przez GitHub
commit 60be843f00
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 27 dodań i 17 usunięć

Wyświetl plik

@ -234,7 +234,14 @@ int main(int argc, char** argv) {
printf("st-util %s\n", STLINK_VERSION);
sl = do_connect(&state);
if (sl == NULL) return 1;
if (sl == NULL) {
return 1;
}
if (sl->chip_id == STLINK_CHIPID_UNKNOWN) {
ELOG("Unsupported Target (Chip ID is %#010x, Core ID is %#010x).\n", sl->chip_id, sl->core_id);
return 1;
}
connected_stlink = sl;
signal(SIGINT, &cleanup);
@ -245,10 +252,7 @@ int main(int argc, char** argv) {
stlink_reset(sl);
}
// This is low-level information for debugging, not useful for normal use.
// So: Demoted to a debug meesage. -- REW
DLOG("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id);
DLOG("Chip ID is %#010x, Core ID is %#08x.\n", sl->chip_id, sl->core_id);
sl->verbose=0;
current_memory_map = make_memory_map(sl);
@ -1852,7 +1856,8 @@ int serve(stlink_t *sl, st_state_t *st) {
stlink_close(sl);
sl = do_connect(st);
if (sl == NULL) cleanup(0);
if (sl == NULL || sl->chip_id == STLINK_CHIPID_UNKNOWN)
cleanup(0);
connected_stlink = sl;
if (st->reset) {

Wyświetl plik

@ -59,8 +59,14 @@ int main(int ac, char** av)
sl = stlink_open_usb(o.log_level, 1, (char *)o.serial);
if (sl == NULL)
if (sl == NULL) {
return -1;
}
if (sl->flash_type == STLINK_FLASH_TYPE_UNKNOWN) {
printf("Failed to connect to target\n");
return -1;
}
if ( o.flash_size != 0u && o.flash_size != sl->flash_size ) {
sl->flash_size = o.flash_size;

Wyświetl plik

@ -1045,7 +1045,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST
stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR);
if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) {
stlink_enter_swd_mode(sl);
stlink_enter_swd_mode(sl);
}
if (reset) {
@ -1054,11 +1054,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST
usleep(10000);
}
ret = stlink_load_device_params(sl);
if (ret == -1) {
// This one didn't have any message.
goto on_libusb_error;
}
stlink_load_device_params(sl);
return sl;
on_libusb_error:
@ -1133,9 +1130,9 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
ret = libusb_open(dev, &handle);
if (ret < 0) {
if (ret == LIBUSB_ERROR_ACCESS) {
WLOG("failed to open USB device (LIBUSB_ERROR_ACCESS), try running as root?\n");
} else {
WLOG("failed to open USB device (libusb error: %d)\n", ret);
ELOG("Could not open USB device %#06x:%#06x, access error.\n", desc.idVendor, desc.idProduct, ret);
} else {
ELOG("Failed to open USB device %#06x:%#06x, libusb error: %d)\n", desc.idVendor, desc.idProduct, ret);
}
break;
}
@ -1149,8 +1146,10 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
}
stlink_t *sl = stlink_open_usb(0, 1, serial);
if (!sl)
if (!sl) {
ELOG("Failed to open USB device %#06x:%#06x\n", desc.idVendor, desc.idProduct);
continue;
}
_sldevs[slcur++] = sl;
}