cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with HID Host and STM32F4

Luca Giuliodori
Associate III
Posted on November 23, 2017 at 13:09

Hi everyone,

I'm developing an HID Host application to comunicate with a own device and I'm using the NUCLEO-F446ZE board.

At the start I tried to use the HID_Standalone application in the STM32CubeF4 firmware package and then, I tried to develop a new application with STMCube configurator.

In both case I tried to connect (with OTG connector) 3 different type of mouse and 1 keyboard and no all device are able to comunicate with microcontroller:

  • with Typhoon mouse 40260 the USBH_Process state machine in the usbh_core.c file of the Middlewares, blocks in the HOST_ENUMERATION state (line 462) because the USBH_HandleEnum(phost) function try to get device descriptior (line 646 same file) but the USBH_HandleControl() function read all times USBH_URB_NOTREADY state (line 600 of usbh_ctlreq.c) until HAL_HCD_Disconnect_Callback() called by interrupt.
  • with Trust mouse 16144 is the same with Typhoon mouse with difference that the HAL_HCD_Disconnect_Callback() isn't called by interrupt.
  • with Dell Mouse XN966 all work fine and I can see the data.
  • with asus keyboard G01 KB the USBH_Process state machine in the usbh_core.c come up to HOST_DEV_DISCONNECTED where there is the BgndProcess but I can't receive data because in the HID_Handle the fifo has the tail and head at the same value.

All the previous devices are tested with PC and work fine and the board are powerd with external source.

What can be the problem and how can I fix it?

Thanks in advance

#usb-hid #usb-host #stmcube-f4-usb #middleware
20 REPLIES 20
Luca Giuliodori
Associate III
Posted on January 26, 2018 at 16:56

I have applied the

pavel_a

patch suggested in

https://community.st.com/0D70X000006SyJZSA0

and seems the USB stack works fine!

I hope, as soon as possible, ST release the USB stack with these fixs.

Regards

When I click the above link I get the following error : "We have changed our Community platform and the page you were looking for appears to have been moved. Please bear with us while Google and other search engines finish re-indexing our pages."

I'm stuck with the same issue, so could you please help in re-directing me to the proper link?

Thanks in advance

Yes it's true: the link doesn't work.

I have not tried anymore but may be ST has released a new version of the stack with these patches. You've tried?

Hello,

The suggested fix isn't yet integrated in the STM32Cube package.

Regarding the other discussion where @Pavel A.​  suggested a fix, you can find it in https://community.st.com/s/question/0D50X00009XkZ4KSAV/usb-host.

If you think that you are facing a different issue than what was described there, please submit a new discussion with relevant details about your case.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

SSure
Associate II

The suggested fix mentioned in the above link is working for me. Thank you.

we are waiting a definitively release of USB stack 😉

Hi Luca,

You can find this patch for F4 library ver. F4.1.21.0 here:

https://github.com/pavel-a/stm32f4_libs/blob/master/STM32Cube_FW_F4/patches/USBH-ctrlreq-hid-21may2018.patch

Regards,

-- pa

AAgha
Associate II

hi

can some one tell me which keyboards work with stm library!?

thanks for your quick reply.

Pavel A.
Evangelist III

With the latest STM32F4 library (v 1.24) most legacy-compatible keyboards should work.

Also, composite devices (kbd+mouse, kbd+card reader) where keyboard is the 1st function should work.

"Works" here means that the HID reports can be read reliably.

I have not tested translation of HID codes to any non-latin layout.

-- pa

hamed33
Associate

I'm hopeful that my answer is useful after about 3 years!

This is because of your PCB design, not the code. Most of the microcontrollers, same as STM32F407, only have one USB port that can be configured as the Host or Device. But in the evaluation boards, the Discovery board for example, there are both the Host and Device physical ports. These ports share the D+ and the D- pins of the microcontroller. Based on USB standard, in the full-speed device mode, there is a 1.5k pull-up resistor connected to the D+ pin. If you need to use the system in the Host mode, you will be sure that this pull-up resistor is disabled based on the PCB schematic details. Each USB device (keyboard, mouse, etc) internally includes this resistor. Using this resistor the Host can detect the type of the connected USB device and the exact plug-in time. After plug-in detection, the host will start the enumeration procedure. Otherwise, the host can not detect the correct moment of device insertion and will run enumeration miss alined. In this situation, the enumeration procedure always reports some sort of errors same as USBH_busy.

You can find more details about USB wiring at the following link:

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

Regards