cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot make USB driver generated with STM32Cube to work with MB1293C

MLiva
Associate III

Try to get demo firmware sources for USB dongle MB1293C. Also a .hex file will be useful.

I am trying to use STM32Cube utility to generate code from the .ioc file but the code generated does not support the usb driver properly. Any hints to how to get usb driver code working will be useful to me.

1 ACCEPTED SOLUTION

Accepted Solutions
Lubos KOUDELKA
ST Employee

Hello,

Your problem is most probably wrongly generated device descriptor, which is missing one '0x0' on 3th position. Please try to compare device descriptor from repository example, which is working for you, and the one from project you generated with CubeMX.

Problem is reported and shall be fixed in next release.

Best regards,

Lubos

View solution in original post

6 REPLIES 6
MLiva
Associate III

Managed to find some software from st site: https://my.st.com/content/my_st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32cube-mcu-mpu-packages/stm32cubewb.license=1570542044428.product=STM32CubeWB.version=1.2.0.html

That can be used to build a working code, but this code is not using code generated by STM32Cube. So my problem is still valid but I have more leads to investigate now.

Lubos KOUDELKA
ST Employee

Hello,

Your problem is most probably wrongly generated device descriptor, which is missing one '0x0' on 3th position. Please try to compare device descriptor from repository example, which is working for you, and the one from project you generated with CubeMX.

Problem is reported and shall be fixed in next release.

Best regards,

Lubos

MLiva
Associate III

After doing some investigation I found in the code generated by CubeMX file usbd_desc.c

............

/** USB standard device descriptor. */

__ALIGN_BEGIN uint8_t USBD_CDC_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =

{

 0x12,            /*bLength */

 USB_DESC_TYPE_DEVICE,    /*bDescriptorType*/

 0x02,

 0x02,            /*bDeviceClass*/

 0x02,            /*bDeviceSubClass*/

 0x00,            /*bDeviceProtocol*/

 USB_MAX_EP0_SIZE,      /*bMaxPacketSize*/

 LOBYTE(USBD_VID),      /*idVendor*/

 HIBYTE(USBD_VID),      /*idVendor*/

 LOBYTE(USBD_PID),      /*idProduct*/

 HIBYTE(USBD_PID),      /*idProduct*/

 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_MAX_NUM_CONFIGURATION /*bNumConfigurations*/

};

..................

while the sample code in file usbd_cdc.c that works is as follows:

................

/* USB Standard Device Descriptor */

__ALIGN_BEGIN static uint8_t USBD_CDC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =

{

 USB_LEN_DEV_QUALIFIER_DESC,

 USB_DESC_TYPE_DEVICE_QUALIFIER,

 0x00,

 0x02,

 0x00,

 0x00,

 0x00,

 0x40,

 0x01,

 0x00,

};

...........

It appears the two structures are different and not only to 0x0 entry at position 3.

Is there a way I can manually edit the CubeMX structure to get it to work?

MLiva
Associate III

Just tried modified structure of CubeMX code as follows:

.........................

/** USB standard device descriptor. */

__ALIGN_BEGIN uint8_t USBD_CDC_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =

{

 0x13,            /*bLength */

 USB_DESC_TYPE_DEVICE,    /*bDescriptorType*/

 0x00,

 0x02,

 0x02,            /*bDeviceClass*/

 0x02,            /*bDeviceSubClass*/

 0x00,            /*bDeviceProtocol*/

 USB_MAX_EP0_SIZE,      /*bMaxPacketSize*/

 LOBYTE(USBD_VID),      /*idVendor*/

 HIBYTE(USBD_VID),      /*idVendor*/

 LOBYTE(USBD_PID),      /*idProduct*/

 HIBYTE(USBD_PID),      /*idProduct*/

 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_MAX_NUM_CONFIGURATION /*bNumConfigurations*/

};

..................

which adds 0x0 at position 3 (as suggested in the fix) but also increase the size from 0x12 to 0x13 in position 1. After running this code I can see the usb port enabled by the CubeMX.

Lubos KOUDELKA
ST Employee

Hello,

device descriptor size shall stay 0x12.

If you want to modify in CubeMX, you would need to dig into internal scripts of CubeMX, which may be quite risky for overall stability.

In your previous comparison you compared two different descriptors - device and device qualifier.

Best regards,

Lubos

MLiva
Associate III

Hi Lubos,

Thank you for the reply. I have reverted to 0x12 but still added the 0x00 in third position and the driver still show. I have even managed to transfer data so am happy with the driver at moment. I'll be waiting for the CubeMX updates, but at the moment this is a good workaround for me.

Regards,

Makis