-
Notifications
You must be signed in to change notification settings - Fork 7.4k
ADC DMA fails on FRDM K64F #56070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@heinwessels please take a look, commit points to a change you made to the test |
The failure shown in the description is caused by me changing the
It's likely the crash is called by a test failing, but the cause of the test failing concerns me. |
Thanks @heinwessels for qiuck analysis, I am checking the driver. |
Having a look at The potential problematic code is here: zephyr/drivers/adc/adc_mcux_adc16.c Line 275 in 1dce3c3
When starting the DMA the bytes-to-transfer (called IMO 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. zephyr/drivers/adc/adc_stm32.c Line 319 in 1dce3c3
@hakehuang do you think this might be it? |
@heinwessels , I will craete a PR for this fix, btw will you fix the interval_us issue, or you want to fix in as well? |
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! |
@hakehuang I'm not sure how to fix the tests in a generic way, because I'm not sure of what the NXP drivers need. Could you possibly tell me why? For example, before my changes, the For zephyr/tests/drivers/adc/adc_dma/src/test_adc.c Lines 247 to 248 in aac0328
For test_task_with_interval it's set to 500 .
For test_task_repeated_samplings it's set to 10000 .zephyr/tests/drivers/adc/adc_dma/src/test_adc.c Lines 401 to 403 in aac0328
For me this all seems like it should all be replaced with a single value, because that's the minimum value that seems to work, and most tests can use that. So I can replace the #define MINIMUM_SAMPLING_TIME = 2 The only test that might need a different timing is #define INTERVAL_SAMPLING_TIME = 500
// in the test_task_with_interval test
options.interval_us = INTERVAL_SAMPLING_TIME;
zassert_true(milliseconds_spent > ( options.extra_samplings * INTERVAL_SAMPLING_TIME ), "..."); What do you think? Can I fix the tests this way? |
the sample interval depends on the hardware mode, the minial interval is 2us for nxp paltforms(consider the longsample mode), and our adc is triggerred by a counter timer form HW, the counter is set to 2us as well. As to the 500US and 1000US, it is because I want to make sure the sample interval is double of the sample interval time, such as I can get exact a new data back. |
For the changes to
How can the driver know the expect result to return? in your test it is 1 plus 4 extra, but buffer given 24. and I did not see an option pass to driver on the exact number of results expected. say if someone wants 2 records in adc read, how could they do this? @heinwessels |
Of course. This would be a
As far as I can see, it doesn't matter. If this This means it should still wait for your hardware timer. The important part is this function: zephyr/drivers/adc/adc_context.h Lines 203 to 222 in a7c011b
I will implement it this way, and then maybe you can check if the NXP tests still pass?
The |
@heinwessels , the NXP DMA can support multiple samples and increate the buffer by HW, so it will not need the extra software involving. I think maybe you can just skip the extra check so only do below
and remove the
|
In that case it should still set the The test is correct. If the user wants a read with 4 extra samples and supplies a buffer, then only |
sure, please add me to your PR review list. Thanks |
@heinwessels , I check the adc.h and find they define so
our driver does not porcess the extra_samplings at all, I will add a PR to fix it, Thanks a lot for your checking |
@heinwessels , I find another issue here, see below
the issue is that is I correct the adc_mcux_adc16.c with 2 transfer and set the block_size to sizeof(int16_t) * (1 + options.extra_samples), and the test_adc_repeated_samplings still fails as it expect to get only one result, but as our driver do 1 + extra_samples in batches, the adc_context_on_sampling_done does not work here, how to handle this? and I try to change the block_size to 2 so that it is handled by the adc_context_on_sampling_done , but the issue is below function
and
and as the repeat_sampling is false, so we do not move the data point at all.
|
@hakehuang I still think your NXP driver should have How the NXP driver should work:
|
Ah yeah, it might be that you have to add that. It's that exact line that caused me to improve the unit tests to check the buffer which is now failing for NXP, because I also forgot it. You can see it here in #52965 (comment) |
@heinwessels , ok, thanks. after those changes it can work now, but I have a customer feedback here.
|
@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: #55783 |
nxp adc channel dma mode does not handle the multi-channel well, I will add the missing parts as well, Thanks to point this out. |
In 6e21ebf the sampling interval was changed, which caused the issue zephyrproject-rtos#56070. This is fixed by allowing different boards to specify a sampling period. Also changed the test_task_with_interval to verify that the supplied interval was used. Signed-off-by: Hein Wessels <[email protected]>
In 6e21ebf the sampling interval was changed, which caused the issue #56070. This is fixed by allowing different boards to specify a sampling period. Also changed the test_task_with_interval to verify that the supplied interval was used. Signed-off-by: Hein Wessels <[email protected]>
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 buffer depends on: PR #56104 fixing: issue #56070 Signed-off-by: Hake Huang <[email protected]>
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
@hakehuang is this issue resolved? |
yes it is resolved, and we see another failure #58467 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
The adc_dma test, buildable using
fails since commit
6e21ebf
It looks like perhaps the NXP specific changes made in this commit broke things.
Test output if helpful
The text was updated successfully, but these errors were encountered: