texane/stlink — Issue #15: Usage documentation incorrect for ST-LINK/V2
Author: philpem
Created: 2011-10-20 15:22:55+00:00
State: open

It seems the documentation is incorrect for ST-Link/V2 type boards, e.g. the STM32L-Discovery.

When I run 'st-link', the sg devices are enumerated (/dev/sg0 thru sg2 on my machine), then st-link exits with this error:

philpem@ryoko:~/stm32/stlink$ ./gdbserver/st-util

*** stlink_open [/dev/sg0] ***
Error: the device /dev/sg0 is not a stlink
VID: got 46d2 expect 0483
PID: got 8800 expect 3744

*** stlink_open [/dev/sg1] ***
Error: the device /dev/sg1 is not a stlink
VID: got ff13 expect 0483
PID: got 0d23 expect 3744

*** stlink_open [/dev/sg2] ***
Error: the device /dev/sg2 is not a stlink
VID: got ff41 expect 0483
PID: got 2b50 expect 3744

Number of /dev/sgX devices found: 3
ST-LINK not found

After examining the code, it appears that st-link will not open ST-LINK/V2 devices unless argc == 3, i.e. the following command will work:

philpem@ryoko:~/stm32/stlink/gdbserver$ ./st-util port usb
stlink current mode: mass
*** looking up stlink version
st vid = 0x0483 (expect 0x0483)
stlink pid = 0x3748
stlink version = 0x2
jtag version = 0xe
swim version = 0x0
notice: the firmware doesn't support a swim interface
stlink current mode: mass
stlink current mode: mass

*** stlink_enter_swd_mode ***

*** stlink_read_mem32 ***
data_len = 4 0x4
16 64 18 10

*** stlink_core_id ***
data_len = 4 0x4
77 14 a0 2b

core_id = 0x2ba01477
Chip ID is 00006416, Core ID is 2ba01477.
Device connected: L1 Med-density device
Device parameters: SRAM: 0x4000 bytes, Flash: up to 0x20000 bytes in pages of 0x100 bytes

(and so on, and so forth).

It appears that either the documentation needs updating, or the command line parsing code modifying to match the documentation.