Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


Initialisation fails when using CubeMX and HSE clock source

Hi,

I am using Windows 10 Pro with SMT32CubeMX (V4.20) and firmware STM32Cube FW_F4 V1.15.0 imported into System Workbench for STM32 (V1.13.1).

I am using an Olimex P405 (STM32F405RGT6 device) development board and ST-LINK/V2 JTAG debugger.

When I configure the CubeMX project to use HSI clock everything works as expected. However, I would like to use HSE as the clock source which is connected to an 8MHz crystal. In this case the function HAL_RCC_OscConfig() returns the error HAL_ERROR.

On further inverstigation into the execution of HAL_RCC_OscConfig(), I find the following.

The first part of the function that configures the HSE clock succeeds and the external crystal oscillator starts up and can be seen on an oscilloscope.

The next part of the function that configures the HSI clock fails at the following line of code.

if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON))
{
return HAL_ERROR;
}

Any help why this is happening would be appreciated.

Regards
FarmerJo

This bug was introduced by CubeMX v4.20.
In SystemClock_Config() function, when HSE is selected it generates code:

RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;

/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

Notice the OscillatorType filed is initialized for BOTH HSI and HSE, while later field HSIState is never set.

So you have two solutions:

  • either remove RCC_OSCILLATORTYPE_HSI for the line to be like this:
    • RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  • or add HSIState field like this:
    • RCC_OscInitStruct.HSIState = RCC_HSI_ON;


I hope they will fix this ASAP, as you have to edit SystemClock_Config() every time the project is regenerated..

Thanks for the reply.

Yes I found the same things. So in order not to have to hand modify the auto-generated code every time I rebuilt the cube code I reverted back to the previous version of cube, which works as expected.

Regards
FarmerJo


I have exact same problem.
I always have to remove RCC_OSCILLATORTYPE_HSI when using HSE for RCC.
Hope this bug be fixed soon.