cancel
Showing results for 
Search instead for 
Did you mean: 

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

Paco
Associate III

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.

12 REPLIES 12
mƎALLEm
ST Employee

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.

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 ?

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.

I attached project folder.

Could you please investigate this?

Thank you.

Hello,

I tested your project and contrarily to what you have said,:


@Paco wrote:

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.


you didn't follow the recommendation I provided to you previously. You need to comment out:

For 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();
}

For CM4:

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

You need also to upload the application for CM7 first as it is responsible to configure the clock and the power settings.

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.

Thank you for your reply.

I'm sorry for sharing files which do not follow your recommendation.

I commented out in CM7 and CM4 as you taught me, and executed project, but it did not break at breakpoint set in CM4.

You said "You need also to upload the application for CM7 first as it is responsible to configure the clock and the power settings." in your last response.

I executed project following the pdf file bellow. I select ST-LINK (OpenOCD) as the [Debug probe].

I'm not sure following this is right.

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

Thank you.

Hello, 

Please do the following:

1- Comment the code lines I mentioned previously

2- Compile both projects CM7+CM4

3- Upload the CM7 project 

4- Upload CM4 and start your debug session

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.

Thank you for your instruction.

I did next steps to follow your instruction. Would you point out any mistakes? 

1. Comment out the code lines you mentioned previously

2. Compile both projects CM7+CM4.

3. Open CM7 Debug Configurations dialog and go to Debugger tab. Set ST-LINK(OpenOCD) to [Debug probe] field, and set Connect under reset to [Reset Mode] field.

Paco_1-1751600394507.png

4.Go to Startup tab, and add TestPrj _CM4 project, as shown in image below.

Paco_3-1751601470603.png

5.Open CM4 Debug Configurations dialog, and set ST-LINK(OpenOCD) to [Debug probe] field, and set "3335" to [Port number] field, and Core reset to [Reset Mode] field.

Paco_2-1751600547950.png

6.Go to Startup tab, and edit TestPrj _CM4 project in which download is false, as shown in image below.

Paco_4-1751601792936.png

7.Open New_configuration window, and add TestPrj_CM7_Debug and TestPrj_CM4_Debug as shown in image below.

 

Paco_6-1751602302436.png

8.Select New_configuration and click Debug button, and uploading is started.

 

Paco_8-1751603068259.png

9.After uploading is done, set breakpoint at "MX_GPIO_Init();" line in CM4 main function. That line is positioned below "HAL_GPIO_WritePin (GPIOI, (uint16_t)GPIO_PIN_12, GPIO_PIN_RESET);" line.

Paco_9-1751605397151.png

10.Click reset button, and click Resume button. But it doesn't break, although LED1 was turned on.

Paco_10-1751605488976.png

Sorry for long sentence.

Thank you.

 

 

 

mƎALLEm
ST Employee

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.