Skip to main content
yang hong
Associate III
August 10, 2021
Question

st-link gdb debug

  • August 10, 2021
  • 10 replies
  • 3688 views

I have one project built in SW4STM32. I download 1.7 stm32ide and want to start this project in stm32ide. I complete comply. It looks pretty good, the whole project use FREERTOS and tick time use timer6, when I start my program. my program trigger hardfault event and this issue is triggered in  HAL_Init(); I believe the issue comes from timer 6 start up, anybody know how to fix this issue?

This topic has been closed for replies.

10 replies

Mike_ST
Technical Moderator
August 10, 2021

Hello,

Which MCU is it ?

If you go step by step, at what line in HAL_Init() does it fail ?

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
yang hong
yang hongAuthor
Associate III
August 10, 2021

I am using FREERTOS, so I need HAL_InitTick to startup timer 6, when program start HAL_TIM_Base_Start_IT, it causes hardfault.

The same program is working in OPENOCD.

Mike_ST
Technical Moderator
August 10, 2021

Do you have implemented the interrupt code for the TIM6 (named TIM6_IRQHandler ) in stm32xxx_it.c or stm32xxxx_hal_timebase_tim.c file ?

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
yang hong
yang hongAuthor
Associate III
August 10, 2021

hello:

TIM6_DAC_IRQHandler is default function, I didn't add anything inside, but I have timer6 callback function to update my rtc time.

yang hong
yang hongAuthor
Associate III
August 10, 2021

hal_tim_periodElapsedcallback

Mike_ST
Technical Moderator
August 10, 2021

Try to append that code in your file stm32h7xx_hal_timebase_tim.c :

/**

 * @brief This function handles TIM interrupt request.

 * @param None

 * @retval None

 */

void TIM6_DAC_IRQHandler(void)

{

 HAL_TIM_IRQHandler(&htim6);

}

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
yang hong
yang hongAuthor
Associate III
August 10, 2021

I have narrow the code trigger hardfault event.

tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS; in HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)

Mike_ST
Technical Moderator
August 10, 2021

If you are using TIM6 as Systick base, it shouldn't execute the code you just mentionned.

You're calling HAL_TIM_Base_Start_IT with a wrong/invalid timer.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
yang hong
yang hongAuthor
Associate III
August 10, 2021

Hello,

stm32h7xx_hal_timebase_TIM.c is generated by stm32cube, HAL_TIM_Base_Start_IT is added by stm32cube when I use FREERTOS.

I found the issue on HAL_TIM_PeriodElapsedCallback.  rtc_millisecond=999-(temp * 1000/hrtc.Init.SynchPrediv) cause the issue on hrtc.Init.SynchPrediv because hrtc initialization after hal_Init(), so hrtc.Init.SynchPrediv=0, and also the default selection "exception on divide by zero is checked in debug configuration. So a hardfault is triggered, I have modified the program. now I am able to ST-LINK GDB NOW. THANK YOU FOR YOUR SUGGESTION.

I have one more question, I am using NUCLEO-H743ZI2, Is it possible to use J-LINK ? if yes, how to set up?

I want to get some printf message when I debug my program, I used printf function suing j-link, so I want to try j-link, but NUCLEO-H743ZI2, use st-link v3, and j-link can't load j-link to NUCLEO-H743ZI2, Do you have any idea?

Thank you again

Dimonira
Associate
August 11, 2021

What prevents the use of printf together with st-link?