HS USB (STM32F4) and bulk data

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
SpacedCowboy
Posts: 5
Joined: Fri Oct 18, 2013 9:28 pm

HS USB (STM32F4) and bulk data

Post by SpacedCowboy »

Hi all,

I'm trying to make a VME graphics accelerator for an Atari TT (http://www.atari-forum.com/viewtopic.php?f=27&t=25339 if you're interested) as a hobby project, and am running into trouble with USB.

The STM32F4 is basically implementing a VME-style interface on one end, and a high-speed USB2 interface on the other end, which talks to a PCDuino dev-board, which runs linux and produces an HDMI output. What I need in terms of USB2 is a bulk transport that I can send drawing commands from the TT to the PCDuino. There's a readback channel as well, but let's not get ahead of ourselves. The VME bus can sustain 20 MBytes/sec, so it needs to be high-speed USB.

I've got Chibios up and running on my Wavefront board, can blink LEDs etc, and I'm patched up with the code at http://sourceforge.net/p/chibios/bugs/377 , but the only USB event I'm getting sent is USB_EVENT_RESET. I was more or less working from the demo code included with the above patch.

I can post code if necessary, but at the moment I'm wondering if there's just some configuration option I may need to set that I'm missing. I've been over the descriptors, and they (to my untutored eye) look ok:

(Device descriptor)

Code: Select all

/******************************************************************************\
|* USB Device Descriptor
\******************************************************************************/
static const uint8_t _usbDevDescData[18] =
   {
   USB_DESC_DEVICE      (0x0200,        // bcdUSB USB version:
                                        //  0x0100 (USB1.0)
                                        //  0x0110 (USB1.1)
                                        //  0x0200 (USB2.0)
                         0xFF,          // bDeviceClass (FF=Vendor specific)
                         0x00,          // bDeviceSubClass.
                         0x00,          // bDeviceProtocol.
                         0x40,          // bMaxPacketSize.
                         0x0483,        // idVendor (ST).
                         0x5417,        // idProduct.
                         0x0001,        // bcdDevice Device Release Number
                         1,             // iManufacturer
                         2,             // iProduct.
                         3,             // iSerialNumber.
                         1)             // bNumConfigurations.
   };


Config/Endpoint descriptors

Code: Select all

/******************************************************************************\
|* Configuration Descriptor
\******************************************************************************/
static const uint8_t _usbCfgDescData[9+9+7+7] =
   {
   // Configuration descriptor - 9 Bytes
   USB_DESC_CONFIGURATION(sizeof _usbCfgDescData,   // wTotalLength
                           0x01,                   // bNumInterfaces
                           0x01,                   // bConfigurationValue
                           0,                      // iConfiguration
                           0xC0,                   // self-powered
                           50),                    // bMaxPower (100mA)

    // Interface Descriptor - 9 Bytes
    USB_DESC_INTERFACE (0x00,          // bInterfaceNumber.
                        0x00,          // bAlternateSetting.
                        0x02,          // bNumEndpoints.
                        0xFF,          // bInterfaceClass (VendorSpecific)
                        0x00,          // bInterfaceSubClass
                        0x50,          // bInterfaceProtocol (bulk only)
                        0),            // iInterface.

   // Endpoint 1 Descriptor, Direction in - 7 Bytes
   USB_DESC_ENDPOINT (EP_IN|USB_RTYPE_DIR_DEV2HOST,   // bEndpointAddress
                       0x02,                            // bmAttributes (Bulk)
                       IN_PACKETSIZE,                   // wMaxPacketSize
                       0x00),                           // bInterval

   // Endpoint 2 Descriptor Direction out - 7 Bytes
   USB_DESC_ENDPOINT (EP_OUT|USB_RTYPE_DIR_HOST2DEV,   // bEndpointAddress
                       0x02,                            // bmAttributes (Bulk)
                       OUT_PACKETSIZE,                  // wMaxPacketSize
                       0x00)                            // bInterval
   };


Any help very gratefully received :)

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

Re: HS USB (STM32F4) and bulk data

Post by Giovanni »

ChibiOS has been initially developed on an Atari ST :)

Are USB-related pins configured correctly in board.h? is the OTG clock 48mhz?

Giovanni
SpacedCowboy
Posts: 5
Joined: Fri Oct 18, 2013 9:28 pm

Re: HS USB (STM32F4) and bulk data

Post by SpacedCowboy »

Giovanni wrote:ChibiOS has been initially developed on an Atari ST :)

[grin] I did not know that :) Sometimes, sitting in front of my 12-core Mac, it seems I could still do the things I needed to a lot faster on the old ST that I had at college... :)

Giovanni wrote:Are USB-related pins configured correctly in board.h? is the OTG clock 48mhz?

Giovanni


Yep - at least I think so. The ULPI serial port demo works fine, and mcuconf.h sets STM32_CLOCK48_REQUIRED ...

Code: Select all

   #define STM32_NO_INIT                       FALSE
   #define STM32_HSI_ENABLED                   TRUE
   #define STM32_LSI_ENABLED                   TRUE
   #define STM32_HSE_ENABLED                   TRUE
   #define STM32_LSE_ENABLED                   FALSE
   #define STM32_CLOCK48_REQUIRED              TRUE
   #define STM32_SW                            STM32_SW_PLL
   #define STM32_PLLSRC                        STM32_PLLSRC_HSE
   #define STM32_PLLM_VALUE                    8
   #define STM32_PLLN_VALUE                    336
   #define STM32_PLLP_VALUE                    2
   #define STM32_PLLQ_VALUE                    7
   #define STM32_HPRE                          STM32_HPRE_DIV1
   #define STM32_PPRE1                         STM32_PPRE1_DIV4
   #define STM32_PPRE2                         STM32_PPRE2_DIV2
   #define STM32_RTCSEL                        STM32_RTCSEL_LSI
   #define STM32_RTCPRE_VALUE                  8
   #define STM32_MCO1SEL                       STM32_MCO1SEL_HSI
   #define STM32_MCO1PRE                       STM32_MCO1PRE_DIV1
   #define STM32_MCO2SEL                       STM32_MCO2SEL_SYSCLK
   #define STM32_MCO2PRE                       STM32_MCO2PRE_DIV5
   #define STM32_I2SSRC                        STM32_I2SSRC_CKIN
   #define STM32_PLLI2SN_VALUE                 192
   #define STM32_PLLI2SR_VALUE                 5
   #define STM32_VOS                           STM32_VOS_HIGH
   #define STM32_PVD_ENABLE                    FALSE
   #define STM32_PLS                           STM32_PLS_LEV0
     ...
   #define STM32_USB_USE_OTG1                  FALSE
   #define STM32_USB_USE_OTG2                  TRUE
   #define STM32_USE_USB_OTG2_HS               TRUE
   #define STM32_USE_USB_OTG2_ULPI             TRUE


One other thing worth mentioning is that the USB prober app on the Mac can't find the device that the STM32F4 is pretending to be (STM vendor, 0x5417 device). At least, if I run /Developer/Applications/Utilities/USB\ Prober.app it doesn't show up.

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

Re: HS USB (STM32F4) and bulk data

Post by Giovanni »

If the ULPI demo works then the setup should be correct. Do the actual endpoint numbers match with those in the descriptors?

You may install a SW USB analyzer and see what is going on during enumeration, an HW analyzer would be even better.

Giovanni
Post Reply