Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove device names, we now just find it via USB ids.

In the future, we might actually want device names back again, if you have multiple stlink's
connected.  But that would be a new device name, not scanning for /dev/sgX looking for scsi
devices.
  • Loading branch information...
commit 0f376a74a51cf3e3134b0e6f2ad0415f43968ed1 1 parent 8749039
@karlp karlp authored
View
38 gdbserver/gdb-server.c
@@ -197,42 +197,8 @@ int main(int argc, char** argv) {
if(sl == NULL) return 1;
break;
case 1:
- if (strlen(state.devicename) == 0) {
- const int DevNumMax = 99;
- int ExistDevCount = 0;
-
- for (int DevNum = 0; DevNum <= DevNumMax; DevNum++) {
- if (DevNum < 10) {
- char DevName[] = "/dev/sgX";
- const int X_index = 7;
- DevName[X_index] = DevNum + '0';
- if (!access(DevName, F_OK)) {
- sl = stlink_v1_open(DevName, 0);
- ExistDevCount++;
- }
- } else if (DevNum < 100) {
- char DevName[] = "/dev/sgXY";
- const int X_index = 7;
- const int Y_index = 8;
- DevName[X_index] = DevNum / 10 + '0';
- DevName[Y_index] = DevNum % 10 + '0';
- if (!access(DevName, F_OK)) {
- sl = stlink_v1_open(DevName, 0);
- ExistDevCount++;
- }
- }
- if (sl != NULL) break;
- }
-
- if (sl == NULL) {
- fprintf(stdout, "\nNumber of /dev/sgX devices found: %i \n",
- ExistDevCount);
- fprintf(stderr, "ST-LINK not found\n");
- return 1;
- }
- } else {
- sl = stlink_v1_open(state.devicename, state.logging_level);
- }
+ sl = stlink_v1_open(NULL, state.logging_level);
+ if(sl == NULL) return 1;
break;
}
View
18 src/stlink-sg.c
@@ -967,8 +967,7 @@ stlink_backend_t _stlink_sg_backend = {
_stlink_sg_force_debug
};
-static stlink_t* stlink_open(const char *dev_name, const int verbose) {
- DLOG("*** stlink_open [%s] ***\n", dev_name);
+static stlink_t* stlink_open(const int verbose) {
stlink_t *sl = malloc(sizeof (stlink_t));
struct stlink_libsg *slsg = malloc(sizeof (struct stlink_libsg));
@@ -1076,24 +1075,19 @@ static stlink_t* stlink_open(const char *dev_name, const int verbose) {
-stlink_t* stlink_v1_open(const char *dev_name, const int verbose) {
+stlink_t* stlink_v1_open(const int verbose) {
ugly_init(verbose);
- stlink_t *sl = stlink_open(dev_name, verbose);
+ stlink_t *sl = stlink_open(verbose);
if (sl == NULL) {
fputs("Error: could not open stlink device\n", stderr);
return NULL;
}
stlink_version(sl);
- struct stlink_libsg *sg = sl->backend_data;
if ((sl->version.st_vid != USB_ST_VID) || (sl->version.stlink_pid != USB_STLINK_PID)) {
- fprintf(stderr, "Error: the device %s is not a stlink\n",
- dev_name);
- fprintf(stderr, " VID: got %04x expect %04x \n",
- sl->version.st_vid, USB_ST_VID);
- fprintf(stderr, " PID: got %04x expect %04x \n",
- sl->version.stlink_pid, USB_STLINK_PID);
+ ugly_log(UERROR, LOG_TAG,
+ "WTF? successfully opened, but unable to read version details. BROKEN!\n");
return NULL;
}
@@ -1116,7 +1110,7 @@ stlink_t* stlink_v1_open(const char *dev_name, const int verbose) {
delay(5000);
DLOG("Attempting to reopen the stlink...\n");
- sl = stlink_open(dev_name, verbose);
+ sl = stlink_open(verbose);
if (sl == NULL) {
fputs("Error: could not open stlink device\n", stderr);
return NULL;
View
3  src/stlink-sg.h
@@ -57,12 +57,13 @@ extern "C" {
uint32_t q_addr;
// Sense (error information) data
+ // obsolete, this was fed to the scsi tools
unsigned char sense_buf[SENSE_BUF_LEN];
reg reg;
};
- stlink_t* stlink_v1_open(const char *dev_name, const int verbose);
+ stlink_t* stlink_v1_open(const int verbose);
#ifdef __cplusplus
}
View
21 src/test_sg.c
@@ -10,33 +10,26 @@
int main(int argc, char *argv[]) {
// set scpi lib debug level: 0 for no debug info, 10 for lots
- char *dev_name;
switch (argc) {
case 1:
fputs(
- "\nUsage: stlink-access-test /dev/sg0, sg1, ...\n"
+ "\nUsage: stlink-access-test [anything at all] ...\n"
"\n*** Notice: The stlink firmware violates the USB standard.\n"
- "*** If you plug-in the discovery's stlink, wait a several\n"
- "*** minutes to let the kernel driver swallow the broken device.\n"
- "*** Watch:\ntail -f /var/log/messages\n"
- "*** This command sequence can shorten the waiting time and fix some issues.\n"
+ "*** Because we just use libusb, we can just tell the kernel's\n"
+ "*** driver to simply ignore the device...\n"
"*** Unplug the stlink and execute once as root:\n"
- "modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:lrwsro\n\n",
+ "modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i\n\n",
stderr);
return EXIT_FAILURE;
- case 2:
- dev_name = argv[1];
- break;
default:
- fprintf(stderr, "bzzt\n");
- return EXIT_FAILURE;
+ break;
}
- stlink_t *sl = stlink_v1_open(dev_name, 99);
+ stlink_t *sl = stlink_v1_open(99);
if (sl == NULL)
return EXIT_FAILURE;
-
+
// we are in mass mode, go to swd
stlink_enter_swd_mode(sl);
stlink_current_mode(sl);
Please sign in to comment.
Something went wrong with that request. Please try again.