Arch-Linux
USB 設備未列為 tty*
我正在嘗試將 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"
我注意到工作設備報告為:
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
分別為。