cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery __ALIGN_BEGIN USB_OTG_CORE_HANDLE Problem

kruszi
Associate II
Posted on February 10, 2013 at 13:01

Hi,

I am working with  CooCox IDE an this USB project https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/DispForm.aspx?ID=1311 pulled from the STe2eCommunity. I had to add #include ''stm32f4xx_conf.h'' to several files and replace the startup_stm32f4xx.s (from the original Attolic-IDE code) by the startup_stm32f4xx.c from CooCox. Now the project is built successfully with following warnings: (not complete but) only regarding usbd_desc.c and usbd_req.h an all about differing  signedness of arguments for USBD_GetString.

 [cc] C:\CooCox\CoIDE\workspace\usb_2\K2_QUELLE\stm32f4-discovery-usb-cdc-example\stm32f4-discovery-usb-cdc-example\src\usbd_desc.c: In function 'USBD_USR_ProductStrDescriptor':

       [cc] C:\CooCox\CoIDE\workspace\usb_2\K2_QUELLE\stm32f4-discovery-usb-cdc-example\stm32f4-discovery-usb-cdc-example\src\usbd_desc.c:219:5: warning: pointer targets in passing argument 1 of 'USBD_GetString' differ in signedness [-Wpointer-sign]

       [cc] In file included from C:\CooCox\CoIDE\workspace\usb_2\K2_QUELLE\stm32f4-discovery-usb-cdc-example\stm32f4-discovery-usb-cdc-example\src\usbd_desc.c:25:0:

       [cc] C:\CooCox\CoIDE\workspace\usb_2\K2_QUELLE\stm32f4-discovery-usb-cdc-example\stm32f4-discovery-usb-cdc-example\Libraries\STM32_USB_Device_Library\Core\inc/usbd_req.h:86:6: note: expected 'uint8_t *' but argument is of type 'char *'

       [cc] C:\CooCox\CoIDE\workspace\usb_2\K2_QUELLE\stm32f4-discovery-usb-cdc-example\stm32f4-discovery-usb-cdc-example\src\usbd_desc.c:223:5: warning: pointer targets in passing argument 1 of 'USBD_GetString' differ in signedness [-Wpointer-sign]

       [cc] In file included from C:\CooCox\CoIDE\workspace\usb_2\K2_QUELLE\stm32f4-discovery-usb-cdc-example\stm32f4-discovery-usb-cdc-example\src\usbd_desc.c:25:0:

Nevertheless the project is bulit and the green LED starts blinking (as supposed) but the USB device is not recognized by Windows. Passing through the code I get underlined the following expressions:

__ALIGN_BEGIN USB_OTG_CORE_HANDLE  (found in main.c marked as syntax error)

and following this the USB descriptors in usbd_descr.c are also marked as syntax errors

/* USB Standard Device Descriptor */

__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =

  {

    0x12,                       /*bLength */

    USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/

    0x00,                       /*bcdUSB */

    0x02,

    0x00,                       /*bDeviceClass*/

    0x00,                       /*bDeviceSubClass*/

    0x00,                       /*bDeviceProtocol*/

    USB_OTG_MAX_EP0_SIZE,      /*bMaxPacketSize*/

    LOBYTE(USBD_VID),           /*idVendor*/

    HIBYTE(USBD_VID),           /*idVendor*/

    LOBYTE(USBD_PID),           /*idVendor*/

    HIBYTE(USBD_PID),           /*idVendor*/

    0x00,                       /*bcdDevice rel. 2.00*/

    0x02,

    USBD_IDX_MFC_STR,           /*Index of manufacturer  string*/

    USBD_IDX_PRODUCT_STR,       /*Index of product string*/

    USBD_IDX_SERIAL_STR,        /*Index of serial number string*/

    USBD_CFG_MAX_NUM            /*bNumConfigurations*/

  } ; /* USB_DeviceDescriptor */

Same goes for the other two USB descriptors following.

Any ideas if this is the problem and how to fix it?

Thanks for your help
5 REPLIES 5
kruszi
Associate II
Posted on February 10, 2013 at 16:59

Hi,

I managed to get rid of the __ALIGN_BEGIN Problem by adding the following code to usbd_conf.h:

//#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED

  #if defined   (__GNUC__)        /* GNU Compiler */

    #define __ALIGN_END    __attribute__ ((aligned (4)))

    #define __ALIGN_BEGIN

  #else

    #define __ALIGN_END

    #if defined   (__CC_ARM)      /* ARM Compiler */

      #define __ALIGN_BEGIN    __align(4)

    #elif defined (__ICCARM__)    /* IAR Compiler */

      #define __ALIGN_BEGIN

    #elif defined  (__TASKING__)  /* TASKING Compiler */

      #define __ALIGN_BEGIN    __align(4)

    #endif /* __CC_ARM */

  #endif /* __GNUC__ */

//#else

//  #define __ALIGN_BEGIN

//  #define __ALIGN_END

//#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */

Unfortunately this was not the problem causing the device not being recognized. Again this is for CooCox IDE.
Posted on February 10, 2013 at 17:27

Unfortunately this was not the problem causing the device not being recognized. Again this is for CooCox IDE.

Not much of CooCox following here, but perhaps your problem is one of passing the correct defines to the compiler command line?

USE_STM32F4_DISCOVERY

STM32F4XX

USE_STDPERIPH_DRIVER

USE_USB_OTG_FS

Alternatively you could build with another tool chain
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ahmed2399
Associate II
Posted on February 12, 2013 at 21:44

Me too I have some problem with coocox .

USB not recognized but the green led blink when i put the USB.

Make sure that you are include the path  of 'inc' in project configuration
Posted on February 12, 2013 at 21:56

Me too I have some problem with coocox .

 

Yeah, I'm noticing a pattern.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
philcal
Associate
Posted on April 12, 2013 at 02:01

I was getting this error only on the first build. Build again and error disappeared. Build clean and error is back again! Strange -Im a noobie so dont known what might cause it but it might give somebody a clue.

note I'm running codeblocks on xubuntu