zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.38k stars 6.36k forks source link

tests: dma: chan_blen_transfer: test breakage on Nucleo-H743ZI #75676

Closed mathieuchopstm closed 6 days ago

mathieuchopstm commented 1 month ago

Describe the bug

(follow-up issue to #75125)

After merge of #75245, the chan_blen_transfer test now succeeds on STM32WB0 MCUs but fails on Nucleo-H743ZI.

Relevant test log extract:

===================================================================                                                                       
START - test_tst_dma1_m2m_chan0_burst16                                                                                                   
Preparing DMA Controller: Name=dmamux@58025800, Chan_ID=4, BURST_LEN=2                                                                    
Starting the transfer                                                                                                                     
E: invalid source address                                                                                                                 
E: cannot configure the dmamux. 

The invalid source address message is emitted here: https://github.com/zephyrproject-rtos/zephyr/blob/662b9803fa9985f499d3627f96589a1ed8d2c8dc/drivers/dma/dma_stm32_bdma.c#L566-L573 where bdma_stm32_is_valid_memory_address is: https://github.com/zephyrproject-rtos/zephyr/blob/662b9803fa9985f499d3627f96589a1ed8d2c8dc/drivers/dma/dma_stm32_bdma.c#L462-L478

TL;DR: the DMA driver refuses the transfer because the source is not in SRAM4.

The regression comes from the fact that, beforehand, the .rodata and .bss segments of the test code could be relocated thanks to: https://github.com/zephyrproject-rtos/zephyr/blob/662b9803fa9985f499d3627f96589a1ed8d2c8dc/tests/drivers/dma/chan_blen_transfer/CMakeLists.txt#L10

And indeed, the Kconfig for Nucleo-H743ZI makes use of this feature: https://github.com/zephyrproject-rtos/zephyr/blob/662b9803fa9985f499d3627f96589a1ed8d2c8dc/tests/drivers/dma/chan_blen_transfer/boards/nucleo_h743zi.conf#L5-L9

Before #75245, the test looked like this: https://github.com/zephyrproject-rtos/zephyr/blob/4180d70439f599a3597b2e31753773cfa222ace2/tests/drivers/dma/chan_blen_transfer/src/test_dma.c#L25-L26

Expected behavior Test should not fail.

Impact Test breakage on Nucleo-H743ZI and potentially all boards with a Kconfig overlay setting CONFIG_DMA_LOOP_TRANSFER_RELOCATE_SECTION (i.e., mimxrt boards).

mathieuchopstm commented 1 month ago

Potential fix proposition: move tx_data and rx_data to a separate file, and relocate the whole file.

Appears to work on STM32WB0 and STM32H7, PR incoming.

mathieuchopstm commented 1 month ago

Fix proposed in #75895.