Skip to main content
Graduate
March 25, 2025
Solved

STM32C0 USB CDC not working

  • March 25, 2025
  • 4 replies
  • 2204 views

Hi,

I am using custom board with STM32C071. I am trying to enable USB port with CDC so that my custom board will be visible as virtual com port on PC. After enabling all options and initializations, I was expecting that my board will appear on PC device manager COM port list but it does not appear. Below are the settings:

1. Clock configuration - In my hardware external crystal is connected of 8MHz and I see there is no PLL which can multiply it and hence I am using internal 48MHz clock.

PPate1_0-1742920922538.png

2. USB port is enabled with default settings. PA11 and PA12 pins are used for USB connection in hardware. USB global interrupt is enabled.

PPate1_1-1742921070309.png

3. USBX is enabled from middleware. Device class CDC ACM is only one selected.

PPate1_2-1742921196299.png

4. Most of the settings for USBX is default value except for two of them marked in red color. These values are updated from 1024 to 10000 and 512 to 8000. With default values of 1024 and 512, function MX_USBX_Device_Init() was returning error. After referring to discussions on community, I got one of the reference to make this change which resolve the error of MX_USBX_Device_Init(). However, still my board is not visible on PC as VCP.

PPate1_3-1742921907090.png

Hardware schematic is as follows:

PPate1_4-1742922370961.png

In main.c file, I could see following two function calls:

MX_USB_PCD_Init();

MX_USBX_Device_Init();

Both of the above functions return 'success'.

Please guide me in locating the issue as why my custom board is not appearing as VCP on PC.

Thanks,

Pradeep

edit: updated label STM32C0 Series

 

    This topic has been closed for replies.
    Best answer by PPate.1

    Hi,

    This problem is resolved. The root cause was found to be grounding issue. Custom board USB connector ground pin was not soldered properly due to which when STLink board was connected to custom board, the ground pin in downloading cable of STLInk board established ground connection of custom board with Host PC. This made USB to work but as soon as STlink board is removed the ground connection got disconnected and USB port was seen removed by Host PC. 

    Thanks,

    Pradeep

    4 replies

    Super User
    March 25, 2025

    @PPate.1 wrote:

    still my board is not visible on PC as VCP.


    Does anything at all appear on your PC?

    Have you verified good connections, no shorts, etc on your custom board?

    Are you sure you're using a good cable, with full data connectivity?

    PPate.1Author
    Graduate
    March 25, 2025

    Information about layout: 90 ohm differential impedance maintained.

    PPate1_0-1742923482510.png

    Thanks,

    Pradeep

    Super User
    March 25, 2025

    But have you actually checked for continuity & shorts?

    And, again:

    Does anything at all appear on your PC?

    Are you sure you're using a good cable, with full data connectivity?

    PPate.1Author
    Graduate
    March 27, 2025

    Hi Andrew,

    Yes I checked continuity on board. It is good. I also checked shorts on PCB and have not observed any shorts. I removed ESD protection diodes for now.

    The cable I have used which is already in use with other device for data transfer and hence no doubts on cable.

    Super User
    March 25, 2025

    Have you generated the project from scratch or started from some pre-configured examples such as this

    If the former: adapt the example to your custom board and try only the USB functionality. If it works, find differences to your project and merge carefully.

    Or get a Nucleo-C071, build the example, ensure it works, then compare with your custom board project.

     

    PPate.1Author
    Graduate
    March 27, 2025

    Hi Pavel,

    Yes, I did generated project from Scratch. I have Nucleo-C071 and tried on it. It works upto level where it I get message on PC - 'Unrecognized USB device'. I downloaded examples for Nucleo-C071 and tried to compile 'Ux_Device_CDC_ACM' from the folder. But it gives me compilation error -

    ---------------------------------------------------------------------------------------

    21:43:40 **** Incremental Build of configuration Debug for project Ux_Device_CDC_ACM ****
    make -j12 all
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_callback.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_callback.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_callback.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_callback.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_create.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_create.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_create.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_create.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_destroy.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_destroy.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_destroy.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_destroy.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_reset.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_reset.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_reset.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_reset.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_stall.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_stall.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_stall.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_stall.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_status.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_status.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_status.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_status.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_frame_number_get.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_frame_number_get.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_frame_number_get.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_frame_number_get.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_function.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_function.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_function.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_function.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_initialize.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_initialize_complete.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize_complete.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize_complete.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize_complete.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_interrupt_handler.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_interrupt_handler.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_interrupt_handler.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_interrupt_handler.o"
    arm-none-eabi-gcc "C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_transfer_abort.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DTX_INCLUDE_USER_DEFINE_FILE -DUX_INCLUDE_USER_DEFINE_FILE -DUSE_HAL_DRIVER -DSTM32C071xx -c -I../../Core/Inc -I../../AZURE_RTOS/App -I../../USBX/App -I../../USBX/Target -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc -I../../../../../../../Middlewares/ST/threadx/common/inc -I../../../../../../../Drivers/CMSIS/Device/ST/STM32C0xx/Include -I../../../../../../../Middlewares/ST/threadx/ports/cortex_m0/gnu/inc -I../../../../../../../Middlewares/ST/usbx/common/core/inc -I../../../../../../../Middlewares/ST/usbx/ports/generic/inc -I../../../../../../../Middlewares/ST/usbx/common/usbx_stm32_device_controllers -I../../../../../../../Middlewares/ST/usbx/common/usbx_device_classes/inc -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/STM32C0xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_transfer_abort.d" -MT"Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_transfer_abort.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_transfer_abort.o"
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_create.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:60: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_create.o] Error 1
    make: *** Waiting for unfinished jobs....
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_callback.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_destroy.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:58: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_callback.o] Error 1
    compilation terminated.
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_stall.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:62: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_destroy.o] Error 1
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_reset.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:66: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_stall.o] Error 1
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:64: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_reset.o] Error 1
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_endpoint_status.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_frame_number_get.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:68: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_endpoint_status.o] Error 1
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_function.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_initialize.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_initialize_complete.c:32:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:70: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_frame_number_get.o] Error 1
    compilation terminated.
    compilation terminated.
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_interrupt_handler.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    In file included from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32.h:57,
    from C:/Projects/STM32CubeIDEWorkspace/STM32CubeC0-main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/ux_dcd_stm32_transfer_abort.c:30:
    ../../USBX/Target/ux_stm32_config.h:29:10: fatal error: stm32c0xx_hal.h: No such file or directory
    29 | #include "stm32c0xx_hal.h"
    | ^~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:72: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_function.o] Error 1
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:74: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize.o] Error 1
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:76: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_initialize_complete.o] Error 1
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:78: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_interrupt_handler.o] Error 1
    make: *** [Middlewares/USBX/UX Device Controllers/subdir.mk:80: Middlewares/USBX/UX Device Controllers/ux_dcd_stm32_transfer_abort.o] Error 1
    "make -j12 all" terminated with exit code 2. Build might be incomplete.

    21:43:41 Build Failed. 25 errors, 0 warnings. (took 984ms)

    PPate.1Author
    Graduate
    March 27, 2025

    Hi,

    I have added - 'HAL_PCD_Start(&hpcd_USB_DRD_FS);' in my custom board application and now when connect its USB port to my PC I get message - 'USB device not recognized'. So now my custom board is also at same level as my Nucleo-C071 board.

    I tried increasing Heap memory size from 0x200 to 0x1000 but it didn't help.

    Do I need to install any driver on PC side? 

    Do I have to enable ThreadX to make USBX work?

    Thanks,

    Pradeep

    Technical Moderator
    March 28, 2025

    Hi @PPate.1 

    1. The compilation errors are caused by the missing driver files. Ensure your CubeIDE properly includes drivers and middleware files.
    2. The connector used can have a crucial impact on the enumeration phase. It’s also recommended to use properly power switch an ESD protection and to place it as close as possible to the USB connector. 
    PPate.1Author
    Graduate
    March 28, 2025

    Hi FBL,

    I recopied the example project in my workspace and now i could compile it. However, I need to include ThreadX middleware in the project else it gives errors in file 'app_usbx_device.c'. All errors are related to ThreadX. 

    After downloading to Nucle-C071 board it does not appear as VCP on my PC. I added 'HAL_PCD_Start(&hpcd_USB_DRD_FS);' function call after all initialization functions and before MX_ThreadX_Init();.

    After this I started getting message on my PC as 'USB device not recognised'. As per some discussion on community related to this error, I tried updating Heap memory size from 0x200 to 0x1000 but it does not resolve my issue.

    In Device manager on my PC I can see new USB device under 'Universal Serial Bus Controllers' as 'Unknown USB device (Device Descriptor Request Failed)'. 

    Hardware: You can look at layout image I have posted in this thread above. ESD diodes are kept near to connector. I am not using power switch as my device is going to be self powered and work in device mode only.

    Please guide further to resolve this issue.

    Thanks,

    Pradeep

    PPate.1Author
    Graduate
    March 31, 2025

    Hi,

    There is no example for CDC_ACM in standalone configuration and hence I took another example from Nucleo-C071 folder - Ux_Device_HID_Standalone. I could build and download this example on my Nucleo board and I could see it is executing good. On my PC, device manager shows 'HID Compliant Mouse' in Mice and Pointing devices group.

    I took this as reference and made a copy and updated it to remove HID Mouse options and selected CDC_ACM. For USBX settings, I took reference from Ux_Device_CDC_ACM (not sure if this is correct way of doing it). This got successfully executed on my Nucleo Board and in device manager on my PC, it shows USB serial Device (COMxx). 

    I used this as reference to update my custom board project settings for USBX. I connected USB port of my custom board to my PC and downloaded the project. I could see 'USB serial Device (COMxx)' on my PC device manager apart from 'STMicroelectronics STLink Virtual ComPort' and I thought things are resolved.

    However, I was wrong. I am using ST Link from Nucleo-G0B1RE board (another Nucleo board) for downloading code into my custom board. When i removed USB cable of this Nucleo board, both STLink VCP and USB serial device on my PC was removed. I reconnected its USB cable and observed that both serial ports appeared again. Now I removed USB cable of my Custom board and to my surprise, again USB serial device on my PC was removed but STLink VCP was appearing. Now I am unable to understand, what's going on here!!!

    My setup diagram is as below:

    PPate1_0-1743413779068.png

    Removing any of the USB cable in above setup, leads Windows 11 on my PC to remove USB serial device appearing in device manager. I tried without USB hub too, results are same. I tried connecting only Custom Board or only Nucleo-G0B1RE board and observed that in either case, USB serial device does not appear on PC. I also tried connecting both with PC but disconnected 5-pin downloading cable and observed that USB port does not appear on PC. It appears only when complete setup shown in above diagram is connected and powered up.

    Please help me in understanding this scenario and resolving the problem as I want my custom board USB port to appear as COM port on PC (offcourse without STLink).