Skip to main content
Associate III
May 10, 2026
Question

STM32H7 Ux_Device_HID example

  • May 10, 2026
  • 3 replies
  • 207 views

Hi,

I spent a few days trying to make Ux_Device_HID and Ux_Device_HID_Standalone to work on Ubuntu with latest versions of CubeMX and Cube IDE (STM32CubeIDE Version: 2.1.1, STM32CubeMX 6.17.0)

The only way I managed Ux_Device_HID to work on NUCLEO-H723ZG was by the following steps:

  • start MX
  • select example for nucleo board and start project directly in CubeIDE (not doing anything in CubeMX)
  • compile project in CubeIDE without any changes
  • flash to the board and it works

However, if I want to open it in CubeMX and generate code even without any changes - the resulting code does not work at all. I used git to do diff and changes are all over..

Of course I could do changes in CubeIDE directly without nice MX interface, but I kind of like it simple ))

Anyway, could someone form ST explain why *.ioc file from example cannot be used with Cube MX to generate a working code?

3 replies

ST Employee
May 11, 2026

Hello @Lex,

Did you try to take a look at:

x-cube-azrtos-h7/Projects/NUCLEO-H723ZG/Applications/USBX/Ux_Device_HID

This is a relevant reference and should be useful for your application.

I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

Thanks for your contribution.

Dor_RH

LexAuthor
Associate III
May 17, 2026

Yes, this example was used. See my comment to the next reply.

Technical Moderator
May 11, 2026

Hi @Lex 

If I understand you correctly, the firmware examples provided are sometimes older than the current CubeMX generator. As a result, the examples are not always intended to be regenerated directly from the .ioc file.

It would be helpful if you could share your diff and describe the issue you are seeing, so we can review it and report it if needed to better preserve the same structure.

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.Best regards,FBL
LexAuthor
Associate III
May 16, 2026

Hi,

I re-tested this issue today. Apparently a newly created code with MX or IDE works. I dunno if my Linux apps or installed packages were updated or not, but I can't see problem directly.

However I found problem with the following in the earlier created example code (without initial changes by MX):

  • I opened .ioc file and added TIM16 and all LEDs (which were previously added manually in the code).
  • Generated new code with MX and opened it in Cube
  • Removed my previous manual additions (TIM16, LDEs) which are generated by MX now
  • Compiled and flashed the code - it crashed

Start doing diff - a lot of system file changes (for example, CMSIS version changed from 1.10.5 to 1.10.7)

The only important change in app code I found was missing memset() line in usb_otg.c:

 /* USER CODE BEGIN USB_OTG_HS_Init 1 */
 memset(&hpcd_USB_OTG_HS, 0x0, sizeof(PCD_HandleTypeDef));
 /* USER CODE END USB_OTG_HS_Init 1 */

See diff of the old and new:

Lex_0-1778961248337.png

Even it was between user input comments it was gone. Possibly due to change in comment styles...

I assume the change of the text after "USER CODE BEGIN" is the reason MX generated code failed if there was something in between lines. Hope this clarification helps.

Cheers

Technical Moderator
May 18, 2026

Hi @Lex 

Would you attach you ioc file ? 

What you observed is can be consistent with regenerating an older example with a newer CubeMX version. In such cases, the generated code structure can change, and some user code sections may not be preserved exactly as in the original example.

That is why we need to check whether this is a CubeMX issue or whether some required user code is missing.

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.Best regards,FBL
LexAuthor
Associate III
May 18, 2026

Here it is the updated ioc version.