cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F427 custom Bootloader with Watchdog can't refresh

melfice
Associate III

I have a STM32F427 bootloader code, the jump from bootloader to application is working before enabled IWDG. The IWDG configuration is as followings: -

hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
hiwdg.Init.Reload = 1000; // 8S, 1000*8ms=8000ms=8S 

After enable the IWDG, the jump from bootloader to application is failed, and it keep reseting every 8 seconds. There is Watchdog refresh code before and after time consuming functions and the main while loop: -

  while (1)
  {
...
    if (bl_uart_status==BL_NACK)
    {
#ifdef ENABLE_WATCHDOG      
      HAL_IWDG_Refresh(&hiwdg);
#endif      
      bl_retry_cnt++;
      LED0=0;
    }else {
#ifdef ENABLE_WATCHDOG      
        HAL_IWDG_Refresh(&hiwdg);
#endif    
...

 The bootloader is running with the following clock setting: -

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

 

Do you have any idea why the watchdog timeout happens even HAL_IWDG_Refresh(&hiwdg) is added?

FYI, I have also added the watchdog refresh at bootloader before jumping and at the application's SystemInit().

Thank you.

 

Melfice

 

11 REPLIES 11

I have modified the .ini file for running bootloader before debug application. And I catch the bug at 

STL_InitClock_Xcross_Measurement(), it return the fail_code 0x66. The STM CLASS B code is normal while watchdog is not enabled. The suggestion is to modify the source in stm32f4xx_STLclock.c. But I am using the library version, there is no such file in my application code. Are there any suggestions on this issue?
 
Thank you.
 
Melfice

 

Google result: "STL_InitClock_Xcross_Measurement() is part of STMicroelectronics’ IEC 60335 Class B Safety Library (often delivered as X-CUBE-CLASSB for STM32 MCUs).
It is used to initialize the clock cross-check measurement mechanism, which is a safety feature that verifies the main system clock against an independent reference clock (usually LSI or HSI) to detect clock failures."

Since it is ST software, you can ask ST for support.