2021-07-07 01:06 AM
I'm working on the NUCLEO-H745ZI-Q development board and recently configured the clock to its max 480 MHz through STM32CubeMx and tried debugging the code generated by CubeMx on STM32CubeIDE. While suddenly the micro failed to respond after the `SystemClock_Config();` step. From then the micro is failed to communicate with STlink.
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
/** Supply configuration update enable
*/
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
/** 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_DIV1;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 4;
RCC_OscInitStruct.PLL.PLLN = 60;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
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_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_I2C1;
PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
On top of the auto-generated code, I've commented out the code which use to wait for CPU2 to boot and enter stop mode. I was only using CM7 and not used CM4 for my initial testing so commented out the while loop.
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
/* Wait until CPU2 boots and enters in stop mode or timeout*/
//timeout = 0xFFFF;
//while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));
//if ( timeout < 0 )
//{
//Error_Handler();
//}
Did I brick my development board? What are the options left to recover the board/micro?
Solved! Go to Solution.
2021-07-07 03:24 AM
Your STLink FW version is an old version "V3J2M1".
Could you please upgrate your STLink firmware to be at "V3J7M3" version :
STM32
2021-07-07 01:53 AM
Dear @YVeda.1 ,
First, the generated code doesn't correspond to the CubeMx config (as shown in your screenshot).
Second, the NUCLEO-H745ZI-Q board supports only SMPS config power supply. To run @480MHz you should select VOS0 (voltage scale 0) as indicated in the datasheet:
But VOS0 is only supported with LDO config not SMPS like indicated in the datasheet:
So you can't run your MCU with this board @480MHz.
Once your question is answered, please click on "Select as Best" for the comment containing the answer to your initial question.
STM32
2021-07-07 02:25 AM
Oops you are right the code I shared is wrong, I've updated the correct code generated by CubeMx
I followed some ST examples and set the max to 480 Mhz, now I don't really want to go to max frequency.
How do I revert the board back to a working state?
2021-07-07 02:35 AM
Dear @YVeda.1
Ah now, that's clear why you lost the connection with the MCU. You configured the PWR to be in LDO while the default board config is SMPS. So normally your MCU is OK.
So how to recover your board and the MCU?
Please use the latest version of CubeProgrammer and connect the board in "Power down" mode as indicated here in below, then erase the Flash:
PS: once your question is answered, please click on "Select as Best" for the comment containing the answer to your initial question.
STM32
2021-07-07 02:54 AM
Thanks for the quick reply, I've tried the suggestion but getting a different error now. I'm using the latest CubeProgrammer 2.7.0.
2021-07-07 02:56 AM
What is the issue? and what kind of error you are facing? Could you share a screenshot?
2021-07-07 03:09 AM
Could you please try to upgrade your STlink firmware:
Connect your board and click on "Firmware upgrade" button ..
2021-07-07 03:24 AM
Awesome, firmware upgrading the ST_LINK to V3J7M3 worked, now I'm able to connect and erase the flash. Thank you very much.
2021-07-07 03:24 AM
Your STLink FW version is an old version "V3J2M1".
Could you please upgrate your STLink firmware to be at "V3J7M3" version :
STM32