ChibiOS/testhal/STM32F4xx/USB_CDC

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

Hi,

I think it is fixed now, queues are now reinitialized after each reset. The driver also received optimizations to the data copy routines, it should be much faster now.

Giovanni
ErikZalm
Posts: 10
Joined: Fri May 11, 2012 9:10 pm

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by ErikZalm »

Hello Giovanni,

I found 2 problems with the driver.
1. On OSX and a vmware virtual machine the enumeration fails. The address needs to be reset to 0 in usb_lld_reset().
( OTG->DCFG = (OTG->DCFG & ~DCFG_DAD_MASK) | DCFG_DAD(0); )

2. When I use termite as terminal program (In windows XP) the commands are send in 1 buffer. Only the first character is recognized.

When I use a normal terminal program it works perfectly.

Best regards,

Erik
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

Hi,

Fixed the device address initialization, I thought it was automatic on reset...

I am looking into the other issue, it looks like there are problems with large incoming packets, probably a problem in the function that fills the input queue.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

Exactly there...

Fixed, now it should be OK.

Giovanni
ErikZalm
Posts: 10
Joined: Fri May 11, 2012 9:10 pm

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by ErikZalm »

Thanks,

It works ok now.

Erik
indigos
Posts: 14
Joined: Sat Jun 02, 2012 10:46 am

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by indigos »

Hi Giovanni,

the usb driver, is it ready also for other applications?
For example: device usb hid (mouse or keyboard, or host usb hid attach a mouse or keyboard. device/host msd.

Thank you

EDIT
wrong word device usb not driver usb
Last edited by indigos on Thu Jun 14, 2012 12:50 am, edited 1 time in total.
User avatar
Badger
Posts: 346
Joined: Mon Apr 18, 2011 6:07 pm

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Badger »

I'm testing this out on Ubuntu.

Upon inserting, the device enumerates and lsusb gives this output:

Code: Select all

Bus 001 Device 016: ID 0483:5740 SGS Thomson Microelectronics 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0483 SGS Thomson Microelectronics
  idProduct          0x5740
  bcdDevice            2.00
  iManufacturer           1 STMicroelectronics
  iProduct                2 ChibiOS/RT Virtual COM Port
  iSerial                 3 250
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           67
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval             255
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0
      iInterface              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
      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
Device Status:     0x0001
  Self Powered


ubuntu sets the device as /dev/ttyACM0

Code: Select all

[ 2982.024285] usb 1-1.5.1.4: new full-speed USB device number 17 using ehci_hcd
[ 2982.118113] cdc_acm 1-1.5.1.4:1.0: This device cannot do calls on its own. It is not a modem.
[ 2982.118139] cdc_acm 1-1.5.1.4:1.0: ttyACM0: USB ACM device


The default udev rules seem to prohibit accessing it as a normal user. but as root it worked:

Code: Select all

sudo screen /dev/ttyACM0


the shell seemed to work.

Now to try it on my own boards!

edit: tried it and it works! http://www.youtube.com/watch?v=UareDFcnZTY&feature=plcp
indigos
Posts: 14
Joined: Sat Jun 02, 2012 10:46 am

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by indigos »

Badger wrote:The default udev rules seem to prohibit accessing it as a normal user. but as root it worked:

Code: Select all

sudo screen /dev/ttyACM0


the shell seemed to work.
On my linux I wrote a simple udev rule.
file /etc/udev/rules.d/99-usbdevice.rules

Code: Select all

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0666"

So all usb devices are writable by all users. Maybe it isn't very good for security but works.
You can restrict also to a single device:

Code: Select all

SUBSYSTEM=="usb_device", ATTR{idVendor}=="0483", ATTR{idProduct}=="5740", MODE="666"

or only to your username

Code: Select all

SUBSYSTEM=="usb_device", ATTR{idVendor}=="0483", ATTR{idProduct}=="5740", OWNER="<your username>", MODE="600"

or only to group

Code: Select all

SUBSYSTEM=="usb_device", ATTR{idVendor}=="0483", ATTR{idProduct}=="5740", GROUP="<group of users>", MODE="660"
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

indigos wrote:the usb driver, is it ready also for other applications?


Yes, only support for isochronous endpoints is missing.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Tectu »

I don't think that I should open a new thread for this ontopic, one answer question:

I've never cared about USB before. Is there now any working example, which demonstrates how to use the USB driver of ChibiOS to do some stuff like USB HID or something else?
Maybe someone also got a linux-side example showing how to use the new /dev device?


~ Tectu
Post Reply