Skip to main content
Associate
August 29, 2026
Question

Problem with NUCLEO-H563ZI USB as Host Only(For Reading and Writing pendrive Sector)

  • August 29, 2026
  • 6 replies
  • 147 views

Hello ​@ST Community ​@ST MICROCONTOLLER 

I have purchase NUCELO-H563ZI board.
Purpose: 
I need to read and write pendrive sector using only pure HAL HCD driver (Baremetal Code only) (No FILEX, USBx, ThreadX, FreeRTOS)
Following is my Hardware Connection: I am using external USB Type A Female Breakout board. Not using internal CN13 TypeC USB connector.

PA11 : D-Minus
PA12 : D-PLUS
VCC : 5V
GND : Board Ground

I have attached file which can read and write the sector.

While submitting request for “Get Descriptor” command. Code is stuck during USB_EnumerateMSC » USB_GetDescriptor » “USB_ControlTransfer” » “USB_SubmitTransfer” >> “HAL_HCD_HC_SubmitRequest”  stuck in “USB_WaitForURB>>HAL_HCD_HC_GetURBState” function.

I can observe that while submitting “HAL_HCD_HC_SubmitRequest” request on channel 0 HAL Drive respond on channel 1 instead of channel 0. ch[0].urbState = USB_IDEL while ch[1].urbState = USB_DONE.

Also i have also observe that “HCD_HC_OUT_IRQHandler(hhcd, (uint8_t)i);” API “uint8_t ch_num = HAL_HCD_GetLogical_Channel(hhcd, phy_chnum, 0U);” return with value 1.

Also i have also observe that “HCD_HC_IN_IRQHandler(hhcd, (uint8_t)i);” API “uint8_t ch_num = HAL_HCD_GetLogical_Channel(hhcd, phy_chnum, 1U);” return with value 1.

Please review the Code and suggest the solution.
I have attached the Code.

Thanks in advance.

 

Regards,

Kaushal Patel   

6 replies

ST Technical Moderator
August 31, 2026

Hi ​@Aum0910 

Before proceeding, we need to narrow down the issue and confirm it’s not related to your custom HW implementation. To do so, Start with a known working USB host firmware on your board for the same USB interface you are using in host mode. You can start with this example and modify it accordingly. If it works as expected we can proceed to enumeration only and see your code.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
Aum0910Author
Associate
September 1, 2026

Hello Team,

I have download the Source from mention link in last comment and i tried to compile it but it fails.

Additionally i have tried to change the MCU as this project is available for STM32H573 Series and mine is STM32H563ZI but not able to change it.  

Can you please guide me for same.
Additional Information about Hardware is I have short SB21 and SB22 for PA11 and PA12 Pin connection for external USB Breakout board.
How to preceed further now?
Is it possible to check my attached source code at your end weather it is correct or not?

Thanks in advance.

regards,

Kaushal Patel

Andrew Neil
Super User
September 1, 2026

I have download the Source from mention link in last comment and i tried to compile it but it fails.

 

Did you follow the download instructions:

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Aum0910Author
Associate
September 7, 2026

Hello Team,

I have downloaded source code as per guidance and i am able to compile it. But it was for STM32H573-DK board.
Can you please guide me how to migrate whole source for NUCLEO-STM32H563ZI   borad.
I am new to STM32 family, Please do needful for me.
Is there any specific steps that i need to follow so i can provide result to you.

 

Aum0910Author
Associate
September 10, 2026

Hello ​@Andrew Neil 

I have tried to create a similar code for STM32H563ZI board.
This code is stuck at starting of thread entry “app_ux_host_thread_entry”  as well as “msc_process_thread_entry”.
I am attaching my source code.
I have not utilize the USBPD as i am connecting USB with external breakout board.
I also short the  SB21 and SB22 for PA11 and PA12 Pin.
I am giving direct 5V from Dev board to USB breakout board.
Attached is whole source as per your suggestion.but this code is not working.
I have connected pendrive from beginning.

Please help me what should be the next steps

regards,
kaushal Patel 
 

ST Technical Moderator
September 15, 2026

Hi ​ ​@Aum0910 

You should not short SB21 and SB22 as per UM3115

  • ON, ON These pins can be used as GPIOs on the ST morpho connector (CN12).  (SB27 and SB28 must be OFF).
  • OFF, OFF These pins are used as D- and D+ on the USB connector (CN13). (SB27 and SB28 must be ON). (Default).

     

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL