Bug Summary
Some weird use of pointers that requires two generated variables to be in a contiguous memory space which they are not guaranteed
Detailed Description
With reference to the LPBAM_SPI_TransmitReceive example for NUCLEO-U575ZI-Q in STM32Cube_FW_U5_V1.9.0:
main.c [43,44]
DMA_HandleTypeDef handle_LPDMA1_Channel0;
DMA_HandleTypeDef handle_LPDMA1_Channel1;
main.c [51]
DMA_HandleTypeDef *LPBAM_TxRx_MultiConf_DMAHandlers[2];
main.c [147,148]
LPBAM_TxRx_MultiConf_DMAHandlers[0U] = &handle_LPDMA1_Channel0;
LPBAM_TxRx_MultiConf_DMAHandlers[1U] = &handle_LPDMA1_Channel1;
main.c [166,175]
MX_TxRx_MultiConf_Start(LPBAM_TxRx_MultiConf_DMAHandlers[0U]);
/* Enter Stop2 mode */
Enter_Stop2_Mode();
/* LPBAM TxRx application MultiConf scenario stop */
MX_TxRx_MultiConf_Stop(LPBAM_TxRx_MultiConf_DMAHandlers[0U]);
/* LPBAM TxRx application MultiConf scenario unlink */
MX_TxRx_MultiConf_UnLink(LPBAM_TxRx_MultiConf_DMAHandlers[0U]);
Reference for pointer use:
lpbam_txrx_multiconf_config.c [199-211]
void MX_TxRx_MultiConf_Start(DMA_HandleTypeDef *hdma)
{
/* LPBAM start DMA channel in linked-list mode */
if (HAL_DMAEx_List_Start(&hdma[COUPLED_TRANSMIT_Q_IDX]) != HAL_OK)
{
Error_Handler();
}
/* LPBAM start DMA channel in linked-list mode */
if (HAL_DMAEx_List_Start(&hdma[TRANSMIT_Q_IDX]) != HAL_OK)
{
Error_Handler();
}
}
This clearly only works under the assumption that
DMA_HandleTypeDef handle_LPDMA1_Channel0;
DMA_HandleTypeDef handle_LPDMA1_Channel1;
are in this order directly one after the other in memory. The assumption does not hold and can create problems, especially when optimization is used.
The occurrence is forced by the function prototype, which is meant to be always
void MX_TxRx_MultiConf_Start(DMA_HandleTypeDef *hdma)
though it should be
void MX_TxRx_MultiConf_Start(DMA_HandleTypeDef **hdma)
and requires changing the function calls of both:
I assume that there is no "easy" workaround since it would require lots of changes in the code generator.
It is possible to fix this in the linker script theoretically, but a heck of work certainly not meant to work like this.
Though I am certain about this, please correct me if I am wrong.
Expected Behavior
reference the correct handle in function HAL_DMAEx_List_Start()
Actual Behavior
called the wrong handle when using optimization
Environment
LPBAM_SPI_TransmitReceive example for NUCLEO-U575ZI-Q in STM32Cube_FW_U5_V1.9.0 as an example but targets alle coupled queue lpbam generated code
Severity
Normal
Bug Summary
Some weird use of pointers that requires two generated variables to be in a contiguous memory space which they are not guaranteed
Detailed Description
With reference to the
LPBAM_SPI_TransmitReceiveexample forNUCLEO-U575ZI-QinSTM32Cube_FW_U5_V1.9.0:main.c [43,44]main.c [51]main.c [147,148]main.c [166,175]Reference for pointer use:
lpbam_txrx_multiconf_config.c [199-211]This clearly only works under the assumption that
are in this order directly one after the other in memory. The assumption does not hold and can create problems, especially when optimization is used.
The occurrence is forced by the function prototype, which is meant to be always
though it should be
and requires changing the function calls of both:
HAL_DMAEx_List_Start()I assume that there is no "easy" workaround since it would require lots of changes in the code generator.
It is possible to fix this in the linker script theoretically, but a heck of work certainly not meant to work like this.
Though I am certain about this, please correct me if I am wrong.
Expected Behavior
reference the correct handle in function HAL_DMAEx_List_Start()
Actual Behavior
called the wrong handle when using optimization
Environment
LPBAM_SPI_TransmitReceive example for NUCLEO-U575ZI-Q in STM32Cube_FW_U5_V1.9.0 as an example but targets alle coupled queue lpbam generated code
Severity
Normal