cancel
Showing results for 
Search instead for 
Did you mean: 

Conflicting definition of HAL_DCMI_Init?

Dan Rose
Associate II

I'm experiencing a runtime crash when using DCMI in with `USE_HAL_DCMI_REGISTER_CALLBACKS`.

The crashing lines are

#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
    /*Call registered DCMI line event callback*/
    hdcmi->LineEventCallback(hdcmi);
#else  
    HAL_DCMI_LineEventCallback(hdcmi);
#endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */

This seems to be caused by by conflicting definitions of `HAL_DCMI_Init`.

One definition is in `stm32f4xx_hal_dcmi.c`:

__weak HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
{
//...
  /* Init the DCMI Callback settings */
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
    hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback; /* Legacy weak FrameEventCallback  */ 
    hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback; /* Legacy weak VsyncEventCallback  */ 
    hdcmi->LineEventCallback  = HAL_DCMI_LineEventCallback;  /* Legacy weak LineEventCallback   */  
    hdcmi->ErrorCallback      = HAL_DCMI_ErrorCallback;      /* Legacy weak ErrorCallback       */ 
    
    if(hdcmi->MspInitCallback == NULL)  
    {
      /* Legacy weak MspInit Callback        */
      hdcmi->MspInitCallback = HAL_DCMI_MspInit;
    }
    /* Initialize the low level hardware (MSP) */
    hdcmi->MspInitCallback(hdcmi);
#else  
    /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
    HAL_DCMI_MspInit(hdcmi);
#endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */

There is a conflicting definition that takes priority in `stm32f4xx_hal_dcmi_ex.c`, since it is not declared `__weak`:

HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)

This initializer does *not* assign LineEventCallback, and doesn't even mention `USE_HAL_DCMI_REGISTER_CALLBACKS`

What's the deal? Is this user error or a bug in HAL?

3 REPLIES 3

Hello Dan Rose,

Thanks for your post. I have raised your feedback internally to be reviewed and treated accordingly to the priority. We will give you an update as soon as possible.

Thanks for your contribution.

Regards,

Khouloud.

Hello  Dan Rose,

Backing to this issue, could you please attach a trace / log file, it will be helpful to track the root-cause of the problem.

Thanks in advance,

Regards,

Khouloud.

Dan Rose
Associate II

@Khouloud OTHMAN​ I don't have a trace/log file. The actual crash is a null pointer problem when it calls `hdcmi->LineEventCallback`, which is not initialized by the version of HAL_DCMI_Init in stm32f4xx_hal_dcmi_ex.c.