Skip to main content
Associate III
June 25, 2025
Question

Can't debug Cortex®-M4 side software on STM32H7 dual core.

  • June 25, 2025
  • 3 replies
  • 924 views

Hi All,

I am using STM32H747IDISCO kit.

I make a new project on STM32CubeIDE(Vewsion 1.18.1), following these steps below.

1.Start STM32CubeIDE(Vewsion 1.18.1), and click [Start new STM32 Project] button on STM32CubeIDE Home.

2.Input "STM32H747I-DISCO" in Commercial Part Number Box on Boad Selector tab.

3.Click Boads list 1 item displayed on right side, and click [Next] button.

4.Input "TestPrj" in Project Name Box in STM32 Project daialog, and click finish button.

After a while, TestPrj.ioc is opened, then click Project -> Generate code. 

C/C++ perspective is opened.

I add some processes in CM4 main function that turn on LED1 like the following.

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

/* added proccess start */
{
/* Configure the GPIO_LED pin */
 GPIO_InitTypeDef GPIO_InitStruct;

 __HAL_RCC_GPIOI_CLK_ENABLE();
 GPIO_InitStruct.Pin = GPIO_PIN_12;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 GPIO_InitStruct.Pull = GPIO_PULLUP;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
 /* turn on LED */
 HAL_GPIO_WritePin (GPIOI, (uint16_t)GPIO_PIN_12, GPIO_PIN_RESET);
 printf("Hello World!!\r\n");
 }
/* added proccess end */

 /* USER CODE BEGIN Init */
 /* USER CODE END Init */ 

I execute build all, and load the code to board following the next guide.

 (https://www.st.com/resource/en/application_note/dm00629855-getting-started-with-projects-based-on-dualcore-stm32h7-microcontrollers-in-stm32cubeide-stmicroelectronics.pdf)

I set a breakpoint HAL_GPIO_WritePin (GPIOI, (uint16_t)GPIO_PIN_12, GPIO_PIN_RESET); line, and start debug, but it does not break.

LED1 is turned on, so it is clear that the breakpoint set above is proccessed.

And "Hello world!!" is not displayed on SWV ITM Data Console.

To display printf output in SWV ITM Data Console, I reffered to related website.

As mentioned above, I can’t debug(break, printf output to console, etc) on CM4 side.

Please teach me how to debug(break, printf output to console, etc) on CM4 side software on STM32H747.

3 replies

mƎALLEm
Technical Moderator
June 25, 2025

Hello,

Debugging the generated code for dual core is bit tricky as there is a kind of synchronization between CM4 and CM7 and CM4 enters in low power mode until the CM7 wakes it up.

I suggest you to comment the following code for debug:

CM7:

 while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));
 if ( timeout < 0 )
 {
 Error_Handler();
 }
while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0));
if ( timeout < 0 )
{
Error_Handler();
}

CM4:

HAL_PWREx_ClearPendingEvent();
HAL_PWREx_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFE, PWR_D2_DOMAIN);

 

"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."
PacoAuthor
Associate III
June 27, 2025

Thank you for your reply.

I tried as you taught me, but it didn't break on breakpoint. The breakpoint is set at HAL_Init() line in CM4 main function.  The result was same, when breakpoint is set in other line in CM4 main function.

If you don't mind and have STM32 project in which SYM32CubeIDE breaks at breakpoint set in CM4 main function properly, could you send me that ?

mƎALLEm
Technical Moderator
June 27, 2025

Please share you project so we can help you efficiently and avoid unnecessary ping pongs.

Thank you.

"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."
mƎALLEm
Technical Moderator
July 4, 2025

Hello,

Try with STLINK GDB server:

mALLEm_0-1751616083933.png

This is what I'm using for your project.

"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."
PacoAuthor
Associate III
July 7, 2025

Hello,

I tried with STLINK GDB server, but it didn't break on CM4 code.

By the way, I noticed the following.

When main in CM4 was selected and I started debuging, it broke on CM4, as shown in image below.

It is the case that breakpoint is set at "HAL_Init();" line in CM4 main function.

Paco_2-1751849110188.png

 

But, when main in CM7 was selected and I started debuging, it didn't break on CM4, as shown in image below.

In this case, LED1 didn't turn on. LED1 turning on proccess is in CM4.

Paco_1-1751848950584.png

I think that after reset, CM7 and CM7 is started at the same time. But one cpu only starts, mentioned above.

Could you tell me the way how both cpu is started at the same time on debugger?

Thank you.

 

 

 

mƎALLEm
Technical Moderator
July 10, 2025

Hello @Paco,

Could you please explain why you accepted as solution this reply?

mALLEm_0-1752136565579.png

 

"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."
PacoAuthor
Associate III
July 10, 2025

Hello mƎALLEm.

I'm sorry but I may click by mistake.

This matter remains unresolved.