Skip to main content
Graduate
July 14, 2025
Question

Unable to get USB_OTG_HS host on PB14/PB15 on Nucleo board to react

  • July 14, 2025
  • 2 replies
  • 370 views

I'm working with the NUCLEO -F 446ZE MB1137 B-01 development board. My goal is to make a Virtual Com Port tunnel, where I plug in PA11/PA12 (USB device) to a PC and PB14/PB15 (USB host) to another product my company makes. I want to use the full speed (12 MBits/s) on both USB peripherals. It was very straight-forward to get the USB device to work using STM32CubeIDE, but no matter what I do I can't get the USB host to work. To isolate the problem, I removed the USB device completely and I’m currently only focusing on the USB host. I've added some logging here and there (using a sw bit-bang UART) e.g. in USBH_UserProcess, USBH_CDC_ClassRequest, OTG_HS_IRQHandler and in case of errors in MX_USB_HOST_Init. I have set PG6 high (right after the call to MX_USB_HOST_Init) to enabled VBUS on the CN13 connector (and measured 5 V on the 4th pin on a micro-USB to USB-A-female connector) and LED LD8 shows green light and LED LD7 (over-current indicator) never lights up. I'm using HSE 8 MHz and I make sure to multiply and divide it properly so that USB gets 48 MHz in the clock tree. Still, it seems the firmware is not reacting at all when I plug something into connector CN13. I've tried plugging in my company’s product, an FTDI USB-to-serial cable, and an optical mouse (its LED on the bottom did not light up). Does anybody know what I'm doing wrong?

Connectivity USB_OTG_HS:
External Phy: Disable (grayed out)
Internal FS Phy: Host_Only
Activate_SOF: Unchecked
Activate_VBUS: Unchecked
Speed: Host Full Speed 12MBit/s
Enable internal IP DMA: Disabled
Physical interface: Internal Phy
Signal start of frame: Disabled
User constants: None
USB On The Go HS End Point 1 Out global interrupe: Unchecked
USB On The Go HS End Point 1 In global interrupt: Unchecked
USB On The Go HS global interrupt: Checked. Prio 5, subprio 0
PB14 USB_OTG_HS_DM n/a Alternate Function Push Pull No pull-up and no pull-down Very High
PB15 USB_OTG_HS_DP n/a Alternate Function Push Pull No pull-up and no pull-down Very High

USB_HOST:
Class For HS IP: Communication Host Class (Virtual Port Com)
Class For HS IP: Disable (Grayed out; I can’t select anything else)
USBH_MAX_NUM_ENDPOINTS (Maximum number of endpoints): 2
USBH_MAX_NUM_INTERFACES (Maximun number of interfaces): 2
USBH_MAX_NUM_SUPPORTED_CLASS (Maximun number of supported class): 1
USBH_MAX_NUM_CONFIGURATION (Maximun number of supported configuration): 1
USBH_KEEP_CFG_DESCRIPTOR (Keep the configuration into RAM): Enabled
USBH_MAX_SIZE_CONFIGURATION (Maximun size in bytes for the Configuration Descriptor): 256 bytes
USBH_MAX_DATA_BUFFER (Maximun size of temporary data): 512 bytes
USBH_DEBUG_LEVEL (USBH Debug Level): 0: No debug message
USBH_USE_OS (Enable the support of an RTOS): Enabled
USBH_PROCESS_PRIO (The CMSIS-RTOS osPriority value specifies the priority for the USB Host thread): priority: normal (default)
USBH_PROCESS_STACK_SIZE (The CMSIS-RTOS stack size requirements in words): 128
Drive_VBUS_HS GPIO Output PG6 [USB_PowerSwitchOn[STMPS2151STR_EN]]

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    July 14, 2025

    Hi @arnold_w 

    Did you test the same controller USB_OTG_HS using PB14/PB15 in device mode? If working without issues, you may refer to this example in host mode.

    arnold_wAuthor
    Graduate
    July 15, 2025

    So, it turns out CN13 wasn't connected to the PB14/PB15 USB peripheral, it was connected to the PA11/PA12 USB peripheral instead. Now I've abandoned the CN13 connector and I'm connecting directly to PB14/PB15. Configuring both USB peripherals as devices worked great, but when I configure the PB14/PB15 USB peripheral as a host and plug in a device, then I get a HardFault. This is surprising because I've made very few changes to the code Cube generated for me. Is there perhaps some define/configuration I have forgotten to set since I want to run with FreeRTOS? Here's the stack trace when it crashes:

    HardFault_Handler() at stm32f4xx_it.c:88 0x80019f6
    <signal handler called>() at 0xfffffff1
    memcpy() at 0x80118e6
    prvCopyDataToQueue() at queue.c:2,102 0x800e444
    xQueueGenericSendFromISR() at queue.c:995 0x800e0d2
    osMessageQueuePut() at cmsis_os2.c:1,766 0x800d888
    USBH_LL_PortEnabled() at usbh_core.c:1,235 0x800c43e
    HAL_HCD_PortEnabled_Callback() at usbh_conf.c:183 0x80111c4
    HCD_Port_IRQHandler() at stm32f4xx_hal_hcd.c:1,687 0x800390e
    HAL_HCD_IRQHandler() at stm32f4xx_hal_hcd.c:559 0x800271a

    arnold_wAuthor
    Graduate
    July 15, 2025

    It appears the default stack size (USBH_PROCESS_STACK_SIZE) was too small, I had to increase it from 128 to 512 to avoid the HardFault.