Showing results for 
Search instead for 
Did you mean: 

Is there any CLI Command to get the COM Port number of my ST-Link device from it's SN ?

Associate II

I executed this command : STM32_Programmer_CLI.exe -c port=SWD sn=xxxxxxxxx232xxxxxxxxxxxx and got the response that gave me details about the device, but not COM Port. Is there any command that gives me the COM Port number to which my device is connected ? I know about the "-l uart" command. any other command than that ? Thanks in advance.


ST Employee

Hello @shiwasreet

Could you clarify your request please ? I could get the port associated with the ST-LINK SN using -l command, here's an example output below.

C:\Users\briguiah>STM32_Programmer_CLI -l
                       STM32CubeProgrammer v2.16.0

=====  DFU Interface   =====

No STM32 device in DFU mode connected

===== J-Link Interface =====
Error: No J-link probe detected.
===== STLink Interface =====

-------- Connected ST-LINK Probes List --------

ST-Link Probe 0 :
   ST-LINK SN  : 002B00213037510B35333131
   ST-LINK FW  : V3J13M4B5S1
   Access Port Number  : 0
   Board Name  : STLINK-V3SET

=====  UART Interface  =====

Total number of serial ports available: 1

Board Name  : STLINK-V3SET
ST-LINK SN: 002B00213037510B35333131
Port: COM129
Location: \\.\COM129
Description: STMicroelectronics STLink Virtual COM Port
Manufacturer: STMicroelectronics


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hey Aziz, thanks for your reply. As I've already mentioned in my question, i've already tried the "-l uart" command, it gives information about all the connected probes. I have more than 50 devices connected to my computer, so that command isn't really reliable for me, however i can parse that command line output and get the COM Port. Hence, i was looking for some specific command which gives me the specific COM Port Name based on my ST-Link Device Serial Number. Anyways, thanks.

Hi Aziz, I don't see a way to delete this comment, but after more testing, it appears to be a different issue so I'm deleting the text of this comment and started a new post about the underlying issue (STM32_Programmer_CLI fails to detect UARTs unless STLink is also connected).

Separate issue: none of my STLinkV3s enumerate in the STLink Probes list. You can see an MINIE in the UART list below at COM14. I suspect I need to update the driver, but the driver download link on the ST site is currently broken.  <sigh>.