2015-05-12 12:45 AM
Hello,
I have set up a CubeMX project with USB FS and CDC enabled. The device is STM32L151CCT6.Also, I have installed the VCP 1.4.0 drivers for Win7 (x64).When I start the debug session (IAR 7.40), Windows complain that the device is unknown and of course is not shown on the COM port list.Moreover I use the following code in my USB gatekeeper thread, to avoid illegal usage of the device:while (hUsbDeviceFS.dev_state != USBD_STATE_CONFIGURED)
{ osThreadYield ();}but it never goes through that check. Thedev_state
always evaluates toUSBD_STATE_DEFAULT
.Any thoughts? Thanks!Best regards,George #cubemx #stm32l12015-05-12 03:50 PM
Hello George,
I have some Issues with the CDC Class, too. Actually I just stuck on a simple project without anything but USB-CDC. I found out, that everything works fine if I just lower the optimization level to O0 (I am using Keil). Further inspection shows that if I only use O0 on the function USBD_static_malloc in usbd_conf.c everything works fine. I made it with pramgas in the source file. It looks like any optimization throws out that unused static variable... hope that helps Alex2015-05-12 10:41 PM
Hello Alex,
Thank you for your reply and sharing your thoughts.I am using IAR with optimizations disabled.Unfortunately the last couple of days I've been looking around the forum and found out that many people are having problems with the USB middleware.I'll try to work on an F4 eval board for now and perhaps I'll find something.Best regards,George2015-05-13 11:26 PM
Hello,
I've found something that was creating problems.inusb_conf.c
line 477 (STM32L1 v1.2.0), there is a ''static malloc'' function.void *USBD_static_malloc(uint32_t size)
{ //static uint32_t mem[sizeof(USBD_CDC_HandleTypeDef)]; static uint8_t mem[512]; return mem;}The input obviously does nothing and this is just a complex way to declare a static variable and its pointer.The real problem is that sizeof(USBD_CDC_HandleTypeDef) is 540. So what the developer tried to do is fit a 540 byte long structure in a 512 byte array, for no obvious reason.Commenting the 512 byte declaration and un-commenting the original allowed me to send messages via CDC. I still can't receive, but I will update as soon as I manage.2015-05-15 04:20 AM
Hi,
It might be a long shot but when you started talking about memory then i remember i had a problem with USB also and in this forum i found that somebody suggested increasing stack and heap size (in startup_xxx.s file).2015-12-01 03:36 AM
Dear user,
The issue has been solved by updating the static_malloc function used by the USB device class.