Skip to content

Commit

Permalink
Add support for the STLink-2.1 when flash with no mass storage
Browse files Browse the repository at this point in the history
Since STLink 2.33.25, it is possible to flash the STLink in two modes:
- STM32 Debug + VCP
- STM32 Debug + Mass storage + VCP

When flashed in the first mode, the device id changes, but the behaviour
remains the same.
This commit thus introduces support for this new device id.
  • Loading branch information
pinaraf committed Feb 14, 2020
1 parent 2d8d4dc commit 326ec19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/stlink/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern "C" {
#define STLINK_USB_PID_STLINK_32L 0x3748
#define STLINK_USB_PID_STLINK_32L_AUDIO 0x374a
#define STLINK_USB_PID_STLINK_NUCLEO 0x374b
#define STLINK_USB_PID_STLINK_NO_UMS 0x3752

#define STLINK_SG_SIZE 31
#define STLINK_CMD_SIZE 16
Expand Down
11 changes: 9 additions & 2 deletions src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,10 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST
}
}

if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO)) {
if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) ||
(desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) ||
(desc.idProduct == STLINK_USB_PID_STLINK_NO_UMS) ||
(desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO)) {
struct libusb_device_handle *handle;

ret = libusb_open(list[cnt], &handle);
Expand All @@ -846,6 +849,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST

if (memcmp(serial, &sl->serial, sl->serial_size) == 0)
break;
else
WLOG("Invalid serial %s VS %s\n", serial, &sl->serial);

continue;
}
Expand Down Expand Up @@ -901,7 +906,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST

// TODO - could use the scanning techniq from stm8 code here...
slu->ep_rep = 1 /* ep rep */ | LIBUSB_ENDPOINT_IN;
if (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO || desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) {
if (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO || desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO || desc.idProduct == STLINK_USB_PID_STLINK_NO_UMS) {
slu->ep_req = 1 /* ep req */ | LIBUSB_ENDPOINT_OUT;
} else {
slu->ep_req = 2 /* ep req */ | LIBUSB_ENDPOINT_OUT;
Expand Down Expand Up @@ -974,6 +979,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {

if (desc.idProduct != STLINK_USB_PID_STLINK_32L &&
desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO &&
desc.idProduct != STLINK_USB_PID_STLINK_NO_UMS &&
desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO)
continue;

Expand All @@ -999,6 +1005,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {

if (desc.idProduct != STLINK_USB_PID_STLINK_32L &&
desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO &&
desc.idProduct != STLINK_USB_PID_STLINK_NO_UMS &&
desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO)
continue;

Expand Down

0 comments on commit 326ec19

Please sign in to comment.