Page 3 of 4

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 5:22 pm
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

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 5:59 pm
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

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 6:09 pm
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

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 7:31 pm
by Giovanni
Exactly there...

Fixed, now it should be OK.

Giovanni

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 7:57 pm
by ErikZalm
Thanks,

It works ok now.

Erik

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 9:50 pm
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

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Wed Jun 13, 2012 10:26 pm
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

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Thu Jun 14, 2012 1:01 am
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"

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Thu Jun 14, 2012 7:33 am
by Giovanni
indigos wrote:the usb driver, is it ready also for other applications?


Yes, only support for isochronous endpoints is missing.

Giovanni

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Posted: Thu Jun 14, 2012 10:41 am
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