cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 - how to initialize USB HS on M4 core (Hard Fault)?

LensFlare
Associate II

Hi!

I'm using STM32H747 MCU on STM32H747I-DISCO board and CubeIDE with a project template for 2-core parts. M7 core processing TouchGFX and all UI-related stuff. 

I'm trying to run a USB HS peripheral on a M4 core.

Selected context for USB_OTG_HS is M4 core in the project configuration (.ioc file).

By default, both cores start at the same time, M4 stops while M7 configures all peripherals and M4 runs after. But when the M4 core starts up and tries to initialize the USB, a Hard Fault error occurs.

When debugging the project, I can see that the error appears in

HAL_PCD_Start() -> __HAL_PCD_ENABLE(hpcd) -> USB_EnableGlobalInt().

This function writes register:

USBx->GAHBCFG |= USB_OTG_GAHBCFG_GINT;

But according to the manual RM0399 (60.14.3 OTG AHB configuration register (OTG_GAHBCFG)):

"Do not change this register after the initial programming. The application must program this register before starting any transactions on either the AHB or the USB."

So, my thoughts, this error occurs because the M7 core has already begun to communicate on the bus while the M4 core is trying to write to this register.

Are my assumptions correct?

Is there a way to move initialization and usage of USB HS to M4 core instead of M7?

(All examples, supplied with FW_H7 V1.9.1 firmware use M7 core for USB)

Perhaps someone could point me in the right direction.

Thank you.

4 REPLIES 4

Hello @LensFlare​ ,

You can refer to the following example provided under our H7 Firmware Package that uses the multi-core support feature integrating the Mass Storage Class (MSC) (Cortex-M7) and Human Interface (HID) (Cortex-M4) in the same project:

  • Projects\STM32H747I-EVAL\Applications\USB_Device\HID-CM4_MSC-CM7

This might help you.

BeST Regards,

Walid

dungeonlords789
Senior III

see also about NewLib

Thank you, I’ll take a look.

Thank you, that is interesting.