Search code examples
linuxstm32ttyusbserialusart

STM32F0-Discovery: no tty


I am currently trying to send data to my STM32F0308 board via USART. The data is supposed to be sent by a Python script using PySerial.

However, when I plug in the board, I cannot find the corresponding /dev/ttyXXXX.

The board is branched and I can flash code on it (STLink via USB), but there is no port visible.

dmesg shows that the computer is aware of the board:

[10364.101554] usb 1-3: USB disconnect, device number 10
[10368.044231] usb 1-3: new full-speed USB device number 12 using xhci_hcd
[10368.173948] usb 1-3: New USB device found, idVendor=0483, idProduct=3748
[10368.173956] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[10368.173959] usb 1-3: Product: STM32 STLink
[10368.173962] usb 1-3: Manufacturer: STMicroelectronics
[10368.173965] usb 1-3: SerialNumber: VÿnIxRT68\xffffffc2\xffffff87

Here is the output of lsusb:

Bus 001 Device 012: ID 0483:3748 STMicroelectronics ST-LINK/V2

Here's the output of ls /dev/tty*:

tty    tty12  tty17  tty21  tty26  tty30  tty35  tty4   tty44  tty49  tty53  tty58  tty62  ttyprintk  ttyS12  ttyS17  ttyS21  ttyS26  ttyS30  ttyS7
tty0   tty13  tty18  tty22  tty27  tty31  tty36  tty40  tty45  tty5   tty54  tty59  tty63  ttyS0      ttyS13  ttyS18  ttyS22  ttyS27  ttyS31  ttyS8
tty1   tty14  tty19  tty23  tty28  tty32  tty37  tty41  tty46  tty50  tty55  tty6   tty7   ttyS1      ttyS14  ttyS19  ttyS23  ttyS28  ttyS4   ttyS9
tty10  tty15  tty2   tty24  tty29  tty33  tty38  tty42  tty47  tty51  tty56  tty60  tty8   ttyS10     ttyS15  ttyS2   ttyS24  ttyS29  ttyS5
tty11  tty16  tty20  tty25  tty3   tty34  tty39  tty43  tty48  tty52  tty57  tty61  tty9   ttyS11     ttyS16  ttyS20  ttyS25  ttyS3   ttyS6

And here is my the function to initialize the serial port:

#function to initialize the serial port
def init_serial():
    global ser    #must be declared in each function
    #set serial: port, baudrate, timeout (port does not hang)
    ser = serial.Serial(port="/dev/ttyS3", baudrate=9600, timeout=5)
    if ser.isOpen():
        ser.close()
    #open the serial port
    ser.open()          
    #print: port is open or closed
    if ser.isOpen():
        print("Port open: " + ser.portstr)
    else:
        print("Port not open: We have a problem!")
#function ends here

I am using Ubuntu 15.04, but it also did not work on another computer using Debian. According to ST, the STM32F0x0 line supports USB.

Edit: As requested, the output of lsusb -v:

Bus 001 Device 003: ID 0483:3748 STMicroelectronics ST-LINK/V2
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0483 STMicroelectronics
  idProduct          0x3748 ST-LINK/V2
  bcdDevice            1.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    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 
      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

Solution

  • The device gets discovered and it's a ST-Link debug interface.

    The STM32F0308-Discovery does not have a USB UART interface and the ST-Link does not include UART functionality as far as I can see. What you are trying to do appears to be impossible without extra hardware. You would have to get one of those USB UART interfaces with separate connectors and wire it up to the USART pins exposed on the headers.