zephyr: ADC DMA fails on FRDM K64F
Describe the bug The adc_dma test, buildable using
west build -p always -b frdm_k64f -T tests/drivers/adc/adc_dma/drivers.adc-dma
fails since commit 6e21ebf2e03259db8ae216314ced9ed84eb3a0cd
It looks like perhaps the NXP specific changes made in this commit broke things.
Test output if helpful
*** Booting Zephyr OS build zephyr-v3.3.0-1492-ga57810dc3b1e ***
Running TESTSUITE adc_dma
===================================================================
START - test_adc_asynchronous_call
Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/adc/adc_dma/src/test_adc.c:308: test_task_asynchronous_call: (ret not equal to 0)
k_poll failed with error -11
FAIL - test_adc_asynchronous_call in 1.015 seconds
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 23 (10 by maintainers)
Commits related to this issue
- tests: drivers: adc_dma: fix sampling interval failing NXP tests In 6e21ebf the sampling interval was changed, which caused the issue #56070. This is fixed by allowing different boards to specify a s... — committed to fancom/zephyr by heinwessels a year ago
- tests: drivers: adc_dma: fix sampling interval failing NXP tests In 6e21ebf the sampling interval was changed, which caused the issue #56070. This is fixed by allowing different boards to specify a s... — committed to fancom/zephyr by heinwessels a year ago
- driver:adc: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add batch_mode for batc... — committed to nxp-zephyr/zephyr by hakehuang a year ago
- driver:adc: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add batch_mode for batc... — committed to nxp-zephyr/zephyr by hakehuang a year ago
- driver: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add batch_mode for batch dm... — committed to nxp-zephyr/zephyr by hakehuang a year ago
- tests: drivers: adc_dma: fix sampling interval failing NXP tests In 6e21ebf the sampling interval was changed, which caused the issue #56070. This is fixed by allowing different boards to specify a s... — committed to zephyrproject-rtos/zephyr by heinwessels a year ago
- driver: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add protection on invalid b... — committed to nxp-zephyr/zephyr by hakehuang a year ago
- driver: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add protection on invalid b... — committed to zephyrproject-rtos/zephyr by hakehuang a year ago
- driver: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add protection on invalid b... — committed to hsearle/zephyr by hakehuang a year ago
- driver: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add protection on invalid b... — committed to ZYNQHRONIZE/zephyr by hakehuang a year ago
- driver: adc16 dma support async and repeat sample add support for async call and repeat sample test 1. change the DMA req to 2 byte each 2. increase the buffer pre-dma 3. add protection on invalid b... — committed to hsearle/zephyr by hakehuang a year ago
@hakehuang great news! So that means my PR works, and I will remove the draft label.
And my customer also maybe wants such a feature. I’ve opened a RFC to expand the ADC API to support this. If you could comment there that you need it it might get more interaction and decided sooner. You can find it here: https://github.com/zephyrproject-rtos/zephyr/issues/55783
I’ll create a fix for this one. It doesn’t seem to be blocking the CI, so I think it’s fine if it’s two seperate PRs.
Thanks!
Having a look at
adc_mcux_adc16.c
it seems like thedma_block.block_size
is set bigger than it should be, which would explain the(INVALID_ADC_VALUE not equal to sample_value)
error.The potential problematic code is here: https://github.com/zephyrproject-rtos/zephyr/blob/1dce3c3ee2e9db41a0111709c337bafce1a45834/drivers/adc/adc_mcux_adc16.c#L275
When starting the DMA the bytes-to-transfer (called
block_size
) is set tosequence->buffer_size
. And for the test, thebuffer_size
is set to the actual size of the buffer, which is much larger than it needs to be for this specific test, in this case24
.IMO
buffer_size
is the size of the buffer, and should not be used. (only to check that it’s indeed big enough). Instead theblock_size
should be set to something likesizeof(sample)
.In the STM32 driver we set it explictly to the number of channels samples multiplied by the size of each sample, and ignore the actual size of the buffer. https://github.com/zephyrproject-rtos/zephyr/blob/1dce3c3ee2e9db41a0111709c337bafce1a45834/drivers/adc/adc_stm32.c#L319
@hakehuang do you think this might be it?