Sat Apr 18 09:54:39 EDT 2020

Distinguishing stm programmers by serial number

The USB strings are different:

[3021786.406034] usb 4- SerialNumber: QÿqI\xffffffc2\xffffff89IR@0\xffffffc2\xffffff87
[3021789.733476] usb 4- SerialNumber: SÿqQ\xffffffc2\xffffff88Q@g

So I guess I need to pass that in somehow...

Bus 004 Device 011: ID 0483:3748 STMicroelectronics ST-LINK/V2
Bus 004 Device 009: ID 0483:3748 STMicroelectronics ST-LINK/V2

# lsusb -s 4:11 -v

Starting OpenOCD gives this status line:

Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748

which is printed in

./src/jtag/drivers/stlink_usb.c:1087:	LOG_INFO("STLINK %s (API v%d) VID:PID %04X:%04X",

Also see stlink_usb_get_alternate_serial in that file.

In jtag_libusb_open, the alternate serial is only requested if serial is non-NULL:

		if (serial != NULL &&
				!jtag_libusb_match_serial(libusb_handle, &dev_desc, serial, adapter_get_alternate_serial)) {
			serial_mismatch = true;

Ok so to do this in stock openocd:
1. set the serial to something that won't match
2. enable debug messages


		LOG_DEBUG("Device alternate serial number '%s' doesn't match requested serial '%s'",
				alternate_serial, serial);


ok now knowing how to look, this is what turns up:


I modified this so it is LOG_INFO.

I did notice a problem with the device.  Something the serial number doesn't show up properly:

Info : Device alternate serial number '303030303030303030303031' doesn't match requested serial 'wrong_serial'
Info : Device alternate serial number '53FF71065188515408400567' doesn't match requested serial 'wrong_serial'

Sometimes it just does that apparently...

  iSerial                 3 000000000001

Power cycling resolves it.

stlink.cfg mentions issues with reset:

ST-LINK/V2 firmware version >= V2.J21.S4 recommended to avoid issues
with adapter serial number reset issues.

How can I see firmware version?

ST hast tool to upgrade firmware:

But the website seems broken.  Link is gone after accepting license
agreement and logging in.