Camera initialization bug: use uninitialized field DMA_Handle of hDcmiEval in application Camera_To_USBDisk
The field DMA_Handle of the local data pointer phdcmi, which points to a global struct variable hDcmiEval, is not initialized in the function BSP_CAMERA_Init (from the file STM32Cube_FW_F4_V1.25.0/Drivers/BSP/STM32469I_EVAL/stm32469i_eval_camera.c).
uint8_t BSP_CAMERA_Init(uint32_t Resolution)
{
DCMI_HandleTypeDef *phdcmi;
uint8_t status = CAMERA_ERROR;
/* Get the DCMI handle structure */
phdcmi = &hDcmiEval;
/*** Configures the DCMI to interface with the camera module ***/
/* DCMI configuration */
phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME;
phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_HIGH;
phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
phdcmi->Instance = DCMI;
/* Configure IO functionalities for CAMERA detect pin */
BSP_IO_Init();
/* Apply Camera Module hardware reset */
BSP_CAMERA_HwReset();
...
}In the function HAL_DCMI_Start_DMA (from the file STM32Cube_FW_F4_V1.25.0/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi.c), the DMA_Handle field is used to store function pointers.
HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
{
/* Initialize the second memory address */
uint32_t SecondMemAddress = 0U;
/* Check function parameters */
assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));
/* Process Locked */
__HAL_LOCK(hdcmi);
/* Lock the DCMI peripheral state */
hdcmi->State = HAL_DCMI_STATE_BUSY;
/* Enable DCMI by setting DCMIEN bit */
__HAL_DCMI_ENABLE(hdcmi);
/* Configure the DCMI Mode */
hdcmi->Instance->CR &= ~(DCMI_CR_CM);
hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode);
/* Set the DMA memory0 conversion complete callback */
hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAXferCplt;
/* Set the DMA error callback */
hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;
/* Set the dma abort callback */
hdcmi->DMA_Handle->XferAbortCallback = NULL;
...
}However, DMA_Handle points to the memory address 0x0000_0000, which is a invalid memory address.
In ARM Cortex-M4 MCUs, the code starts 0x800_0000.
I am confused why this application runs well and does not crash. Is address 0x0000_0000 a valid memory address?
