USB hub serial addresses not showing up ls -l /dev/cu.*

I am running macOS Sonoma and using PlatformIO within Visual Studio Code.

I have multiple STM32 microcontrollers connected via ST-LINKs to a USB hub¹. My ST-LINK USB devices are correctly listed in 1) the USB Device Tree within the macOS System Information, and 2) via Terminal when using st-info --probe.

I am also able to utilise these ST-LINKs to upload code to a single microcontroller individually. Even when all are connected I am able to upload code to one of these microcontrollers.

However, this happens semi-randomly. I cannot specify to which of these connected microcontrollers my code is being uploaded.

I am aware that I need a serial device address to define upload_port in my platformio.ini file. To find this address I am using ls -l /dev/cu.* in the Terminal. But the only port being returned is /dev/cu.Bluetooth-Incoming-Port.

Why isn’t ls -l /dev/cu.* showing the serial addresses of my connected ST-LINK devices? After several days of troubleshooting without any success, I would be very grateful for any insights or suggestions that could help resolve this issue!


1= Anker 4-Port Ultra-Slim USB 3.0 Hub

Well, thanks to the gethla tool on GitHub by a-v-s, and after rewriting that script to have it fully functional on macOS, I realised a different and even simpler method:

  1. Use the shell command st-info --probe to list all connected stlink programmers. When having 3 devices connected you’ll see an output like the following:
    Found 3 STLINK programmers
    1.
      version:    V2J37S7
      serial:     420062000E0000543233574E
      flash:      524288 (pagesize: 16384)
      sram:       131072
      chipid:     0x0431
      descr:      stm32f411re
    2.
      version:    V2J43S7
      serial:     39005700180000344159544E
      flash:      524288 (pagesize: 16384)
      sram:       131072
      chipid:     0x0431
      descr:      stm32f411re
    3.
      version:    V2J43S7
      serial:     18002300020000304131574E
      flash:      524288 (pagesize: 16384)
      sram:       131072
      chipid:     0x0431
      descr:      stm32f411re
  1. Then, integrate the device’s serial number into your platformio.ini file using the following line:

upload_flags = -c adapter serial <serial>

  1. And this made it work for me! :partying_face: