我正在尝试将 ST-Link v2 程序员列为 tty*。
在
OS: Arch Linux x86_64
Host: Inspiron 7580
Kernel: 5.5.2-arch1-1
插入设备会产生以下输出
journalctl -a
kernel: usb 1-1: new full-speed USB device number 31 using xhci_hcd
kernel: usb 1-1: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: usb 1-1: Product: STM32 STLink
kernel: usb 1-1: Manufacturer: STMicroelectronics
kernel: usb 1-1: SerialNumber: SÿnReIBg
为了
lsusb -v
Bus 001 Device 031: ID 0483:3748 STMicroelectronics ST-LINK/V2
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0483 STMicroelectronics
idProduct 0x3748 ST-LINK/V2
bcdDevice 1.00
iManufacturer 1 STMicroelectronics
iProduct 2 STM32 STLink
iSerial 3 SÿnReIBg
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0027
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 4 ST Link
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
我的 udev 规则idVendor=0483, idProduct=3748
是49-stlinkv2.rules
:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \
MODE:="0666", \
SYMLINK+="stlinkv2_%n"
该设备之前可以在 Ubuntu 上运行。
Nucleo-64 板的嵌入式 ST-Link 被列为ttyACM0
没有问题。工作核板的输出:
journalctl -a
kernel: usb 1-1: new full-speed USB device number 32 using xhci_hcd
kernel: usb 1-1: New USB device found, idVendor=0483, idProduct=374b, bcdDevice= 1.00
kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: usb 1-1: Product: STM32 STLink
kernel: usb 1-1: Manufacturer: STMicroelectronics
kernel: usb 1-1: SerialNumber: 066DFF494849887767073715
kernel: usb-storage 1-1:1.1: USB Mass Storage device detected
kernel: scsi host1: usb-storage 1-1:1.1
kernel: cdc_acm 1-1:1.2: ttyACM0: USB ACM device
kernel: scsi 1:0:0:0: Direct-Access MBED microcontroller 1.0 PQ: 0 ANSI: 2
kernel: sd 1:0:0:0: [sda] 328 512-byte logical blocks: (168 kB/164 KiB)
kernel: sd 1:0:0:0: [sda] Write Protect is off
kernel: sd 1:0:0:0: [sda] Mode Sense: 03 00 00 00
kernel: sd 1:0:0:0: [sda] No Caching mode page found
kernel: sd 1:0:0:0: [sda] Assuming drive cache: write through
kernel: sd 1:0:0:0: [sda] Attached SCSI removable disk
lsusb -v
Bus 001 Device 032: ID 0483:374b STMicroelectronics ST-LINK/V2.1
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x0483 STMicroelectronics
idProduct 0x374b ST-LINK/V2.1
bcdDevice 1.00
iManufacturer 1 STMicroelectronics
iProduct 2 STM32 STLink
iSerial 3 066DFF494849887767073715
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0080
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 300mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 4 ST-Link Debug
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0020 1x 32 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 5 ST-Link mass storage
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 2 Communications
bFunctionSubClass 2 Abstract (modem)
bFunctionProtocol 1 AT-commands (v.25ter)
iFunction 6 ST-Link VCP Ctrl
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2 Communications
bInterfaceSubClass 2 Abstract (modem)
bInterfaceProtocol 1 AT-commands (v.25ter)
iInterface 6 ST-Link VCP Ctrl
CDC Header:
bcdCDC 1.10
CDC Call Management:
bmCapabilities 0x00
bDataInterface 3
CDC ACM:
bmCapabilities 0x06
sends break
line coding and serial state
CDC Union:
bMasterInterface 2
bSlaveInterface 3
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval 255
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10 CDC Data
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 7 ST-Link VCP Data
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
我的 udev 规则idVendor=0483, idProduct=374b
是49-stlinkv2-1.rules
:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374a", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
答案1
我注意到工作设备报告为:
Bus 001 Device 032: ID 0483:374b STMicroelectronics ST-LINK/V2.1
而问题设备被报告为:
Bus 001 Device 031: ID 0483:3748 STMicroelectronics ST-LINK/V2
请参阅本 PDF 第 2 页上的 ST-LINK 版本概述。
Nucleo-64 板中的嵌入式 ST-LINK 是 ST-LINK/V2-1,它具有一些额外的 USB 接口:USB 大容量存储接口和虚拟 COM 端口。后者ttyACMn
在 Linux 中被列为设备。
基本的ST-LINK/V2(没有-1后缀)没有虚拟COM端口,因此没有任何东西可以映射为TTY设备。
上电时,基本 ST-LINK/V2 将处于固件升级模式,并且需要专用命令切换到 STM8 或 STM32 调试模式(取决于加载的固件)。另一方面,ST-LINK/V2-1 及更新版本从已运行的固件开始,需要专用命令才能切换到固件升级模式。
这stlink-tool
公用事业实际上并不使用 TTY 设备,而是使用原始 USB 命令。它使用libusb-1.0
,因此要使用stlink-tool
,您需要确保/dev/bus/usb/*/*
您的用户帐户可以访问相应的原始 USB 设备节点。如果该lsusb
命令将设备报告为Bus 001 Device 031
,则正确的设备节点将/dev/bus/usb/001/031
分别为 。