- **status**: new --> closed
- **Comment**:

closed due to no recent activity - please reopen if this is still an issue.



---

** [tickets:#110] STLINK serial numbers with multiple adaptors on same PC**

**Status:** closed
**Milestone:** 0.9.0
**Labels:** stlink 
**Created:** Wed Oct 21, 2015 12:39 PM UTC by Michael James
**Last Updated:** Wed Oct 21, 2015 12:39 PM UTC
**Owner:** nobody
**Attachments:**

- 
[stlink-serial-gibberish.patch](https://sourceforge.net/p/openocd/tickets/110/attachment/stlink-serial-gibberish.patch)
 (2.0 kB; application/octet-stream)


OpenOCD 0.9.0 with STLINK does not handle serial numbers very well. These 
serial numbers are binary derived from an internal unique 96 bit CPU serial ID 
number.
They may contain 0x00 bytes WITHIN the serial numbers not only at the end of an 
ASCII string like other USB serial numbers.  So using strncmp() as in OpenOCD 
code  fails anyway by  assuming that they are pure ASCII

The command hla_serial allows the user to define the serial numbers using 
escape sequences. 
However the printing of the device serial numbers from within OpenOCD with 
debug level 3 does not allow the user to determine the correct string to enter 
into the hla_serial command. If you are French and using a French language 
Windows envirionment, for example, characters can be mapped so that it is 
impossible to determine the correct string to use ... 

What I did was I changed the code, so that the serial number is printed out in 
the escaped form if a match is not found 

as in attached patchfile.

While this may not be the best way to do it , it is useful  


Here is a debug trace with my patch - 

Line 259 shows usual STLINK junk serial number - this is the user input from 
hla_serial command..
Line 260,261 shows diagnostics from opening each device. 

It can be seen from this that the correct commands are 

"hla_serial S?r\x06exUU\x128\x04g"
for the first adapter and
"hla_serial S?p\x06exUUR7\x18g"
for the second adapter 

In my example I deliberately garbled the hla_serial argument to make it 
enumerate all the serial numbers. 


Debug: 258 104 stlink_usb.c:1602 stlink_usb_open(): stlink_usb_open
Debug: 259 104 stlink_usb.c:1619 stlink_usb_open(): transport: 1 vid: 0x0483 
pid: 0x3748 serial: Sa?pexUUR7g
Debug: 260 160 libusb1_common.c:111 string_descriptor_equal(): Device serial 
number 'S?r\x06exUU\x128\x04g' doesn't match requested serial 
'Sa?p\x06exUUR7\x18'
Debug: 261 162 libusb1_common.c:111 string_descriptor_equal(): Device serial 
number 'S?p\x06exUUR7\x18g' doesn't match requested serial 'Sa?p\x06exUUR7\x18'
Error: 262 163 stlink_usb.c:1632 stlink_usb_open(): open failed



---

Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to