cancel
Showing results for 
Search instead for 
Did you mean: 

USB device not recognized

ST Community
ST Employee

The USB device is detected by the PC (USB host), but the device initialization reports an error, like. "error code 10" on Windows. What is the problem?
 

When using the HAL libraries, the source of this problem can be a too small heap configured in the project. The solution is to either increase the heap size, or configure the USB library to use static allocation.

The heap configuration depends on the used IDE/Toolchain:

  • CubeMX: In project options (see picture below). If project is generated with CubeMX, it will then apply this configuration for the selected toolchain (IAR, Keil, SW4STM32 etc.).
  • IAR: In project setting or ICF file
  • Keil: In startup_stm32xxx.s file
  • SW4STM32/Eclipse: In the linker script file (e.g.: STM32F746NGHx_FLASH.ld)

 

  • 705.png

The USB library configuration requires enough space to allocate the structure related to the implemented USB class (e.g. USBD_CDC_HandleTypeDef in case of CDC class implementation). A value of 0x1000 should be enough for most cases, but it might also depends on other software components used in the project.
 

If you want to use static allocation, you can rewrite the USBD_malloc and USBD_free macros in the usbd_conf.h file. The USBD_malloc is called only once when the USB class is initialized. The static variant can return always the same pointer to static allocated memory, and USBD_free can be left empty. The size of the static allocated memory will depend on the used class (e.g. size of USBD_CDC_HandleTypeDef).
 

Comments
HKIM.91
Associate

Hi

I am beginner. I want to use USB_CDC_ACM

My MCU module is stm32f207vc and customized board

I have a question about detection of usb

1. USBH_CDC_ACM_GetDeviceStatus function does not detect when usb insert

2. And Is this necessary ? I only use USB port

//////////////////////////

extern ARM_DRIVER_USART Driver_USART9;

#define ptrUART_USB     (&Driver_USART9)

////////////////////////

And usart9 is not in stm32f207vc

//////////////////////////////////////////////////

I succeeded make program via cubemx

custom A board cdc-host,

custom B board cdc-device,

connect A and B board via USB port

Succeed test data send, and receive

///////////////////////////////////////////

My USBH_CDC_ACM_GetDeviceStatus problem's program configure

In keil's "manage run time environment" set

CMSIS : core

RTOS : Keil RTX

CMSIS Driver : USART(API) : CDC, USART

USB Host(API) : Full Speed

Device : CStartup, classic

Device : common,Cortex,DMA,GPIO,RCC

USB : Host :CDC

////////////////////////////////////////////

Thank's

Javier1
Principal

I have this exact problem with my stm32wb5m discovery board

https://community.st.com/s/question/0D53W00001GNSAUSA5/usb-cdc-device-not-being-recognised-by-windows-stm32wb5m

increasing heap size to 0x1000 or 0x2000 didnt fix it

RhSilicon
Lead

Hi,

If anyone searches this page again,

If I'm not mistaken, for the Host to recognize the Device, it is necessary to have the pull-up or pull-down resistor, as the case may be. I already had a problem with Bluepill, due to the incorrect value of the resistor.

See: https://www.beyondlogic.org/usbnutshell/usb2.shtml

"High speed devices will start by connecting as a full speed device (1.5k to 3.3V). Once it has been attached, it will do a high speed chirp during reset and establish a high speed connection if the hub supports it. If the device operates in high speed mode, then the pull up resistor is removed to balance the line"

gilmo
Associate

A lot of good ideas above but the newer ST micros don't require the 1.5K ohm external resistor because they have a built in Pull Up implementation, check your micro's reference manual.

I am using the STM32G0B1RET and I was having a similar issue. 

gilmo_0-1701625196425.png


What really solved my issue was the article below that pointed me in the right direction, bottom line is CubeMX is not generating a complete code for the CDC handling, specially enabling the interrupts, It had the clock initialization correctly setup by it but I had to implement the interrupt handling.

https://community.st.com/t5/stm32cubemx-mcus/usb-stm32g0b1kct6-not-working/td-p/75116

I will share my USB schematic with you, I guarantee you this works after fixing the interrupt handler!

gilmo_1-1701625313893.png

My USB lines connect directly to pins PA11 (USBD-) and PA12 (USBD+)

I hope this helps you!

Good Luck!

 

Embedded_Engineer
Associate II

Hello Members, I am facing problem in using FATFS and USB_MSC together in the same board. I'm reaching out to seek your assistance with a challenge I'm currently facing.

I'm involved in a project that involves the transfer of files, typically text or binary data files with sizes ranging from 100 MB to 600 MB. To facilitate this process, I'm working on integrating USB functionality. The objective is to copy these files directly from an SD card to my computer using USB. The USB functionality works as intended when FATFS is not enabled.

However, the complication arises when I enable FATFS (which is a mandatory component for the project). Enabling FATFS prevents the USB functionality from working, and it no longer detects the USB after enabling FATFS. This issue has been a roadblock for me, since in a single board I am not able to use USB and FATFS I thought to use 2 STM32 micro controllers but still its not working please help me resolving this issue:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/facing-issue-in-transfering-sdcard-file-by-uart-usb/m-p/616003#M16108





MKing
Associate III

Hi,

in my case the problem was that windows used the wrong/previous driver:

At the beginning i created the usb cdc (communication device class) for testing. This works fine. Then i used the same project and same processor and selected the adc (audio device class). After i download and start the stm32f103 i get the "error 10".

So i had to open "device manager" of windows, select the device with the problem. Rightclick and select properties. Then select driver->driver update. Then press "search on my computer for driver", "select driver from list" and change to the other shown driver.

 

Version history
Last update:
‎2023-12-07 05:56 AM
Updated by: