Skip to main content
Associate II
Solved

B-G431B-ESC1 HardFault with MCW generated code

I generated some code with the default "Electronic speed control on B-G431B-ESC1 kit" project in Motor Control WorkBench.  Then when I flash the default code I get a HardFault when calling `__HAL_FLASH_PREFETCH_BUFFER_ENABLE()` in  `HAL_Init()`:

int main(void)
{
 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

...

HAL_StatusTypeDef HAL_Init(void)...

#if (PREFETCH_ENABLE != 0U)
 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */

MC Workbench v6.2

CubeMX version 6.9.2

CubeIDE version 1.14.0

 

    This topic has been closed for replies.
    GMA
    GMABest answer
    ST Technical Moderator

    Hello,

    I was able to pass the HAL_init step on "ElectronicSpeedControl_ESC-G4" example with MC Workbench v6.2, CubeMX version 6.9.2, CubeIDE version 1.14.0, (Firmware Package Version STM32 FW V1.5.1) and Drive Type LL or HAL.

    Could you please check that via IDE you have access to FLASH registers as below?

    GMA_0-1702476811235.png

     

    If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA

    3 replies

    GMA
    GMABest answer
    ST Technical Moderator

    Hello,

    I was able to pass the HAL_init step on "ElectronicSpeedControl_ESC-G4" example with MC Workbench v6.2, CubeMX version 6.9.2, CubeIDE version 1.14.0, (Firmware Package Version STM32 FW V1.5.1) and Drive Type LL or HAL.

    Could you please check that via IDE you have access to FLASH registers as below?

    GMA_0-1702476811235.png

     

    If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA
    Associate II

    I tried regenerating the project and was able to pass this init step without hardfault.  The only other thing I did was update STLink.  Not sure why the problem went away but thank you.

    GMA
    ST Technical Moderator

    Hello,

    Thank you for your feedback!

    If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA